encoding/decoding h.264

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
25 messages Options
12
Reply | Threaded
Open this post in threaded view
|

encoding/decoding h.264

musikit
hello,

i am trying to build a project using ffmpeg that will encode/decode h.
264 data.

we have an RGB24 image and we would like a decoded RGB24 image on the
ouput

i am trying to setup ffmpeg to do this for me and i am having
difficulty getting the parameters correct.

i know i need to do a RGB24->YUV420 conversion which i do using
sws_scale before encoding
i know i need to do a YUV420->RGB24 conversion which i do using
sws_scale after decoding.

i know that the sws_scale before the encode and after the decode work
because if i comment out the encode/decode the original image shows
(minus conversion differences)

for encoding i have set up the following parameters

encoder = avcodec_alloc_context();
encoder->bit_rate = 16 * 1000;
encoder->rc_max_rate = 16 * 1000;
       
encoder->width = 160;
encoder->height = 120;

encoder->time_base.num = 1;
encoder->time_base.den = 30;
encoder->gop_size = 10;
encoder->max_b_frames = 1;
encoder->pix_fmt = PIX_FMT_YUV420P;


my decoder settings are

decoder = avcodec_alloc_context();
decoder->width = 160;
decoder->height = 120;
decoder->pix_fmt = PIX_FMT_YUV420P;


i do get a picture out but it looks nothing like my original picture.

any assistance anyone can provide would very much be appreciated.

Peter Wilkes


_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

avcodec_decode_audio2 doesn't decode small buffers

Thomas Rehaag
Hi,

I've got a problem using avcodec_decode_audio2 to read audio from MPEG1.
After av_read_packet has got an audio packet, my program calls
avcodec_decode_audio2 sequently until the buffer is decoded. Now
avcodec_decode_audio2 always

decodes 192 bytes. And when less then 192 bytes are left over, it
returns -1 (error).

This leads to a rhythm of clicks in the background and sometimes to a
short, loud noise.
Can anybody tell me, what I've done wrong?

You'll find the main code at the bottom of this mail,
the decoded sound as an mp3 at:
http://www.ismism.de/xc/Mpeg2Wav.mp3
and a very low res version of the MPEG1 movie (for the original sound)
at:
http://www.ismism.de/xc/in_lo.mpg
The complete function is here:
http://www.ismism.de/xc/readAudioFromMpeg1.cpp

Thanks,

Thomas


    while(1)//get audio packets only
    {
        // Free old avPacket
        if(avPacket.data!=NULL)
            av_free_packet(&avPacket);

        // Read new avPacket
        if(av_read_packet(pFormatCtx, &avPacket)<0)
        {
                break;//the job is done
        }
        if(avPacket.stream_index == lIxAudioStream)
        {
                long lAudioBytesRemaining=avPacket.size;
                long lAudioRawDataSize = avPacket.size;
                uint8_t  * pAudioRawData=avPacket.data;
                int bytesDecoded = -1;
               
                while(1)
                {
                        int iNumAudioBytes = AVCODEC_MAX_AUDIO_FRAME_SIZE;
                        //padding zeros for avcodec_decode_audio2
                        long lSize = lAudioBytesRemaining  + FF_INPUT_BUFFER_PADDING_SIZE;
                        uint8_t  * pIn = new uint8_t[lSize];
                        memset(pIn, 0, lSize);
                        memcpy(pIn, pAudioRawData, lAudioBytesRemaining);
                        bytesDecoded=avcodec_decode_audio2(pAudioCodecCtx, pAudioBuffer,
&iNumAudioBytes, pIn, lAudioBytesRemaining);
                        delete pIn;
                        if(bytesDecoded < 0)
                        {
                                break;//Decoding error!
                        }
                        else
                        {
                                //write iNumNewAudioBytes of pAudioBuffer to a wave file:
                        }
                        lAudioBytesRemaining-=bytesDecoded;
                        pAudioRawData += bytesDecoded;
                }
        }
    }
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: avcodec_decode_audio2 doesn't decode small buffers

Thomas Rehaag
Hi,

problem solved - I've joined the undecoded buffers with the following
ones. Now everything sounds perfect.

Cheers,

Thomas
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: avcodec_decode_audio2 doesn't decode small buffers

Michel Bardiaux-2
Thomas Rehaag a écrit :
> Hi,
>
> problem solved - I've joined the undecoded buffers with the following
> ones. Now everything sounds perfect.
>
Still, I dont understand how you can end up with partial buffers. In
*my* code, for MPEG1 audio, I always get complete packets of 576 bytes
from av_read_packet.

Greetings,
--
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:[hidden email]

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: avcodec_decode_audio2 doesn't decode small buffers

Thomas Rehaag


Michel Bardiaux schrieb:

>
> Thomas Rehaag a écrit :
> > Hi,
> >
> > problem solved - I've joined the undecoded buffers with the following
> > ones. Now everything sounds perfect.
> >
> Still, I dont understand how you can end up with partial buffers. In
> *my* code, for MPEG1 audio, I always get complete packets of 576 bytes
> from av_read_packet.
>
> Greetings,
> --
> Michel Bardiaux


.. so it must have something to do with the initialization from
av_open_input_file to avcodec_open.
Maybe I missed something. My code is below.

Best Regards,

Thomas



