[FFmpeg-user] Encoding FLV: video plays back slow relative to audio, etc.
lou at lrcd.com
Thu Jul 7 01:02:21 CEST 2011
On Wed, 6 Jul 2011 10:23:02 +0100
Christian Ebert <blacktrash at gmx.net> wrote:
> * Lou on Monday, July 04, 2011 at 14:02:16 -0800
> > On Sun, 3 Jul 2011 13:29:10 -0400
> > Dave Kleinschmidt <dave.f.kleinschmidt at gmail.com> wrote:
> >> Hi all, I'm having a bit of trouble with encoding .avi files
> >> as .flv for flowplayer. I know this is a bit of a black art, and
> >> I've done quite a bit of looking around, but haven't seen much of
> >> anything. The symptoms: the audio plays back fine, but the video
> >> plays back at a slightly slower rate. In addition, the onFinish()
> >> events fires really late, a second or two after the video has
> >> finished.
> >> I suspect that this is a problem with how I encoded my .flv file,
> >> since the Flowplayer sample .flv plays fine, with no lag, and the
> >> onFinish() event fires essentially immediately after the last
> >> frame.
> >> Any suggestions would be very much appreciated. Unfortunately, I
> >> don't have a test site to link to, but here is a link to the
> >> original .avi file: http://db.tt/fpLLGSP
> >> and here is the .flv: http://db.tt/CnjPIrI
> I tried your sample and for me it's too short to detect any
> anomalies. The shortness might also be responsible for the
> perceived delay of the onFinish event.
> >> Here is the ffmpeg call and its output for the actual conversion:
> >> dkleinschmidt$ ffmpeg -y -i videos/VbA1.avi -ab 128000 -vcodec flv
> >> -r 25 videos/VbA1.flv
> I ran the same command with the same result on the avi. The only
> thing which looks slightly suspicious is the audio being 1 frame
> (0.04 secs) longer than the video. But I get this for all my flv
> files, the difference does not increase progressively with the
> size of the video.
> Of course I might just be too blind and deaf to notice the
> difference ;-)
> > Is there a reason why you're changing the frame rate? Secondly, the
> > encoder called "flv" in FFmpeg is very poor compared to x264, and
> > since H.264 can work in the flv container just fine, and you
> > already have it enabled apparently, I don't see any reason not to
> > use x264 instead:
> Dave might want to cater for old Flash versions < 9.0.115. Also
> x264 takes more decoding cpu than flv.
Using that logic you could also promote RealMedia formats, and Cinepak
works wonders for desktop playback.
> > ffmpeg -i input -vcodec libx264 -preset medium -crf 26 -threads 0 \
> > -acodec libmp3lame -aq 5 output.flv
> > You may then have to run this output through flvtool++, flvtool2,
> > flvmeta, or any other similar tool. I'm not sure if this step is
> > necessary for flowplayer these days, but it's something to keep in
> > mind if it has trouble with the output from FFmpeg (such as
> > incorrectly displaying the duration for example).
> Injecting metadata should only be needed for pseudostreaming flv.
This is not true according to my experiences. IIRC, I've encountered
several flash players that would not correctly display the duration,
elapsed time, or progress bar without passing the output through one of
those tools, but this was some time ago.
> I also compared Dave's result after injection, and it doesn't
> make any difference.
More information about the ffmpeg-user