Page 1 of 1

Subtitles with Ffmpeg

Posted: Wed Oct 24, 2012 9:55 pm
by NaughtyPrawn
For absolutely ages I have been having trouble with certain mkv files not syncing the video and audio and it seems this problem has been solved if I use ffmpeg.

Does anyone know how to get subs working with ffmpeg? I get an error if I try to run avisynth/ffmpeg as I though that may work.
Any help would be appreciated!

Re: Subtitles with Ffmpeg

Posted: Wed Oct 24, 2012 10:37 pm
by SharkHunter
NaughtyPrawn wrote:For absolutely ages I have been having trouble with certain mkv files not syncing the video and audio and it seems this problem has been solved if I use ffmpeg.

Does anyone know how to get subs working with ffmpeg? I get an error if I try to run avisynth/ffmpeg as I though that may work.
Any help would be appreciated!
That depends on. You could simply do

Code: Select all

ffmpeg -i file.xyz -i subs.??? out.abc
but if ??? is srt and abc is an mpeg2 format this doesn't work.
This is simply not supported in ffmpeg. If your render supports srt the above should work otherwise you could use mencoder or use some pipeing and use spumux. I have on the to do list (probably at the bottom) to get ffmpeg to support srts when transcoding to mpeg2.

Re: Subtitles with Ffmpeg

Posted: Thu Oct 25, 2012 4:39 am
by NaughtyPrawn
Yeah doesn't seem like it will work. Is there any way to get mencoder to keep the audio and video in sync like ffmpeg does? Sorry I'm pretty new to all this :roll:

Re: Subtitles with Ffmpeg

Posted: Thu Oct 25, 2012 4:46 am
by SharkHunter
Like always synch is all in the eye of the beholder. But you could try the "-mc" option and play with the values start on 0.1
From the man page

Code: Select all

mc <seconds/frame>
maximum A-V sync correction per frame (in seconds)
-mc 0 should always be combined with -noskip for mencoder, otherwise it will almost certainly cause A-V desync.

Re: Subtitles with Ffmpeg

Posted: Thu Oct 25, 2012 4:50 am
by ExSport
Never tested it but you can use MEncoder in a way as FFMPEG works, with special o= parameter so default MEncoder settings can be overridden by FFMPEG params?
http://bugzilla.mplayerhq.hu/show_bug.cgi?id=2046
Don't know if the hint in link can help but it is worth trying it. Maybe electing some ffmpeg params bundled in MEncoder will gave same result when ffmpeg alone is used? Who knows... 8-)
EDIT:
In past I used a custom PMS build which replaced -mc 0 -noskip with -mc 0.005 to fix A/V sync problems.
-mc 0 -noskip will disable built-in a/v sync algoritm totally and also will ignore audio delay set.
-mc 0.1 is sometimes too much so I used 0.005 which worked best for me.
Now MEncoder is not so buggy as in past so removing -mc 0 -noskip is in most cases enough to make a/v sync OK.

Re: Subtitles with Ffmpeg

Posted: Thu Oct 25, 2012 7:47 am
by SubJunk
Yeah I share your frustration and we (and the FFmpeg and MEncoder developers) are constantly improving audio/video sync.
UMS knows how to implement the suggestion the others made, just go to the Transcoding Settings tab, then the MEncoder page, then untick "A/V sync alternative method" and Save.
That will make MEncoder use different methods to synchronise and it may work better for you.
One thing we have noticed is that the number of CPU threads affect the sync when using that setting, so you should set your CPU threads (on the Common Transcode Settings page) to the lowest value you can. 2 seems stable, and above 4 is where the sync problems get pronounced.