long CAvIn::Open(char *pFileName)
{

       
        if(m_bOpen)
        {
                return 0;
        }

        m_bGotAudio = false;
        m_bGotVideo = false;
        m_lRawAudioBufferPos = 0;

        m_pAudioRawRestData = 0;
        m_lAudioRawRestDataSize = 0;
        m_bAudioDecodeError = false;

        m_lAudioBytesRemaining = 0;
        m_lVideoBytesRemaining = 0;
        m_bOpen = true;
    int numBytes;
        m_lError = 0;


    // Open video file
    if(av_open_input_file(&m_pFormatCtx, pFileName, NULL, 0, NULL)!=0)
        {
                m_lError = 1;
                sprintf(m_pcError,"Couldn't open file");
        return 0; //
        }

    // Retrieve stream information
    if(av_find_stream_info(m_pFormatCtx)<0)
        {
                m_lError = 1;
                sprintf(m_pcError,"Couldn't find stream information");
        return 0; //
        }

    // Dump information about file onto standard error
    //dump_format(m_pFormatCtx, 0, pFileName, false);

    // Find the first video and audio stream
    m_lIxVideoStream=-1;
    m_lIxAudioStream=-1;

    for(unsigned long ix=0; ix<m_pFormatCtx->nb_streams; ix++)
        {
       
if(m_pFormatCtx->streams[ix]->codec->codec_type==CODEC_TYPE_VIDEO &&
m_lIxVideoStream==-1)
        {
            m_lIxVideoStream=ix;
            //break;
        }
       
if(m_pFormatCtx->streams[ix]->codec->codec_type==CODEC_TYPE_AUDIO &&
m_lIxAudioStream==-1)
        {
            m_lIxAudioStream=ix;
            //break;
        }
        }

    if(m_lIxVideoStream==-1)
        {
                m_lError = 1;
                sprintf(m_pcError,"Didn't find a video stream");
        return 0; //
        }
    // Get a pointer to the codec context for the video stream
    m_pCodecCtx=m_pFormatCtx->streams[m_lIxVideoStream]->codec;

    // Find the decoder for the video stream
    m_pCodec=avcodec_find_decoder(m_pCodecCtx->codec_id);
    if(m_pCodec==NULL)
        {
                m_lError = 1;
                sprintf(m_pcError,"Codec not found");
        return 0; //
        }

    // Inform the codec that we can handle truncated bitstreams -- i.e.,
    // bitstreams where frame boundaries can fall in the middle of
packets

    if(m_pCodec->capabilities & CODEC_CAP_TRUNCATED)
        m_pCodecCtx->flags|=CODEC_FLAG_TRUNCATED;

    // Open codec
    if(avcodec_open(m_pCodecCtx, m_pCodec)<0)
        {
                m_lError = 1;
                sprintf(m_pcError,"Could not open codec");
        return 0; //
        }


    // Hack to correct wrong frame rates that seem to be generated by
some
    // codecs

        //correct transformation for the new CodecContext struct
    if(m_pCodecCtx->time_base.den  >1000 &&
m_pCodecCtx->time_base.num==1)
        m_pCodecCtx->time_base.num=1000;


    // Allocate video frame
    m_pFrame=avcodec_alloc_frame();


        //m_pFrameRGB will probably not be used!!
    // Allocate an AVFrame structure
    m_pFrameRGB=avcodec_alloc_frame();
    if(m_pFrameRGB==0  || m_pFrame==0)
        {
                m_lError = 1;
                sprintf(m_pcError,"memory error");
        return 0;
        }
    // Determine required buffer size and allocate buffer
    numBytes=avpicture_get_size(PIX_FMT_RGB24, m_pCodecCtx->width,
        m_pCodecCtx->height);
    m_pBuffer=new uint8_t[numBytes];

    // Assign appropriate parts of buffer to image planes in m_pFrameRGB
    avpicture_fill((AVPicture *)m_pFrameRGB, m_pBuffer, PIX_FMT_RGB24,
        m_pCodecCtx->width, m_pCodecCtx->height);


        //Audio . . .
        if(m_lIxAudioStream != -1)
        {
                // Get a pointer to the codec context for the video stream
                m_pAudioCodecCtx=m_pFormatCtx->streams[m_lIxAudioStream]->codec;

                // Find the decoder for the video stream
                m_pAudioCodec=avcodec_find_decoder(m_pAudioCodecCtx->codec_id);
                if(m_pAudioCodec==NULL)
                {
                        m_lAudioError = 1;
                        sprintf(m_pcError,"Audio Codec not found");
                }



                // Inform the codec that we can handle truncated bitstreams -- i.e.,
                // bitstreams where frame boundaries can fall in the middle of packets
                //long test = CODEC_FLAG_TRUNCATED;
                if(m_pAudioCodec->capabilities & CODEC_CAP_TRUNCATED)
                        m_pAudioCodecCtx->flags|=CODEC_FLAG_TRUNCATED;

                // Open codec
                if(avcodec_open(m_pAudioCodecCtx, m_pAudioCodec)<0)
                {
                        m_lAudioError = 1;
                        sprintf(m_pcError,"Could not open audio codec");
                }


                m_pAudioFrameBuffer = new int16_t[AVCODEC_MAX_AUDIO_FRAME_SIZE];
       
       
        }

        return 1;
}
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: avcodec_decode_audio2 doesn't decode small buffers

Michel Bardiaux-2
Thomas Rehaag a écrit :

>
> Michel Bardiaux schrieb:
>> Thomas Rehaag a écrit :
>>> Hi,
>>>
>>> problem solved - I've joined the undecoded buffers with the following
>>> ones. Now everything sounds perfect.
>>>
>> Still, I dont understand how you can end up with partial buffers. In
>> *my* code, for MPEG1 audio, I always get complete packets of 576 bytes
>> from av_read_packet.
>>
>> Greetings,
>> --
>> Michel Bardiaux
>
>
> .. so it must have something to do with the initialization from
> av_open_input_file to avcodec_open.
> Maybe I missed something. My code is below.
>
> //long test = CODEC_FLAG_TRUNCATED;
> if(m_pAudioCodec->capabilities & CODEC_CAP_TRUNCATED)
> m_pAudioCodecCtx->flags|=CODEC_FLAG_TRUNCATED;
>
I dont see the usefulness of this unless you expect corrupted streams. I
dont use that flag.

Greetings,
--
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:[hidden email]

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: avcodec_decode_audio2 doesn't decode small buffers

Thomas Rehaag


Michel Bardiaux schrieb:

