FFmpegSource - frame accurate, multiformat/container loading

This forum is for questions and discussion of all the aspects of handling and cleaning up your footage with Avisynth.
Locked
User avatar
Qyot27
Surreptitious fluffy bunny
Joined: Fri Aug 30, 2002 12:08 pm
Status: Creepin' between the bullfrogs
Location: St. Pete, FL
Contact:
Org Profile

FFmpegSource - frame accurate, multiformat/container loading

Post by Qyot27 » Sat Oct 06, 2007 3:31 pm

I've mentioned this before in other threads, but Myrsloik over on the doom9 forums has created an input filter for AviSynth 2.5 based on FFmpeg, allowing frame accurate decoding/seeking of many different formats and containers, such as MKV, MP4, etc - pretty much anything ffmpeg (of which libavcodec is a part) can handle, although Haali's splitter is used for MKV.

The doom9 thread (includes a link to download the newest version):
http://forum.doom9.org/showthread.php?t=127037

It does this in much the same manner as DGIndex does with MPEG-1 or MPEG-2, by writing an index file. However, it doesn't require you to specifically load the index file, it just calls the index file when you run the script (the index is created the very first time the script is played, which slows down opening for just that first time). The one integral thing it lacks is the ability to convert framerate to maintain audio sync when dealing with variable framerates. The decoding of H.264 streams also still retains the dummy frames at the end of the file that sometimes appear, except that, unlike DirectShowSource, the ones now are black instead of gray, so it's probably not noticeable unless the video abruptly ends with anything except a fade to black. I'm not sure if this is also the case for other types of compression.

Basically, what this means is that DirectShowSource is no longer required for loading things not covered by AVISource or MPEG2Source, unless you want to maintain audio sync in VFR files. FFmpegSource does have an option to write timecodes, though, so that could feasibly be used to correct framerate in a more roundabout way. Maybe by way of a separate plugin that can read said timecodes and do the conversion if needed - I don't have any programming skills or else I'd try my hand at it.

The basic syntax is like this:
FFmpegSource("video.mkv", atrack=-1)

By default, the plugin only loads the video; atrack=-1 will have it load the audio as well. Audio is handled by decoding the stream to PCM (or FLAC, if you use that parameter) at the same time as the index is written, and stored in a separate .ffa1cache file. There are other parameters detailed in the plugin's documentation.

Locked

Return to “AviSynth Help”