Subtitles with Ffmpeg

For help and support with Universal Media Server
Forum rules
Please make sure you follow the Problem Reporting Guidelines before posting if you want a reply
Post Reply
NaughtyPrawn
Posts: 2
Joined: Wed Oct 24, 2012 9:37 pm

Subtitles with Ffmpeg

Post 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!
User avatar
SharkHunter
Developer
Posts: 648
Joined: Fri Jun 01, 2012 9:36 pm

Re: Subtitles with Ffmpeg

Post 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.
We reject: kings, presidents and voting.
We believe in: rough consensus and running code.
NaughtyPrawn
Posts: 2
Joined: Wed Oct 24, 2012 9:37 pm

Re: Subtitles with Ffmpeg

Post 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:
User avatar
SharkHunter
Developer
Posts: 648
Joined: Fri Jun 01, 2012 9:36 pm

Re: Subtitles with Ffmpeg

Post 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.
We reject: kings, presidents and voting.
We believe in: rough consensus and running code.
ExSport
Posts: 595
Joined: Wed Oct 10, 2012 1:57 am

Re: Subtitles with Ffmpeg

Post 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.
User avatar
SubJunk
Lead Developer
Posts: 3797
Joined: Sun May 27, 2012 4:12 pm

Re: Subtitles with Ffmpeg

Post 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.
Post Reply