>
> Thomas Rehaag a écrit :
> >
> > Michel Bardiaux schrieb:
> >> Thomas Rehaag a écrit :
> >>> Hi,
> >>>
> >>> problem solved - I've joined the undecoded buffers with the following
> >>> ones. Now everything sounds perfect.
> >>>
> >> Still, I dont understand how you can end up with partial buffers. In
> >> *my* code, for MPEG1 audio, I always get complete packets of 576 bytes
> >> from av_read_packet.
> >>
> >> Greetings,
> >> --
> >> Michel Bardiaux
> >
> >
> > .. so it must have something to do with the initialization from
> > av_open_input_file to avcodec_open.
> > Maybe I missed something. My code is below.
> >
> >               //long test = CODEC_FLAG_TRUNCATED;
> >               if(m_pAudioCodec->capabilities & CODEC_CAP_TRUNCATED)
> >                       m_pAudioCodecCtx->flags|=CODEC_FLAG_TRUNCATED;
> >
> I dont see the usefulness of this unless you expect corrupted streams. I
> dont use that flag.
>
> Greetings,
> --
> Michel Bardiaux

Hi Michael,

deleted the lines - no difference.

Regards,

Thomas
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: avcodec_decode_audio2 doesn't decode small buffers

Michel Bardiaux-2
Thomas Rehaag a écrit :

>
> Michel Bardiaux schrieb:
>> Thomas Rehaag a écrit :
>>> Michel Bardiaux schrieb:
>>>> Thomas Rehaag a écrit :
>>>>> Hi,
>>>>>
>>>>> problem solved - I've joined the undecoded buffers with the following
>>>>> ones. Now everything sounds perfect.
>>>>>
>>>> Still, I dont understand how you can end up with partial buffers. In
>>>> *my* code, for MPEG1 audio, I always get complete packets of 576 bytes
>>>> from av_read_packet.
>>>>
>>>> Greetings,
>>>> --
>>>> Michel Bardiaux
>>>
>>> .. so it must have something to do with the initialization from
>>> av_open_input_file to avcodec_open.
>>> Maybe I missed something. My code is below.
>>>
>>>               //long test = CODEC_FLAG_TRUNCATED;
>>>               if(m_pAudioCodec->capabilities & CODEC_CAP_TRUNCATED)
>>>                       m_pAudioCodecCtx->flags|=CODEC_FLAG_TRUNCATED;
>>>
>> I dont see the usefulness of this unless you expect corrupted streams. I
>> dont use that flag.
>>
>> Greetings,
>> --
>> Michel Bardiaux
>
> Hi Michael,
>
> deleted the lines - no difference.
>
Time to fall back on reference code:

ffmpeg -dump -i <yourfilehere> -f mpegts - > /dev/null

On an MPEG1 file of mine, which is mono 32kbits, it gives size=96 all
the time (The 576 above is for a 192kbits stereo).

But looking in your complete source, I see you loop in each audio input
packet regardless of whether you have exhausted the payload. You must
also break when lBytesRemaining is less than the padding you appended.

On MPEG1 audio, the while loop should normally execute only once.

--
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:[hidden email]

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: avcodec_decode_audio2 doesn't decode small buffers

Thomas Rehaag
Hi Michel,

> Time to fall back on reference code:
>
> ffmpeg -dump -i <yourfilehere> -f mpegts - > /dev/null

I'm on windows, what's the replacement for /dev/null ?
When I give a file's path instead, it will receive the input movie.
The console output is attached at the bottom.


>
> On an MPEG1 file of mine, which is mono 32kbits, it gives size=96 all
> the time (The 576 above is for a 192kbits stereo).
>

Sorry, but I don't understand the following 2 sentences.
I suspect, it's my poor English!

> But looking in your complete source, I see you loop in each audio input
> packet regardless of whether you have exhausted the payload.
What do you mean by "exhausted the payload"?
avcodec_decode_audio2 get's the whole buffer piece by piece.

> You must
> also break when lBytesRemaining is less than the padding you appended.
What do you mean by "padding you appended"?
The FF_INPUT_BUFFER_PADDING_SIZE (8) zeros?


>
> On MPEG1 audio, the while loop should normally execute only once.
In my case not. I've created a mini stamp size mpeg1 file with ffmpeg:
ffmpeg  -r 30 -i in.mpg -y  -b 16k -s 64x48 lo1.mpg -t 2 -target vcd
it's here:
http://www.ismism.de/xc/lo1.mpg

av_read_packet delivers a buffer of 2037 bytes from this file,
avcodec_decode_audio2 reads 192 bytes in one step.

Best Regards and big Thanks for your efforts,

Thomas







C:\Arbeit\EventVideografie\test\use_ffmpg\TwoInOne\out>ffmpeg -dump -i
in.mpg -f
 mpegts -
1>C:\Arbeit\EventVideografie\test\use_ffmpg\TwoInOne\out\x.mpg
FFmpeg version SVN-r11162, Copyright (c) 2000-2007 Fabrice Bellard, et
al.
  configuration: --enable-shared --disable-static --enable-memalign-hack
  libavutil version: 49.5.0
  libavcodec version: 51.48.0
  libavformat version: 52.1.0
  built on Dec  6 2007 14:59:01, gcc: 4.2.2 (TDM-1)
Input #0, mpeg, from 'in.mpg':
  Duration: 00:00:50.6, start: 0.500000, bitrate: 1114 kb/s
    Stream #0.0[0x1e0]: Video: mpeg1video, yuv420p, 720x576 [PAR 178:163
DAR 445
:326], 104857 kb/s, 25.00 tb(r)
    Stream #0.1[0x1c0]: Audio: mp2, 48000 Hz, stereo, 64 kb/s
Output #0, mpegts, to 'pipe:':
    Stream #0.0: Video: mpeg2video, yuv420p, 720x576 [PAR 178:163 DAR
445:326],
q=2-31, 200 kb/s, 25.00 tb(c)
    Stream #0.1: Audio: mp2, 48000 Hz, stereo, 64 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1
Press [q] to stop encoding
frame= 1267 fps=132 q=31.0 Lsize=    3200kB time=50.0 bitrate=
524.1kbits/s
video:2207kB audio:391kB global headers:0kB muxing overhead 23.174690%
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: avcodec_decode_audio2 doesn't decode small buffers

