[FFmpeg-devel] [RFC] Eliminate -re and make -rate_emu set by AVOption

Stefano Sabatini stefano.sabatini-lala
Mon Jul 14 10:32:01 CEST 2008


Hi all,

currently ffmpeg -re -i ... doesn't work with only audio files, which
makes for example tricky to stream with RTP audio streams.

This is because rate_emu is currently set in opt_input() only for
video streams, and is ignored if there is only an audio stream to
transcode (for example if you're using -vn).

My solution is to make -rate_emu settable through AVOption options
using rate_emu, then remove the -re option.

This alone doesn't fix the problems for audio-only multimedia streams
streaming, there are still timestamp issues to be addressed.

I'm not sure this is the best solution, so I'm posting it here to
foster ideas and suggestions.

To test the patch:
stefano at geppetto ~/s/ffmpeg> 
ffmpeg -rate_emu 1 -i ~/test2.flv -vn -f avi -y /dev/null
FFmpeg version SVN-r14225, Copyright (c) 2000-2008 Fabrice Bellard, et al.
  configuration: --prefix=/home/stefano --disable-shared --enable-libschroedinger --enable-libx264 --enable-pthreads --enable-gpl --enable-debug=3 --enable-libtheora --enable-libvorbis --enable-avfilter --enable-libamr-nb --enable-libamr-wb --enable-nonfree --enable-libfaad --enable-libfaac --enable-x11grab --enable-libmp3lame --disable-optimizations --disable-mmx
  libavutil version: 49.7.0
  libavcodec version: 51.60.0
  libavformat version: 52.17.0
  libavdevice version: 52.0.0
  libavfilter version: 0.0.0
  built on Jul 14 2008 00:56:52, gcc: 4.2.3 20071014 (prerelease) (Debian 4.2.2-3)

Seems stream 0 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 25.00 (25/1)
Input #0, flv, from '/home/stefano/test2.flv':
  Duration: 00:00:30.01, start: 0.000000, bitrate: 96 kb/s
    Stream #0.0: Video: vp6f, yuv420p, 320x240, 25.00 tb(r)
    Stream #0.1: Audio: mp3, 44100 Hz, mono, 96 kb/s
Output #0, avi, to '/dev/null':
    Stream #0.0: Audio: mp2, 44100 Hz, mono, 64 kb/s
Stream mapping:
  Stream #0.1 -> #0.0
Press [q] to stop encoding
size=       0kB time=29.68 bitrate=   0.0kbits/s    
video:0kB audio:232kB global headers:0kB muxing overhead -99.999579%

Note that (at least in my case) I don't get frame rate emulation since
the codec time base for the audio is set to {0,0}, nonetheless now
ffmpeg will execute this part of code within output_packet():

        /* frame rate emulation */
        if (ist->st->codec->rate_emu) {
            int64_t pts = av_rescale((int64_t) ist->frame * ist->st->codec->time_base.num, 1000000, ist->st->codec->time_base.den);
            int64_t now = av_gettime() - ist->start;
            if (pts > now)
                usleep(pts - now);

            ist->frame++;
        }

Regards.
-- 
FFmpeg = Forgiving & Funny MultiPurpose Extended Genius
-------------- next part --------------
A non-text attachment was scrubbed...
Name: make-rate-emu-settable-00.patch
Type: text/x-diff
Size: 1005 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080714/dda39147/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: eliminate-ffmpeg-re-00.patch
Type: text/x-diff
Size: 1400 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080714/dda39147/attachment-0001.patch>



More information about the ffmpeg-devel mailing list