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

[email protected] <mailto:[email protected]>

<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>

-               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 *

+               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 *

_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to