Michel Bardiaux-2
Thomas Rehaag a écrit :
> Hi Michel,
>
>> Time to fall back on reference code:
>>
>> ffmpeg -dump -i <yourfilehere> -f mpegts - > /dev/null
>
> I'm on windows, what's the replacement for /dev/null ?

http://en.wikipedia.org/wiki/Data_sink

> When I give a file's path instead, it will receive the input movie.

Yes, and its irrelevant for what concerns us here.

> The console output is attached at the bottom.
>
>
>> On an MPEG1 file of mine, which is mono 32kbits, it gives size=96 all
>> the time (The 576 above is for a 192kbits stereo).
>>
>
> Sorry, but I don't understand the following 2 sentences.
> I suspect, it's my poor English!
>
>> But looking in your complete source, I see you loop in each audio input
>> packet regardless of whether you have exhausted the payload.
> What do you mean by "exhausted the payload"?
> avcodec_decode_audio2 get's the whole buffer piece by piece.
>
>> You must
>> also break when lBytesRemaining is less than the padding you appended.
> What do you mean by "padding you appended"?
> The FF_INPUT_BUFFER_PADDING_SIZE (8) zeros?
>
>
>> On MPEG1 audio, the while loop should normally execute only once.
> In my case not. I've created a mini stamp size mpeg1 file with ffmpeg:
> ffmpeg  -r 30 -i in.mpg -y  -b 16k -s 64x48 lo1.mpg -t 2 -target vcd
> it's here:
> http://www.ismism.de/xc/lo1.mpg
>
> av_read_packet delivers a buffer of 2037 bytes from this file,
> avcodec_decode_audio2 reads 192 bytes in one step.

That goes against everything I tjhought I knew about MPEG1 audio, so I
need your in.mpg too to be able to reproduce your whole experiment (or
at least the first 10 seconds of it).

>
> Best Regards and big Thanks for your efforts,
>
> Thomas
>
>
>
>
>
>
>
> C:\Arbeit\EventVideografie\test\use_ffmpg\TwoInOne\out>ffmpeg -dump -i
> in.mpg -f
>  mpegts -
> 1>C:\Arbeit\EventVideografie\test\use_ffmpg\TwoInOne\out\x.mpg
> FFmpeg version SVN-r11162, Copyright (c) 2000-2007 Fabrice Bellard, et
> al.
>   configuration: --enable-shared --disable-static --enable-memalign-hack
>   libavutil version: 49.5.0
>   libavcodec version: 51.48.0
>   libavformat version: 52.1.0
>   built on Dec  6 2007 14:59:01, gcc: 4.2.2 (TDM-1)
> Input #0, mpeg, from 'in.mpg':
>   Duration: 00:00:50.6, start: 0.500000, bitrate: 1114 kb/s
>     Stream #0.0[0x1e0]: Video: mpeg1video, yuv420p, 720x576 [PAR 178:163
> DAR 445
> :326], 104857 kb/s, 25.00 tb(r)
>     Stream #0.1[0x1c0]: Audio: mp2, 48000 Hz, stereo, 64 kb/s
> Output #0, mpegts, to 'pipe:':
>     Stream #0.0: Video: mpeg2video, yuv420p, 720x576 [PAR 178:163 DAR
> 445:326],
> q=2-31, 200 kb/s, 25.00 tb(c)
>     Stream #0.1: Audio: mp2, 48000 Hz, stereo, 64 kb/s
> Stream mapping:
>   Stream #0.0 -> #0.0
>   Stream #0.1 -> #0.1
> Press [q] to stop encoding
> frame= 1267 fps=132 q=31.0 Lsize=    3200kB time=50.0 bitrate=
> 524.1kbits/s
> video:2207kB audio:391kB global headers:0kB muxing overhead 23.174690%
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user


--
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:[hidden email]

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: avcodec_decode_audio2 doesn't decode small buffers

Thomas Rehaag
> >> On MPEG1 audio, the while loop should normally execute only once.
> > In my case not. I've created a mini stamp size mpeg1 file with ffmpeg:
> > ffmpeg  -r 30 -i in.mpg -y  -b 16k -s 64x48 lo1.mpg -t 2 -target vcd
> > it's here:
> > http://www.ismism.de/xc/lo1.mpg
> >
> > av_read_packet delivers a buffer of 2037 bytes from this file,
> > avcodec_decode_audio2 reads 192 bytes in one step.
>
> That goes against everything I tjhought I knew about MPEG1 audio, so I
> need your in.mpg too to be able to reproduce your whole experiment (or
> at least the first 10 seconds of it).
>

Hi,

my input file has been created by ffmpeg just like the lo1.mpg. No
difference but the params for size and bitrate. in.mpeg is a dvbs
recording in mpeg2.

But in my program, every mpeg1's audio stream behaves like that, so I
don't think it's the source material.
e.g.
http://download.pocketmovies.net/movies/trailers/thedarkknight_176x80.mpg
or
http://download.pocketmovies.net/movies/trailers/fantastic4silversurfer_320x136.mpg

The buffer sizes from av_read_packet and the number of bytes, decoded in
one step differ from file to file, but the principle is allways the
same.

Best Regards,

Thomas
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: avcodec_decode_audio2 doesn't decode small buffers

Michel Bardiaux-2
Thomas Rehaag a écrit :

>>>> On MPEG1 audio, the while loop should normally execute only once.
>>> In my case not. I've created a mini stamp size mpeg1 file with ffmpeg:
>>> ffmpeg  -r 30 -i in.mpg -y  -b 16k -s 64x48 lo1.mpg -t 2 -target vcd
>>> it's here:
>>> http://www.ismism.de/xc/lo1.mpg
>>>
>>> av_read_packet delivers a buffer of 2037 bytes from this file,
>>> avcodec_decode_audio2 reads 192 bytes in one step.
>> That goes against everything I tjhought I knew about MPEG1 audio, so I
>> need your in.mpg too to be able to reproduce your whole experiment (or
>> at least the first 10 seconds of it).
>>
>
> Hi,
>
> my input file has been created by ffmpeg just like the lo1.mpg. No
> difference but the params for size and bitrate. in.mpeg is a dvbs
> recording in mpeg2.

