master-of-zen / Av1an

Cross-platform command-line AV1 / VP9 / HEVC / H264 encoding framework with per scene quality encoding
GNU General Public License v3.0
1.46k stars 151 forks source link

Burning subtitles? #783

Open RyanHakurei opened 1 year ago

RyanHakurei commented 1 year ago

I have some media I am trying to encode, and everything else being said I am having no issues except that I can't seem to get ASS/SSA subtitles to burn. I looked up ffmpeg's documentation to burn subtitles and it appears that passing -vf subtitles=video.mkv is what I want. I am passing that using Avian's relevant flag, but the final video only has the subtitles passed through, not burned into the video. Here is the command I am using:

av1an -x 300 -i video.mkv \
-v " \
--deltaq-mode=0 --sharpness=1 --profile=0 --end-usage=q \
--cq-level=30 --threads=2 --tile-columns=2 --tile-rows=1 \
--cpu-used=2 --row-mt=0 --enable-fwd-kf=1 --aq-mode=1 \
--lag-in-frames=48 --bit-depth=10 --kf-max-dist=240 \
--kf-min-dist=12 --enable-qm=1 --sb-size=64 --arnr-strength=0 \
--arnr-maxframes=3 --enable-dnl-denoising=0 --denoise-noise-level=5 \
--enable-restoration=0 --enable-cdef=0 --gf-max-pyr-height=4 --max-reference-frames=4 \
" \
-w 16 -p 2 -l video.log --pix-format yuv420p10le \
-f " -vf subtitles=video.mkv " \
-a " -c:a libfdk_aac -b:a 384k " \
-o "video-AV1.mkv"
silverbacknet commented 1 year ago

That's a tricky proposition, since the subtitle filter has to be seeked for each slice. Most likely it is burning as well as reattaching them, there are just no subtitles to burn in the first X seconds, however long your slices are. It will just keep trying to burn from the start on every slice, which is definitely not what you want. Adding on the seek to the filter string shouldn't be too hard, but it has to be done in the code.

RyanHakurei commented 1 year ago

Looking at it, yeah it is just burning in the first 2-3 seconds worth of subtitles for every chunk. I only had a minute or so to look today and I thought the subtitles showing up where VLC defaulting to enabling the sub track since they did appear to go away when I turned them off.

master-of-zen commented 1 year ago

What about different approach, use vapoursynt to feed input that have them already burned-in?

RyanHakurei commented 1 year ago

Wouldn't that require transcoding the file twice? Once to burn then the final AV1 transcode?

master-of-zen commented 1 year ago

Vapoursynth processed your input into what needs to be fed into the av1an on demand, meaning that you can make as many manipulations in vapoursynth script and applied to the source when it fed to the av1an

RyanHakurei commented 1 year ago

At this point I think the better option would just be to forgo subs and deal with on-the-fly transcoding if subs are wanted. I wouldn't even know where to begin to even look to get Vapoursynth to feed in subs as Av1an needs them. That is wayyyy outside my level of expertise in this regard.