View Full Version : Frame and subtitle does not sync


blaanima
20th February 2014, 12:28
Dear all

I am ripping video from my DVD into MKV and the size is 300MB, then I want a smaller size for my tablet due to limited space, and I re-encode the 300MB file into smaller size. I use below syntax

ffmpeg -i "input.mkv" -level 5.1 -preset veryslow -tune animation -keyint_min 12 -sc_threshold 45 -bf 8 -b_strategy 2 -refs 10 -qmin 10 -qmax 51 -qcomp 0.6 -direct-pred auto -me_range 24 -me_method umh -subq 10 -trellis 2 -an -sn -vcodec libx264 -crf 28.0 output1.mkv

ffmpeg -i "input.mkv" -f wav -| neroAacEnc -ignorelength -lc -q 0.4 -if - -of output2.aac

mkvmerge -o outputFF.mkv --language "0:jpn" --track-name "0:CRF 28.0" output1.mkv --no-chapters --language "0:jpn" --track-name "0:2.0 AAC-LC @ 0.4" output2.aac -A -D --language "2:eng" --track-name "2:Styled Subtitle (.ass)" "input.mkv"


1. First I encode the video only by forcing ffmpeg to disable subtitle and audio encoding
2. Then I encode the audio separately into AAC
3. Later I mix the two source into one, the video + audio + subtitle using mkvmerge

The problem here is that the subtitle appear 0.4 second late from the audio. I try to play using all player and it happens all the same. The ffmpeg libx264 is configured using 10 bit

Anybody knows why this happen?

Correct should be : http://i61.tinypic.com/16lwfwj.jpg
Mine is like this : http://i60.tinypic.com/29lkd1u.jpg

bigotti5
20th February 2014, 13:54
What program do you use to demux subtitles from DVD?

blaanima
20th February 2014, 14:01
What program do you use to demux subtitles from DVD?

i try several methods on several dvd i have, not sure which one resulting in the 300MB file

however, the output 300MKV MKV video file is fine, play smoothly and correctly (subtitle sync with audio well), the problem happens only after I re-encode the 300MKV using ffmpeg into smaller size for tablet (resulting in around 100MB), then the subtitle begin to appear 0.4 second late

bigotti5
20th February 2014, 14:18
Pgcdemux creates sup files ... you mux an ass file.
Your way from sup to ass?

blaanima
20th February 2014, 14:37
Pgcdemux creates sup files ... you mux an ass file.
Your way from sup to ass?

hi i tried several methods on several dvd,
i use this method to convert vob to mkv first resulting in 300MB MKV file

./ffmpeg -i mymovie.vob -c:v copy -c:a copy -c:s copy -map 0 mymovie.mkv

then there is no problem playing 300MB file and the subtitle is correct and does not appearing late, the problem happens when I try to re encode 300MB file into 100MB file by using the syntax in the thread, that causes late of 0.4 second subtitle

bigotti5
20th February 2014, 14:51
Reencode the video has nothing to do with sub delay (if not altering framerate or similar).
Delay is probably caused by the muxer or changing timecodes in your subtitle editing chain.

foxyshadis
22nd February 2014, 02:57
Run mediainfo will full output on both the input and output, that might give you a clue as to any discrepancies.

blaanima
24th February 2014, 15:26
I have open both files mediainfo and find the differences as below.


1. Original is 8 bit, mine is 10 bit
2. Audio differences, original does not have delay relative to video, mine has delay relative 67ms

Original : ref 5
Mine : ref 16

Original : deblock 1:0:0
Mine : deblock 1:1:1

Original : subme 8
Mine : subme 10

Original : psy_rd 1.00:0.00
Mine : psy_rd 0.40:0.00

Original : me_range 16
Mine : me_range 24

Original : trellis 1
Mine : trellis 2

Original : bframes 3
Mine : bframes 8

Original : --min-keyint 12
Mine : --min-keyint 25

Original : scenecut 40
Mine : scenecut 45

Original : rc_lookahead 50
Mine : rc_lookahead 60

Original : qpmax 69
Mine : qpmax 51

Original : aq 1:1.00
Mine : aq 1:0.60


Can anyone tell me which parameter can cause the delay subtitle issue, I want to retain the encoding parameters as much as possible.

Thanks