You misunderstand me. I meant I will simply not look further in the
problem until I have the means to re-create by myself the file on which
you run your code.

>
> But in my program, every mpeg1's audio stream behaves like that, so I
> don't think it's the source material.
> e.g.
> http://download.pocketmovies.net/movies/trailers/thedarkknight_176x80.mpg
> or
> http://download.pocketmovies.net/movies/trailers/fantastic4silversurfer_320x136.mpg
>
> The buffer sizes from av_read_packet and the number of bytes, decoded in
> one step differ from file to file, but the principle is allways the
> same.
>


--
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:[hidden email]

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: avcodec_decode_audio2 doesn't decode small buffers

Thomas Rehaag


Michel Bardiaux schrieb:

>
> Thomas Rehaag a écrit :
> >>>> On MPEG1 audio, the while loop should normally execute only once.
> >>> In my case not. I've created a mini stamp size mpeg1 file with ffmpeg:
> >>> ffmpeg  -r 30 -i in.mpg -y  -b 16k -s 64x48 lo1.mpg -t 2 -target vcd
> >>> it's here:
> >>> http://www.ismism.de/xc/lo1.mpg
> >>>
> >>> av_read_packet delivers a buffer of 2037 bytes from this file,
> >>> avcodec_decode_audio2 reads 192 bytes in one step.
> >> That goes against everything I tjhought I knew about MPEG1 audio, so I
> >> need your in.mpg too to be able to reproduce your whole experiment (or
> >> at least the first 10 seconds of it).
> >>
> >
> > Hi,
> >
> > my input file has been created by ffmpeg just like the lo1.mpg. No
> > difference but the params for size and bitrate. in.mpeg is a dvbs
> > recording in mpeg2.
>
> You misunderstand me. I meant I will simply not look further in the
> problem until I have the means to re-create by myself the file on which
> you run your code.
>
You mean, the mpeg1 file I've been using? It's here:
http://www.ismism.de/xc/in.mpg
It's just a shorter version.
I've also tried to create a short version of the original mpeg2 file,
but:
ffmpeg   -i csi2.mpg  -vcodec copy -acodec copy -t 4 tv_short.mpg
didn't work. Ffmpeg says, it can't open the file. Strange, because
there's no problem to create an mpeg1 file of it with:
-i csi2.mpg -y  in.mpg -t 4  -target vcd
- the one I've uploaded.

Cheers,

Thomas
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: avcodec_decode_audio2 doesn't decode small buffers

Michel Bardiaux-2
Thomas Rehaag a écrit :

>
> Michel Bardiaux schrieb:
>> Thomas Rehaag a écrit :
>>>>>> On MPEG1 audio, the while loop should normally execute only once.
>>>>> In my case not. I've created a mini stamp size mpeg1 file with ffmpeg:
>>>>> ffmpeg  -r 30 -i in.mpg -y  -b 16k -s 64x48 lo1.mpg -t 2 -target vcd
>>>>> it's here:
>>>>> http://www.ismism.de/xc/lo1.mpg
>>>>>
>>>>> av_read_packet delivers a buffer of 2037 bytes from this file,
>>>>> avcodec_decode_audio2 reads 192 bytes in one step.
>>>> That goes against everything I tjhought I knew about MPEG1 audio, so I
>>>> need your in.mpg too to be able to reproduce your whole experiment (or
>>>> at least the first 10 seconds of it).
>>>>
>>> Hi,
>>>
>>> my input file has been created by ffmpeg just like the lo1.mpg. No
>>> difference but the params for size and bitrate. in.mpeg is a dvbs
>>> recording in mpeg2.
>> You misunderstand me. I meant I will simply not look further in the
>> problem until I have the means to re-create by myself the file on which
>> you run your code.
>>
> You mean, the mpeg1 file I've been using? It's here:
> http://www.ismism.de/xc/in.mpg
> It's just a shorter version.
> I've also tried to create a short version of the original mpeg2 file,
> but:
> ffmpeg   -i csi2.mpg  -vcodec copy -acodec copy -t 4 tv_short.mpg
> didn't work. Ffmpeg says, it can't open the file.

Relapse into the newbie sins (1) of not posting the output messages (2)
of complaining that something "didnt work" :-)

> Strange, because
> there's no problem to create an mpeg1 file of it with:
> -i csi2.mpg -y  in.mpg -t 4  -target vcd
> - the one I've uploaded.

I really want either that MPEG2 file or a short version of it, because I
am pretty sure the MPEG1 audio is mangled, it should not behave like
this (or I am excessively tired...) So we really should first see why
that truncation didnt work. Or just put it in the same directory, with
ffmpeg -i http:// I can do a partial download.


--
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:[hidden email]

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: avcodec_decode_audio2 doesn't decode small buffers

Thomas Rehaag


Michel Bardiaux schrieb:

>
> Thomas Rehaag a écrit :
> >
> > Michel Bardiaux schrieb:
> >> Thomas Rehaag a écrit :
> >>>>>> On MPEG1 audio, the while loop should normally execute only once.
> >>>>> In my case not. I've created a mini stamp size mpeg1 file with ffmpeg:
> >>>>> ffmpeg  -r 30 -i in.mpg -y  -b 16k -s 64x48 lo1.mpg -t 2 -target vcd
> >>>>> it's here:
> >>>>> http://www.ismism.de/xc/lo1.mpg
> >>>>>
> >>>>> av_read_packet delivers a buffer of 2037 bytes from this file,
> >>>>> avcodec_decode_audio2 reads 192 bytes in one step.
> >>>> That goes against everything I tjhought I knew about MPEG1 audio, so I
> >>>> need your in.mpg too to be able to reproduce your whole experiment (or
> >>>> at least the first 10 seconds of it).
> >>>>
> >>> Hi,
> >>>
> >>> my input file has been created by ffmpeg just like the lo1.mpg. No
> >>> difference but the params for size and bitrate. in.mpeg is a dvbs
> >>> recording in mpeg2.
> >> You misunderstand me. I meant I will simply not look further in the
> >> problem until I have the means to re-create by myself the file on which
> >> you run your code.
> >>
> > You mean, the mpeg1 file I've been using? It's here:
> > http://www.ismism.de/xc/in.mpg
> > It's just a shorter version.
> > I've also tried to create a short version of the original mpeg2 file,
> > but:
> > ffmpeg   -i csi2.mpg  -vcodec copy -acodec copy -t 4 tv_short.mpg
> > didn't work. Ffmpeg says, it can't open the file.
>
> Relapse into the newbie sins (1) of not posting the output messages (2)
> of complaining that something "didnt work" :-)
>
> > Strange, because
> > there's no problem to create an mpeg1 file of it with:
> > -i csi2.mpg -y  in.mpg -t 4  -target vcd
> > - the one I've uploaded.
>
> I really want either that MPEG2 file or a short version of it, because I
> am pretty sure the MPEG1 audio is mangled, it should not behave like
> this (or I am excessively tired...) So we really should first see why
> that truncation didnt work. Or just put it in the same directory, with
> ffmpeg -i http:// I can do a partial download.
>

Partial download - good idea: I just did a partial upload ;)
http://www.ismism.de/xc/tvshort.mpg
But it can't have anything to do with the original mpeg2 file, cause
every mpeg1 file has big buffers from the view point of my program, that
can only be crunched in little portions by avcodec_decode_audio2.

Cheers,

Thomas
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: avcodec_decode_audio2 doesn't decode small buffers

Michel Bardiaux-2
Thomas Rehaag a écrit :
[snip]
>
> Partial download - good idea: I just did a partial upload ;)
> http://www.ismism.de/xc/tvshort.mpg
> But it can't have anything to do with the original mpeg2 file, cause
> every mpeg1 file has big buffers from the view point of my program, that
> can only be crunched in little portions by avcodec_decode_audio2.
>
Let's take things one step at a time. I have tvshort.mpg now. I have
made a slight hack to ffmpeg sources to dump packets on 1 line, its
easier to read and grep. On tvshort.mpg I get:

ffmpeg -dump -v 2 -i tvshort.mpg -y jul.mpg | & tee -a notes
FFmpeg version SVN-r11285, Copyright (c) 2000-2007 Fabrice Bellard, et al.
   configuration: --enable-gpl --enable-liba52 --enable-libgsm
--enable-libmp3lame
   libavutil version: 49.6.0
   libavcodec version: 51.49.0
   libavformat version: 52.3.0
   built on Dec 20 2007 15:22:57, gcc: 4.1.2 20061115 (prerelease)
(Debian 4.1.1-21)
Input #0, mpeg, from 'tvshort.mpg':
   Duration: 00:00:05.2, start: 0.180000, bitrate: 3030 kb/s
     Stream #0.0[0x1e0], 1/90000: Video: mpeg2video, yuv420p, 720x576
[PAR 16:15 DAR 4:3], 1/25, 15000 kb/s, 25.00 tb(r)
     Stream #0.1[0x1c0], 1/90000: Audio: mp2, 48000 Hz, stereo, 192 kb/s
Output #0, mpeg, to 'jul.mpg':
     Stream #0.0, 1/90000: Video: mpeg1video, yuv420p, 720x576 [PAR
16:15 DAR 4:3], 1/25, q=2-31, 200 kb/s, 25.00 tb(c)
     Stream #0.1, 1/90000: Audio: mp2, 48000 Hz, stereo, 64 kb/s
Stream mapping:
   Stream #0.0 -> #0.0
   Stream #0.1 -> #0.1
Press [q] to stop encoding
stream #0:   keyframe=1   duration=0.004   dts=0.016  pts=0.016  size=30676
stream #0:   keyframe=0   duration=0.004   dts=0.020  pts=0.020  size=4586
stream #0:   keyframe=0   duration=0.004   dts=0.016  pts=0.016  size=4578
stream #0:   keyframe=0   duration=0.004   dts=0.016  pts=0.027  size=12300
stream #0:   keyframe=0   duration=0.004   dts=0.020  pts=0.020  size=5690
stream #0:   keyframe=0   duration=0.004   dts=0.023  pts=0.023  size=5498
stream #0:   keyframe=0   duration=0.004   dts=0.027  pts=0.038  size=28660
stream #0:   keyframe=0   duration=0.004   dts=0.031  pts=0.031  size=6786
stream #0:   keyframe=0   duration=0.004   dts=0.034  pts=0.034  size=6426
stream #0:   keyframe=0   duration=0.004   dts=0.038  pts=0.049  size=23876
stream #0:   keyframe=0   duration=0.004   dts=0.041  pts=0.041  size=5866
stream #0:   keyframe=0   duration=0.004   dts=0.045  pts=0.045  size=5322
stream #1:   keyframe=1   duration=0.002   dts=0.032  pts=0.032  size=576
stream #0:   keyframe=1   duration=0.004   dts=0.049  pts=0.059  size=57332
stream #0:   keyframe=0   duration=0.004   dts=0.052  pts=0.052  size=6058
stream #0:   keyframe=0   duration=0.004   dts=0.056  pts=0.056  size=6050
stream #0:   keyframe=0   duration=0.004   dts=0.059  pts=0.070  size=19844
stream #0:   keyframe=0   duration=0.004   dts=0.063  pts=0.063  size=6050
stream #0:   keyframe=0   duration=0.004   dts=0.067  pts=0.067  size=5138
stream #0:   keyframe=0   duration=0.004   dts=0.070  pts=0.081  size=19284
stream #0:   keyframe=0   duration=0.004   dts=0.074  pts=0.074  size=5690
stream #1:   keyframe=1   duration=0.002   dts=0.035  pts=0.035  size=576
stream #1:   keyframe=1   duration=0.002   dts=0.039  pts=0.039  size=576
stream #1:   keyframe=1   duration=0.002   dts=0.041  pts=0.041  size=576
stream #0:   keyframe=0   duration=0.004   dts=0.077  pts=0.077  size=5314
stream #0:   keyframe=0   duration=0.004   dts=0.081  pts=0.092  size=14508
stream #1:   keyframe=1   duration=0.002   dts=0.043  pts=0.043  size=576
stream #1:   keyframe=1   duration=0.002   dts=0.050  pts=0.050  size=576
stream #1:   keyframe=1   duration=0.002   dts=0.052  pts=0.052  size=576
stream #1:   keyframe=1   duration=0.002   dts=0.054  pts=0.054  size=576
stream #0:   keyframe=0   duration=0.004   dts=0.085  pts=0.085  size=5138
stream #0:   keyframe=0   duration=0.004   dts=0.088  pts=0.088  size=5506
stream #1:   keyframe=1   duration=0.002   dts=0.056  pts=0.056  size=576
stream #1:   keyframe=1   duration=0.002   dts=0.058  pts=0.058  size=576
stream #1:   keyframe=1   duration=0.002   dts=0.060  pts=0.060  size=576
...

