Reputation: 353
I encounter problems encoding video that I ripped from DVD, after ripping the video size is around 300MB and it plays well and subtitle sync well, then I want a smaller size for tablet and encode it using ffmpeg and the result is around 100MB but the subtitle will always late for 1 frame
# ffmpeg -i "Original.mkv" -level 5.1 -preset veryslow -tune animation -keyint_min 12 -sc_threshold 45 -bf 8 -b_strategy 2 -refs 16 -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 "Original.mkv" -f wav -| neroAacEnc -ignorelength -lc -q 0.4 -if - -of output2.aac
# mkvmerge -o outputFF.mkv --language "0:jpn" --track-name "0:SmallAnime Encode @ 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)" "Original.mkv"
In aegis sub, the video looks well which the subtitle appear normally, however when played using MPC, the subtitle always late 1 frame
Aegis show correctly screenshot : http://puu.sh/6N2gy
Play using MPC problems : http://puu.sh/6N38E.jpg
Anyone know why this happens? The ffmpeg uses libx264 video codec and it is configured using bit depth=10. The OS I am using is CentOS 6.4
Upvotes: 2
Views: 3009
Reputation: 1051
It's likely a rounding error - it's something that I've encountered too. Aegisub saves subtitles with timecodes (not frame numbers), and it's possible that Aegisub's timecode does not match what FFMPEG considers to be the correct timecode, resulting in the off-by-one frames.
I've experimented with the -itsoffset
flag, which allows you to adjust the input file's time offset. With a 23.98 fps input, I was able to find that a delay of 0.045 (using 1/23.98 == 0.0417014178, and some testing) would work with correcting my early subtitles. As a result, I added -itsoffset -0.045
right before my -i input_file
to re-sync the subtitles.
For your case, assuming that you have a similar frame rate, you can try ffmpeg -itsoffset 0.045 -i "Original.mkv" ...
and see if that prevents your subtitle delay. Note that -itsoffset 0.045
MUST come before the -i FILE
argument since itsoffset DELAY
argument modifies inputs after it.
More documentation about -itsoffset
can be found here.
Alternatively, you can use the Shift Times tool in Aegisub (Timing > Shift Times) and specify a time of 0:00:01.05
to try and correct the timing there... though I just stuck with the -itsoffset
flag since it's much easier to experiment on IMO.
Upvotes: 1