Thursday, 15 December 2016

burning subtitles


recently i did a little film project where i had to burn specially formatted subtitles onto the movie. i spent some time finding a good solution for this. here are the findings.

creating the subtitles
after having tried out several tools for creating subtitles i ended up with Aegisub. a nice free open-source subtitle tool, with all the features i needed. i created my own template, which defined the font and style to use. hence it was easy to create subtitles for several films, with the same layout. to preserve the format i exported using the .ass file format.

burning the subtitles
to burn the subtitles onto the movie i used ffmpeg. a nice howto is found here. worth noticing that i had a couple of issues though. first off an issue related the "fontconfig_file" (one fix here). second some issue accessing subtitle files when they were located in a different directory than the movie file. i solved this copying over the subtitle file.

here is the bat file i ended up using for burning subtitles (original files can be found on github.com):

:: - - - - - - - - - - - - - - - - - - - - - - - - - - -
:: burn subtitles
:: author: frode klevstul (frode at klevstul dot com)
:: started: november 2016
::
:: DOCUMENTATION
:: fix font config:
:: - https://trac.ffmpeg.org/wiki/HowToBurnSubtitlesIntoVideo
:: - https://ffmpeg.zeranoe.com/forum/viewtopic.php?f=7&t=2554
:: - https://github.com/Shoes3/shoes3/issues/46
::
:: note - i only needed to add the env variable FONTCONFIG_FILE:
:: set FONTCONFIG_FILE=R:\googleDrive\_portableApps\ffmpeg\fonts\fonts.conf
:: - - - - - - - - - - - - - - - - - - - - - - - - - - -
ECHO OFF

SET SOURCE_DIR=R:\videoEditing\1610_forbrukerraadet\renders\lowRes\
SET TARGET_DIR=R:\_desktop\
SET SOURCE_FILNAME=1610_fr_mov7_v05.mp4
SET TARGET_FILENAME=1610_fr_mov7_v05_burnedSubs.mp4
SET SUBTITLES=R:\videoEditing\1610_forbrukerraadet\assets\subtitles\film7.ass
SET TMP_SUB_FILE=tmp.ass

SET SOURCE_FILE=%SOURCE_DIR%%SOURCE_FILNAME%
SET TARGET_FILE=%TARGET_DIR%%TARGET_FILENAME%
SET FFMPEG=R:\googleDrive\_portableApps\ffmpeg\bin\ffmpeg.exe

:: problems accessing subtitles files in another directory, so copying it over to current script dir, and deleting it again, after we are done using it
copy %SUBTITLES% %TMP_SUB_FILE%

:: command for .ass type subtitles
%FFMPEG% -i %SOURCE_FILE% -vf ass=%TMP_SUB_FILE% -y %TARGET_FILE%

:: delete temporary subtitles file
del %TMP_SUB_FILE%



No comments:

Post a Comment

Allowed HTML tags:
<b>bold</b>
<strong>strong</strong>
<i>italics</i>
<em>emphasis</em>
<a href="">hyperlink</a>


Please, show the courtesy of identifying yourself when adding a comment. Anonymous comments will, most likely, be removed.