Obviously stream#1 is the audio, and *all* packets are 576 bytes long.
Now, just give me the ffmpeg command you used to create the file you
feed to your own code. (the past postings are a bit confused, I cant be
100% sure I would use the correct command).

Cheers,
--
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:[hidden email]

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: avcodec_decode_audio2 doesn't decode small buffers

Thomas Rehaag


Michel Bardiaux schrieb:

>
> Thomas Rehaag a écrit :
> [snip]
> >
> > Partial download - good idea: I just did a partial upload ;)
> > http://www.ismism.de/xc/tvshort.mpg
> > But it can't have anything to do with the original mpeg2 file, cause
> > every mpeg1 file has big buffers from the view point of my program, that
> > can only be crunched in little portions by avcodec_decode_audio2.
> >
> Let's take things one step at a time. I have tvshort.mpg now. I have
> made a slight hack to ffmpeg sources to dump packets on 1 line, its
> easier to read and grep. On tvshort.mpg I get:
>
> ffmpeg -dump -v 2 -i tvshort.mpg -y jul.mpg | & tee -a notes
> FFmpeg version SVN-r11285, Copyright (c) 2000-2007 Fabrice Bellard, et al.
>    configuration: --enable-gpl --enable-liba52 --enable-libgsm
> --enable-libmp3lame
>    libavutil version: 49.6.0
>    libavcodec version: 51.49.0
>    libavformat version: 52.3.0
>    built on Dec 20 2007 15:22:57, gcc: 4.1.2 20061115 (prerelease)
> (Debian 4.1.1-21)
> Input #0, mpeg, from 'tvshort.mpg':
>    Duration: 00:00:05.2, start: 0.180000, bitrate: 3030 kb/s
>      Stream #0.0[0x1e0], 1/90000: Video: mpeg2video, yuv420p, 720x576
> [PAR 16:15 DAR 4:3], 1/25, 15000 kb/s, 25.00 tb(r)
>      Stream #0.1[0x1c0], 1/90000: Audio: mp2, 48000 Hz, stereo, 192 kb/s
> Output #0, mpeg, to 'jul.mpg':
>      Stream #0.0, 1/90000: Video: mpeg1video, yuv420p, 720x576 [PAR
> 16:15 DAR 4:3], 1/25, q=2-31, 200 kb/s, 25.00 tb(c)
>      Stream #0.1, 1/90000: Audio: mp2, 48000 Hz, stereo, 64 kb/s
> Stream mapping:
>    Stream #0.0 -> #0.0
>    Stream #0.1 -> #0.1
> Press [q] to stop encoding
> stream #0:   keyframe=1   duration=0.004   dts=0.016  pts=0.016  size=30676
> stream #0:   keyframe=0   duration=0.004   dts=0.020  pts=0.020  size=4586
> stream #0:   keyframe=0   duration=0.004   dts=0.016  pts=0.016  size=4578
> stream #0:   keyframe=0   duration=0.004   dts=0.016  pts=0.027  size=12300
> stream #0:   keyframe=0   duration=0.004   dts=0.020  pts=0.020  size=5690
> stream #0:   keyframe=0   duration=0.004   dts=0.023  pts=0.023  size=5498
> stream #0:   keyframe=0   duration=0.004   dts=0.027  pts=0.038  size=28660
> stream #0:   keyframe=0   duration=0.004   dts=0.031  pts=0.031  size=6786
> stream #0:   keyframe=0   duration=0.004   dts=0.034  pts=0.034  size=6426
> stream #0:   keyframe=0   duration=0.004   dts=0.038  pts=0.049  size=23876
> stream #0:   keyframe=0   duration=0.004   dts=0.041  pts=0.041  size=5866
> stream #0:   keyframe=0   duration=0.004   dts=0.045  pts=0.045  size=5322
> stream #1:   keyframe=1   duration=0.002   dts=0.032  pts=0.032  size=576
> stream #0:   keyframe=1   duration=0.004   dts=0.049  pts=0.059  size=57332
> stream #0:   keyframe=0   duration=0.004   dts=0.052  pts=0.052  size=6058
> stream #0:   keyframe=0   duration=0.004   dts=0.056  pts=0.056  size=6050
> stream #0:   keyframe=0   duration=0.004   dts=0.059  pts=0.070  size=19844
> stream #0:   keyframe=0   duration=0.004   dts=0.063  pts=0.063  size=6050
> stream #0:   keyframe=0   duration=0.004   dts=0.067  pts=0.067  size=5138
> stream #0:   keyframe=0   duration=0.004   dts=0.070  pts=0.081  size=19284
> stream #0:   keyframe=0   duration=0.004   dts=0.074  pts=0.074  size=5690
> stream #1:   keyframe=1   duration=0.002   dts=0.035  pts=0.035  size=576
> stream #1:   keyframe=1   duration=0.002   dts=0.039  pts=0.039  size=576
> stream #1:   keyframe=1   duration=0.002   dts=0.041  pts=0.041  size=576
> stream #0:   keyframe=0   duration=0.004   dts=0.077  pts=0.077  size=5314
> stream #0:   keyframe=0   duration=0.004   dts=0.081  pts=0.092  size=14508
> stream #1:   keyframe=1   duration=0.002   dts=0.043  pts=0.043  size=576
> stream #1:   keyframe=1   duration=0.002   dts=0.050  pts=0.050  size=576
> stream #1:   keyframe=1   duration=0.002   dts=0.052  pts=0.052  size=576
> stream #1:   keyframe=1   duration=0.002   dts=0.054  pts=0.054  size=576
> stream #0:   keyframe=0   duration=0.004   dts=0.085  pts=0.085  size=5138
> stream #0:   keyframe=0   duration=0.004   dts=0.088  pts=0.088  size=5506
> stream #1:   keyframe=1   duration=0.002   dts=0.056  pts=0.056  size=576
> stream #1:   keyframe=1   duration=0.002   dts=0.058  pts=0.058  size=576
> stream #1:   keyframe=1   duration=0.002   dts=0.060  pts=0.060  size=576
> ...
>
> Obviously stream#1 is the audio, and *all* packets are 576 bytes long.
> Now, just give me the ffmpeg command you used to create the file you
> feed to your own code. (the past postings are a bit confused, I cant be
> 100% sure I would use the correct command).
>
> Cheers,
> --
> Michel Bardiaux

