New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subtitles don't appear on first frame when encoding with --vf=sub #5194

Closed
TheAMM opened this Issue Dec 7, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@TheAMM
Contributor

TheAMM commented Dec 7, 2017

mpv version and platform

Windows

mpv 0.27.0 (C) 2000-2017 mpv/MPlayer/mplayer2 projects
 built on Wed Sep 13 04:18:08 CEST 2017
ffmpeg library versions:
   libavutil       55.74.100
   libavcodec      57.105.100
   libavformat     57.82.100
   libswscale      4.7.103
   libavfilter     6.105.100
   libswresample   2.8.100
ffmpeg version: N-87286-g6ce4a635ed

Linux

mpv 0.27.0-484-ge92d1b7 (C) 2000-2017 mpv/MPlayer/mplayer2 projects
 built on Mon Dec  4 03:00:59 EET 2017
ffmpeg library versions:
   libavutil       56.3.100
   libavcodec      58.6.102
   libavformat     58.2.103
   libswscale      5.0.101
   libavfilter     7.5.100
   libswresample   3.0.101
ffmpeg version: N-89366-g65b5fcf

Reproduction steps

Encode a video containing softsubs while using --vf=sub to force the subtitles on the filter chain.

Below are four different commands for encoding test_video.mkv, a video with embedded ASS softsubs.

# A simple encode without specifying the sub-filter
# The first frame of the subtitles shows up.
mpv "test_video.mkv" --end=3 --log-file=out_no_sub.log --o out_no_sub.mp4

# A simple encode, prepending the sub-filter
# The first frame of the subtitles is missing - the subtitles only appear on the second frame and afterwards.
mpv "test_video.mkv" --end=3 --log-file=out_with_sub.log --o out_with_sub.mp4 --vf-pre=sub

# The following encodes demonstrate the use-case for applying the sub-filter:

# An encode with a crop applied, without specifying the sub-filter
# The first frame of the subtitles shows up, however the ASS subtitles are adjusted to the cropped frame, breaking them.
mpv "test_video.mkv" --end=3 --log-file=out_crop_no_sub.log --o out_crop_no_sub.mp4 --vf-add=crop=300:300:250:180

# An encode with a crop applied, the sub-filter being prepended before the crop
# The subtitles are where expected, but the first frame does not show up.
mpv "test_video.mkv" --end=3 --log-file=out_crop_with_sub.log --o out_crop_with_sub.mp4 --vf-add=crop=300:300:250:180 --vf-pre=sub

Expected behavior

The subtitles should appear on the first frame of the encode output when using the sub-filter.

out_with_sub_correct_00_00_00-01
out_crop_with_sub_correct_00_00_00-01

Actual behavior

The subtitles do not appear on the first frame of the encode output when using the sub-filter.

out_with_sub_00_00_00-01
out_crop_with_sub_00_00_00-01

Log file

Here are all the logfiles from the above commands

Sample files

Sample video test_video.mkv, created with:

ffmpeg -f lavfi -i testsrc=duration=6:size=1280x720:rate=30:decimals=2 -i subs.ass -attach arialbd.ttf -metadata:s:2 "mimetype=application/x-truetype-font" -c:v libx264 -crf 20 -y test_video.mkv

Example encode outputs:
out_no_sub.mp4
out_with_sub.mp4
out_crop_no_sub.mp4
out_crop_with_sub.mp4

@sfan5 sfan5 added the bug label Dec 8, 2017

@sfan5

This comment has been minimized.

Member

sfan5 commented Dec 8, 2017

vf_sub is apparently deprecated without replacement.
Not sure how you would get the desired cropping without using the sub filter (maybe @wm4 knows?)

@wm4

This comment has been minimized.

Contributor

wm4 commented Dec 8, 2017

Not at all.

@TheAMM

This comment has been minimized.

Contributor

TheAMM commented Dec 8, 2017

@sfan5 There is a wonky alternative using lavfi=subtitles, but it's much slower in fetching embedded subtitles from a video (noticed on a network mount), and it's a horrible pain/nigh impossible to replicate and apply all the user's subtitle customization - what-you-see-is-what-you-get won't happen, not to mention subtitles doesn't do image subs(?). Hopefully it won't be killed too soon - if there's something I can help with, I shall.

@wm4 Cheers on the hack, tested it out just now. 👍

@jeeb jeeb closed this in 0a749a3 Dec 8, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment