[Libav-user] swr_convert_frame returns -1 while converting u8 to s16 audio format

rizvan.kuliev rizvan.kuliev at ru.axxonsoft.com
Mon Jul 18 16:24:26 CEST 2016


Hi all!

I'm trying to use *swresample *library to resample audio format from 
AV_SAMPLE_FMT_U8 to AV_SAMPLE_FMT_S16.

My file is:

/>ffmpeg -i D:\cam_md_start_1.wav/

/ffmpeg version 0.11.5 Copyright (c) 2000-2014 the FFmpeg developers
   built on Sep 26 2014 01:10:12 with gcc 4.9-win32 (GCC)
   configuration: --enable-memalign-hack --arch=x86_64 
--target-os=mingw32 --cross-prefix=x86_64-w64-mingw32- --disable-ffprobe 
--disable-ffplay --build-suffix=-ovs-3.1 --enable-shared 
--disable-static --enable-libass 
--prefix=/home/gzh/sdk/mingw-x86_64/ffmpeg-ovs-3.1
   libavutil      54.  7.100 / 54.  7.100
   libavcodec     56.  1.100 / 56.  1.100
   libavformat    56.  4.101 / 56.  4.101
   libavdevice    56.  0.100 / 56.  0.100
   libavfilter     5.  1.100 /  5.  1.100
   libswscale      3.  0.100 /  3.  0.100
   libswresample   1.  1.100 /  1.  1.100
Guessed Channel Layout for  Input Stream #0.0 : mono
Input #0, wav, from 'D:\cam_md_start_1.wav':
   Duration: 00:00:01.49, bitrate: 176 kb/s
     Stream #0:0: Audio: *pcm_u8* ([1][0][0][0] / 0x0001), 22050 Hz, 1 
channels, u8, 176 kb/s
At least one output file must be specified

d:\ngp.sdk64\ffmpeg-ovs-3.1\bin>/

The code looks like this:

/std::unique_ptr<SwrContext, SwrContextDtor> m_swr;//
//            m_swr.reset(swr_alloc());//
//            av_opt_set_int(m_swr.get(), "in_channel_layout", 
frame->channel_layout, 0);//
//            av_opt_set_int(m_swr.get(), "out_channel_layout", 
frame->channel_layout, 0);//
//            av_opt_set_int(m_swr.get(), "in_sample_rate", 
frame->sample_rate, 0);//
//            av_opt_set_int(m_swr.get(), "out_sample_rate", 
frame->sample_rate, 0);//
//            av_opt_set_sample_fmt(m_swr.get(), "in_sample_fmt", 
(AVSampleFormat)frame->format, 0);//
//            av_opt_set_sample_fmt(m_swr.get(), "out_sample_fmt", 
AV_SAMPLE_FMT_S16, 0);//
//            swr_init(m_swr.get());//
//std::unique_ptr<AVFrame, AVFrameDtor> converted(av_frame_alloc());//
//        converted->channel_layout = frame->channel_layout;//
//        converted->sample_rate = frame->sample_rate;//
//        converted->format = AV_SAMPLE_FMT_S16;//
//        int err = swr_convert_frame(m_swr.get(), converted.get(), 
frame.get());/

The problem is that swr_convert_frame returns value -1 and doesn't 
convert the frame.
I have attached input frame as frame.txt and output as converted.txt.

Please, could someone help me to understand why swr_convert_frame fails 
to convert format?

-- 

	AxxonSoft 	

Rizvan Kuliev

Programmer

rizvan.kuliev at axxonsoft.com <mailto:rizvan.kuliev at axxonsoft.com>

<http://axxonsoft.com> <http://www.youtube.com/user/ITVAXXON> 
<http://www.linkedin.com/groups/FREE-16-channel-VMS-from-4133198> 
<http://www.facebook.com/axxonsoft> 
<https://twitter.com/#%21/AxxonSoft_EN> <skype:skype.itv.ru?call> 
CONFIDENTIALITY NOTICE <http://www.axxonsoft.com/disclaimer.php>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160718/79ed7577/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cioamlnhbpmblfmb.png
Type: image/png
Size: 4158 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160718/79ed7577/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: daedfhgehlcdekgi.png
Type: image/png
Size: 919 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160718/79ed7577/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jomfjhiimogighgh.png
Type: image/png
Size: 806 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160718/79ed7577/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: djjkkmlpjkfgbakk.png
Type: image/png
Size: 741 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160718/79ed7577/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pmdplakeckjiandi.png
Type: image/png
Size: 597 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160718/79ed7577/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jieimlliankgeocn.png
Type: image/png
Size: 699 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160718/79ed7577/attachment-0005.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ficadgdeclopnbpa.png
Type: image/png
Size: 963 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160718/79ed7577/attachment-0006.png>
-------------- next part --------------
-		frame	unique_ptr {data=0x00000256dc92d260 {0x00000256dc938c60 "}~~~~~~}}}~~~~~~~~~~~~~~~~~~ЂЂЂЂ~~~~~~~~~~~~~~}}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}}}}}}}}}}}}}}}}}}}}}}}}}}}~~~~~~~~~~~}~~~~~}~~~~~~~~~~~~~ЂЂЂЂЂЂ..., ...} ...}	std::unique_ptr<AVFrame,NMMSS::AVFrameDtor> &
-		[ptr]	0x00000256dc92d260 {data=0x00000256dc92d260 {0x00000256dc938c60 "}~~~~~~}}}~~~~~~~~~~~~~~~~~~ЂЂЂЂ~~~~~~~~~~~~~~}}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}}}}}}}}}}}}}}}}}}}}}}}}}}}~~~~~~~~~~~}~~~~~}~~~~~~~~~~~~~ЂЂЂЂЂЂ..., ...} ...}	AVFrame *
+		data	0x00000256dc92d260 {0x00000256dc938c60 "}~~~~~~}}}~~~~~~~~~~~~~~~~~~ЂЂЂЂ~~~~~~~~~~~~~~}}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}}}}}}}}}}}}}}}}}}}}}}}}}}}~~~~~~~~~~~}~~~~~}~~~~~~~~~~~~~ЂЂЂЂЂЂ..., ...}	unsigned char *[8]
+		linesize	0x00000256dc92d2a0 {4096, 0, 0, 0, 0, 0, 0, 0}	int[8]
+		extended_data	0x00000256dc92d260 {0x00000256dc938c60 "}~~~~~~}}}~~~~~~~~~~~~~~~~~~ЂЂЂЂ~~~~~~~~~~~~~~}}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}}}}}}}}}}}}}}}}}}}}}}}}}}}~~~~~~~~~~~}~~~~~}~~~~~~~~~~~~~ЂЂЂЂЂЂ...}	unsigned char * *
		width	0	int
		height	0	int
		nb_samples	4096	int
		format	0	int
		key_frame	1	int
		pict_type	AV_PICTURE_TYPE_NONE (0)	AVPictureType
+		base	0x00000256dc92d2e0 {0x0000000000000000 <NULL>, 0x0000000000000000 <NULL>, 0x0000000000000000 <NULL>, ...}	unsigned char *[8]
+		sample_aspect_ratio	{num=0 den=1 }	AVRational
		pts	-9223372036854775808	__int64
		pkt_pts	0	__int64
		pkt_dts	0	__int64
		coded_picture_number	0	int
		display_picture_number	0	int
		quality	0	int
		reference	0	int
+		qscale_table	0x0000000000000000 <NULL>	char *
		qstride	0	int
		qscale_type	0	int
+		mbskip_table	0x0000000000000000 <NULL>	unsigned char *
+		motion_val	0x00000256dc92d368 {0x0000000000000000 {???, ???}, 0x0000000000000000 {???, ???}}	short[2] *[2]
+		mb_type	0x0000000000000000 {???}	unsigned int *
+		dct_coeff	0x0000000000000000 {???}	short *
+		ref_index	0x00000256dc92d388 {0x0000000000000000 <NULL>, 0x0000000000000000 <NULL>}	char *[2]
		opaque	0x0000000000000000	void *
+		error	0x00000256dc92d3a0 {0, 0, 0, 0, 0, 0, 0, 0}	unsigned __int64[8]
		type	1	int
		repeat_pict	0	int
		interlaced_frame	0	int
		top_field_first	0	int
		palette_has_changed	0	int
		buffer_hints	0	int
+		pan_scan	0x0000000000000000 <NULL>	AVPanScan *
		reordered_opaque	-9223372036854775808	__int64
		hwaccel_picture_private	0x0000000000000000	void *
+		owner	0x0000000000000000 <NULL>	AVCodecContext *
		thread_opaque	0x0000000000000000	void *
		motion_subsample_log2	0 '\0'	unsigned char
		sample_rate	22050	int
		channel_layout	0	unsigned __int64
+		buf	0x00000256dc92d430 {0x0000000000000000 <NULL>, 0x0000000000000000 <NULL>, 0x0000000000000000 <NULL>, ...}	AVBufferRef *[8]
+		extended_buf	0x0000000000000000 {???}	AVBufferRef * *
		nb_extended_buf	0	int
+		side_data	0x0000000000000000 {???}	AVFrameSideData * *
		nb_side_data	0	int
		flags	0	int
		color_range	AVCOL_RANGE_UNSPECIFIED (0)	AVColorRange
		color_primaries	AVCOL_PRI_UNSPECIFIED (2)	AVColorPrimaries
		color_trc	AVCOL_TRC_UNSPECIFIED (2)	AVColorTransferCharacteristic
		colorspace	AVCOL_SPC_UNSPECIFIED (2)	AVColorSpace
		chroma_location	AVCHROMA_LOC_UNSPECIFIED (0)	AVChromaLocation
		best_effort_timestamp	0	__int64
		pkt_pos	-1	__int64
		pkt_duration	0	__int64
		metadata	0x0000000000000000 <NULL>	AVDictionary *
		decode_error_flags	0	int
		channels	1	int
		pkt_size	4096	int
+		qp_table_buf	0x0000000000000000 <NULL>	AVBufferRef *

-------------- next part --------------
+		frame	unique_ptr {data=0x00000256dc92d260 {0x00000256dc92aec0 "}~~~~~~}}}~~~~~~~~~~~~~~~~~~ЂЂЂЂ~~~~~~~~~~~~~~}}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}}}}}}}}}}}}}}}}}}}}}}}}}}}~~~~~~~~~~~}~~~~~}~~~~~~~~~~~~~ЂЂЂЂЂЂ..., ...} ...}	std::unique_ptr<AVFrame,NMMSS::AVFrameDtor> &
		formatContext	identifier "formatContext" is undefined	
		codecContext	identifier "codecContext" is undefined	
		m_codecContext	identifier "m_codecContext" is undefined	
-		converted	unique_ptr {data=0x00000256dc939c80 {0x0000000000000000 <NULL>, 0x0000000000000000 <NULL>, 0x0000000000000000 <NULL>, ...} ...}	std::unique_ptr<AVFrame,NMMSS::AVFrameDtor>
-		[ptr]	0x00000256dc939c80 {data=0x00000256dc939c80 {0x0000000000000000 <NULL>, 0x0000000000000000 <NULL>, 0x0000000000000000 <NULL>, ...} ...}	AVFrame *
+		data	0x00000256dc939c80 {0x0000000000000000 <NULL>, 0x0000000000000000 <NULL>, 0x0000000000000000 <NULL>, ...}	unsigned char *[8]
+		linesize	0x00000256dc939cc0 {0, 0, 0, 0, 0, 0, 0, 0}	int[8]
+		extended_data	0x00000256dc939c80 {0x0000000000000000 <NULL>}	unsigned char * *
		width	0	int
		height	0	int
		nb_samples	0	int
		format	1	int
		key_frame	1	int
		pict_type	AV_PICTURE_TYPE_NONE (0)	AVPictureType
+		base	0x00000256dc939d00 {0x0000000000000000 <NULL>, 0x0000000000000000 <NULL>, 0x0000000000000000 <NULL>, ...}	unsigned char *[8]
+		sample_aspect_ratio	{num=0 den=1 }	AVRational
		pts	-9223372036854775808	__int64
		pkt_pts	-9223372036854775808	__int64
		pkt_dts	-9223372036854775808	__int64
		coded_picture_number	0	int
		display_picture_number	0	int
		quality	0	int
		reference	0	int
+		qscale_table	0x0000000000000000 <NULL>	char *
		qstride	0	int
		qscale_type	0	int
+		mbskip_table	0x0000000000000000 <NULL>	unsigned char *
+		motion_val	0x00000256dc939d88 {0x0000000000000000 {???, ???}, 0x0000000000000000 {???, ???}}	short[2] *[2]
+		mb_type	0x0000000000000000 {???}	unsigned int *
+		dct_coeff	0x0000000000000000 {???}	short *
+		ref_index	0x00000256dc939da8 {0x0000000000000000 <NULL>, 0x0000000000000000 <NULL>}	char *[2]
		opaque	0x0000000000000000	void *
+		error	0x00000256dc939dc0 {0, 0, 0, 0, 0, 0, 0, 0}	unsigned __int64[8]
		type	0	int
		repeat_pict	0	int
		interlaced_frame	0	int
		top_field_first	0	int
		palette_has_changed	0	int
		buffer_hints	0	int
+		pan_scan	0x0000000000000000 <NULL>	AVPanScan *
		reordered_opaque	0	__int64
		hwaccel_picture_private	0x0000000000000000	void *
+		owner	0x0000000000000000 <NULL>	AVCodecContext *
		thread_opaque	0x0000000000000000	void *
		motion_subsample_log2	0 '\0'	unsigned char
		sample_rate	22050	int
		channel_layout	0	unsigned __int64
+		buf	0x00000256dc939e50 {0x0000000000000000 <NULL>, 0x0000000000000000 <NULL>, 0x0000000000000000 <NULL>, ...}	AVBufferRef *[8]
+		extended_buf	0x0000000000000000 {???}	AVBufferRef * *
		nb_extended_buf	0	int
+		side_data	0x0000000000000000 {???}	AVFrameSideData * *
		nb_side_data	0	int
		flags	0	int
		color_range	AVCOL_RANGE_UNSPECIFIED (0)	AVColorRange
		color_primaries	AVCOL_PRI_UNSPECIFIED (2)	AVColorPrimaries
		color_trc	AVCOL_TRC_UNSPECIFIED (2)	AVColorTransferCharacteristic
		colorspace	AVCOL_SPC_UNSPECIFIED (2)	AVColorSpace
		chroma_location	AVCHROMA_LOC_UNSPECIFIED (0)	AVChromaLocation
		best_effort_timestamp	-9223372036854775808	__int64
		pkt_pos	-1	__int64
		pkt_duration	0	__int64
		metadata	0x0000000000000000 <NULL>	AVDictionary *
		decode_error_flags	0	int
		channels	0	int
		pkt_size	-1	int
+		qp_table_buf	0x0000000000000000 <NULL>	AVBufferRef *



More information about the Libav-user mailing list