Hi,

I used this line:
ffmpeg   -i csi1.mpg -y  in.mpg -t 20  -target vcd
csi1.mpg is the long original.

Best Regards,

Thomas
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: avcodec_decode_audio2 doesn't decode small buffers

Thomas Rehaag
In reply to this post by Michel Bardiaux-2
Hi Michel,

I took your line
> ffmpeg -dump -v 2 -i tvshort.mpg -y jul.mpg | & tee -a notes
and modified it for my in.mpeg:

ffmpeg -dump -v 2 -i in.mpg -y jul.mpg

And this delivers a clear audio buffer size of 192 bytes.
Then I've tried my code, and avcodec_decode_audio2 decodes 192 bytes at
once, but av_read_packet e.g. reads 2037 bytes the first time it's
called.
And the ffmpeg dump shows the decoding of about 11 audio frames of 192
bytes, before the next video frame appears. About the same size, isn't
it?

Can I have done something wrong, compiling ffmpeg, so that
av_read_packet does something wrong? (Hope I've got you right, that it
should deliver handy little packages of 192 bytes in case of in.mpg)

Cheers,

Thomas

ps.: still kind of holiday to work with ffmpeg and it's libs - after a
long, frustrating day, trying to convince 4 windows media player
controls, to play 4 *.asf files from an offset of some seconds ;)
I still can't believe what I saw: the two players, started first, played
from 0, the others did their job well!
reproducable!!
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: avcodec_decode_audio2 doesn't decode small buffers

Michel Bardiaux-2
Thomas Rehaag a écrit :

> Hi Michel,
>
> I took your line
>> ffmpeg -dump -v 2 -i tvshort.mpg -y jul.mpg | & tee -a notes
> and modified it for my in.mpeg:
>
> ffmpeg -dump -v 2 -i in.mpg -y jul.mpg
>
> And this delivers a clear audio buffer size of 192 bytes.
> Then I've tried my code, and avcodec_decode_audio2 decodes 192 bytes at
> once, but av_read_packet e.g. reads 2037 bytes the first time it's
> called.
> And the ffmpeg dump shows the decoding of about 11 audio frames of 192
> bytes, before the next video frame appears. About the same size, isn't
> it?

So, to summarize: the problem is neither in the input file, nor in
ffmpeg&libs, it must be in your code. Can you send me a zip of your code
plus a Makefile, so I can try it? (As much as I can, my C++ is very --)

>
> Can I have done something wrong, compiling ffmpeg, so that
> av_read_packet does something wrong?

Doesnt seem likely, but you never know, do a distclean.

> (Hope I've got you right, that it
> should deliver handy little packages of 192 bytes in case of in.mpg)

For 48000Hz stereo at 64 kbps, yes, 192. You can calculate the size
easily knowing that 1 MPEG audio packet corresponds to 1152 (times
#channels) samples.

>
> Cheers,
>
> Thomas
>
> ps.: still kind of holiday to work with ffmpeg and it's libs - after a
> long, frustrating day, trying to convince 4 windows media player
> controls, to play 4 *.asf files from an offset of some seconds ;)
> I still can't believe what I saw: the two players, started first, played
> from 0, the others did their job well!
> reproducable!!
Then you're actually lucky!


--
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:[hidden email]

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: avcodec_decode_audio2 doesn't decode small buffers

Thomas Rehaag
Hi Michel,

> So, to summarize: the problem is neither in the input file, nor in
> ffmpeg&libs, it must be in your code. Can you send me a zip of your code
> plus a Makefile, so I can try it? (As much as I can, my C++ is very --)

The code is here:
http://www.ismism.de/xc/twoinone.zip
don't remember, if I mentioned before - the program stitches together
two input videos. E.g.: two times 640*480 -> 1280*480.
I don't think, you'll have to know much about c++ to read the code. Else
I'll have to write an example code using C only.
And also I hope, Visual C++ exported a correct makefile.

And - the audio problem is my minor problem:

- The program can't decode wmv files at all. I set the output's
framerate hardcoded to 30 (not in the uploaded code), cause the output
codec will not be created at 1000 frames/s. Then the first packet of
3877 bytes seems to be decoded well. The second time, av_read_packet
delivers 32397 bytes and avcodec_decode_video returns -1.

- Decoding and encoding MPEG1 files seems to work quite well at the
first sight. My TV testfiles, including sound,

work fine in between.
But the files, my main program encoded with the help of mencoder:
mencoder.exe a.wmv -o a.mpg -of mpeg -mpegopts
format=mpeg1:tsaf:muxrate=2000 -oac lavc -ovc lavc -lavcopts
acodec=mp2:abitrate=224:vcodec=mpeg1video:vbitrate=2304:keyint=15:mbd=2
-vf scale=500:375
are running too fast. I have to set a hard coded frame rate of about 22,
to get the original speed and video length.
I've also uploaded the wmv and mpg input files:
http://www.ismism.de/xc/a.wmv
http://www.ismism.de/xc/a.mpg

Thanks & have a nice 2008,

Thomas
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
12