Compare commits

...

No commits in common. "master" and "v0.13.1" have entirely different histories.

2 changed files with 10 additions and 56 deletions

View file

@ -1,42 +0,0 @@
# burnSubs
You found my burnSubs tool. The goal for this tool is to ease the
conversion of arbitrary video files with soft-subtitles in the SSA/ASS
Substation Alpha format into simple stereo hard-subtitled video files.
## Features
* softsub to hardsub conversion
* embedded font files
* selecting specific audio streams
* selecting specific video streams
* automatic selection of language preferences
* default surround sound to stereo down-mixing
* opt out CLI flag available
* anti-clobbering default behavior
* auto-cleanup on error
## Prerequisite Tools
Firstly, the tool will yell at you if the tools it needs don't exist.
Feel free to just run the tool, and it will let you know what you're
missing.
* [`ffmpeg`](https://ffmpeg.org/) - the one and only
* `ffprobe` - usually comes with ffmpeg
* [`jq`](https://stedolan.github.io/jq/) - file/pipe based JSON processor
## How does it work?
`burnSubs` takes an input video file and tries to figure out what
audio streams and subtitle streams exist within the file. It stores
metadata in `/tmp` while it runs. When running it will pull the
streams within the input file, and try to select Japanese language
audio streams, and a non-signs subtitle stream (i.e. a full language
subtitle stream) to add to the output video.
Before transcoding it will then extract the subtitle file to pass into
`ffmpeg`'s subtitle burn in filter, and will try to down-mix any
surround sound input streams to stereo. Downmixing, track selection,
clobbering behavior, and verbosity can all be controlled to a limited
extent by CLI flags.
## Can you make it do *XYZ*.
Give me an enhancement request in github and I'll take a look.

View file

@ -5,7 +5,7 @@ set -o errexit
################################################################################ ################################################################################
# burnSubs # burnSubs
# version 0.13.3 # version 0.13.1
################# #################
# Wishlist: # Wishlist:
# queue encodes # queue encodes
@ -13,9 +13,11 @@ set -o errexit
# finish help flag # finish help flag
# audio recode flag # audio recode flag
# #
# Changes
# automatically select JPN audio if more than one audio channel found.
################################################################################ ################################################################################
DEFAULTS_OPTS_CRF=18 DEFAULTS_OPTS_CRF=20
function machineSetup() { function machineSetup() {
# Default setup # Default setup
@ -137,9 +139,9 @@ function setupBins() {
setAndValidateBin "ffmpeg" "FFMPEG" setAndValidateBin "ffmpeg" "FFMPEG"
setAndValidateBin "ffprobe" "FFPROBE" setAndValidateBin "ffprobe" "FFPROBE"
setAndValidateBin "jq" "JQ" setAndValidateBin "jq" "JQ"
#setAndValidateBin "python3" "PYTHON3" setAndValidateBin "python3" "PYTHON3"
#setAndValidateBin "awk" "AWK" setAndValidateBin "awk" "AWK"
#setAndValidateBin "date" "DATE" setAndValidateBin "date" "DATE"
} }
# Used by the above function to evaluate overrides if they are set, and # Used by the above function to evaluate overrides if they are set, and
@ -173,7 +175,6 @@ function doCleanup() {
echo "=> Cleaning up." echo "=> Cleaning up."
rm -r "$TMP" rm -r "$TMP"
else else
set +x
echo "tmp dir: $TMP" echo "tmp dir: $TMP"
fi fi
@ -313,7 +314,7 @@ function setupAudioTranscode() {
if [[ "${OPTS_SURROUND_PRESERVE}" == false ]]; then if [[ "${OPTS_SURROUND_PRESERVE}" == false ]]; then
# From https://superuser.com/questions/852400/properly-downmix-5-1-to-stereo-using-ffmpeg # From https://superuser.com/questions/852400/properly-downmix-5-1-to-stereo-using-ffmpeg
# Nightmode Formula # Nightmode Formula
FILT_AUDIO="-filter:a pan=stereo|FL=FC+0.30*FL+0.30*BL|FR=FC+0.30*FR+0.30*BR ${FILT_AUDIO}" FILT_AUDIO="-filter:a pan=stereo|FL<FC+0.30*FL+0.30*BL|FR<FC+0.30*FR+0.30*BR ${FILT_AUDIO}"
fi fi
else else
FILT_AUDIO="-c:a copy" FILT_AUDIO="-c:a copy"
@ -385,9 +386,9 @@ function selectSubs() {
# try to avoid a signs and lyrics track # try to avoid a signs and lyrics track
LANG_SINGLE_SELECT=$($JQ '[.[].lang] | index("'${OPTS_SELSUB_LANG}'")' "$STREAMS_SUB") LANG_SINGLE_SELECT=$($JQ '[.[].lang] | index("'${OPTS_SELSUB_LANG}'")' "$STREAMS_SUB")
echo "Multiple english tracks found." echo "Multiple english tracks found."
export SUBTITLE_INDEX=$($JQ 'reduce .[] as $trk ([]; if ($trk.lang == "'${OPTS_SELSUB_LANG}'" and (( ($trk.t | test("lyrics";"i")) or ($trk.t | test("signs";"i")) or ($trk.t | test("dub";"i")) )|not) ) then [.[],{t:$trk.t,i:$trk.i}] else . end) | .[].i' "$STREAMS_SUB") export SUBTITLE_INDEX=$($JQ 'reduce .[] as $trk ([]; if ($trk.lang == "'${OPTS_SELSUB_LANG}'" and ( ($trk.t | test("lyrics";"i") or ($trk.t | test("signs";"i")) ) | not ) ) then [.[],{t:$trk.t,i:$trk.i}] else . end) | .[].i' "$STREAMS_SUB")
# And display rejected subtitles too. # And display rejected subtitles too.
SUBTITLE_REJECT_LIST=($($JQ 'reduce .[] as $trk ([]; if ($trk.lang == "'${OPTS_SELSUB_LANG}'" and (( ($trk.t | test("lyrics";"i")) or ($trk.t | test("signs";"i")) or ($trk.t | test("dub";"i")) )) ) then [.[],{t:$trk.t,i:$trk.i}] else . end) | .[].t' "$STREAMS_SUB")) SUBTITLE_REJECT_LIST=($($JQ 'reduce .[] as $trk ([]; if ($trk.lang == "'${OPTS_SELSUB_LANG}'" and ( ($trk.t | test("lyrics";"i") or ($trk.t | test("signs";"i")) ) ) ) then [.[],{t:$trk.t,i:$trk.i}] else . end) | .[].t' "$STREAMS_SUB"))
for REJECT_SUB in ${SUBTITLE_REJECT_LIST[@]}; do for REJECT_SUB in ${SUBTITLE_REJECT_LIST[@]}; do
echo " > rejecting ${REJECT_SUB}" echo " > rejecting ${REJECT_SUB}"
done done
@ -735,11 +736,6 @@ elif [[ ${OPTS_VERBOSITY} -eq 1 ]]; then
else # ie [[ ${OPTS_VERBOSITY} -ge 2 ]]; then else # ie [[ ${OPTS_VERBOSITY} -ge 2 ]]; then
FF_VERBOSITY="-hide_banner" FF_VERBOSITY="-hide_banner"
fi fi
if [[ "$OPTS_DEBUG" == "true" ]]; then
set -x
fi
############### ###############
# Configure the encoder based upon the hostname # Configure the encoder based upon the hostname
machineSetup machineSetup