PDA

View Full Version : FLV Transcoding


JonE
23rd April 2009, 09:58
Hi,

I'm having trouble transcoding FLV files using DirectShow.

If I build a graph with FLVSplitter (part of k-lite codec pack), decode audio and video with FFDShow and just play it, everything works fine i.e. in synch

However, re-mux the decoded audio/video streams, encoding only the video (tried DV, XVid and a few others) and write to an AVI file and it is clear that the video frame rate is completely garbage ... it seems < half speed. Initially I thought the video was half speed but its worse than that.

Switching on the OSD feature in FFDShow to show the sample times reveals odd behaviour; the sample times from the FLVSplitter are e.g.

0-1, 33000-33001, 66000-66001 etc whereas I would expect
0-33000, 33000-66000, 66000-... etc

Either way, this is clearly ~30fps, yet the output from FFDShow shows a 40mS period i.e. 25fps. In addition, examination of the resulting video in VirtualDub reveals each frame is being duplicated.

Also, the DirectShow graph hangs during transcoding if you stop the graph, or if it gets to the end of the transcoding process (this is all currently being done in Monogram GraphStudio at the moment). I don't know exactly where it is hanging, but a readable AVI is generated (with frame rate wrong of course).

So, whats going on and, more to the point, how do I fix it ? Where does FFDShow get its 40mS frame period from ?

TTFN,
Jon

PS : In case it is in any way relevent, the test source FLV is from YouTube.

PPS : I know there are good utils out there that will transcode FLVs, indeed ffmpeg can also transcode these files, but I'm specifically trying to do this using DirectShow.

JonE
30th June 2009, 09:30
OK, I've struggled with this for a few months on and off and still no where near solving it.

What is happening is the 30fps video is having every frame duplicated and the result is subsequentlty assumed to be 25fps, so during playback the video takes 2-and-a-bit times longer to play than the audio !

The doubling made me think it may have at least some connection with mis-reading the video as interlaced although it definately isn't.

So, where is the bug, is it in the FLVSplitter or Ffdshow ? And why only when I built an transcoding graph and not a playback graph ?

TTFN,
Jon

sneaker_ger
30th June 2009, 13:53
The problem with those .FLV-files is that they often have a variable framerate. DirectShow can cope with that just fine but AviSynth only works with a constant framerate.

You either have to do a VFR->CFR conversion (for example using "DirectShowSource("yourfile",fps=30,convertfps=true)") or use a container like Matroska, extract the timescodes from the FLV-file using FLVExtractor and include them when muxing again.

JonE
1st July 2009, 13:36
'Fraid DirectShow _cant_ cope fine :-( I'm not using AviSynth for this, I'm actually programatically building a DirectShow graph to transcode the files using .NET (a proper C++ version failed in exactly the same way).

TTFN,
Jon

sneaker_ger
1st July 2009, 15:23
Sorry, I meant the real time playing when using DirectShow. Just tested encoding and it didn't work for me either. You probably have to drop the idea of solely using DirectShow for this.

roozhou
3rd July 2009, 05:39
Try mencoder. It supports vfr avi output