diff --git a/.config/zsh/functions/cutvid b/.config/zsh/functions/cutvid index db1b9b0..555f30a 100755 --- a/.config/zsh/functions/cutvid +++ b/.config/zsh/functions/cutvid @@ -35,19 +35,17 @@ local vencoder="copy" local aencoder="copy" [[ ${#o_vencoder} -eq 2 ]] && vencoder=${o_vencoder[2]} [[ ${#o_aencoder} -eq 2 ]] && aencoder=${o_aencoder[2]} +local subtitle_options=(-codec:s copy) + +if [[ ${#o_hardcode_subs} -ne 0 ]]; then + local tmpass=$(mktemp --suffix='.cutvid.ass') + ffmpeg -i ${input} -y ${tmpass} + subtitle_options=(-sn -vf ass=${tmpass} ) +fi ffmpeg -i ${input} \ -ss ${from} -to ${to} \ - -codec:v ${vencoder} -codec:a ${aencoder} -codec:s copy \ + -codec:v ${vencoder} -codec:a ${aencoder} ${subtitle_options} \ ${ffmpeg_options} ${output} -# NOTE: only works with ASS at the moment -if [[ ${#o_hardcode_subs} -ne 0 ]]; then - local tmpass=$(mktemp --suffix='.cutvid.ass') - ffmpeg -i ${output} -y ${tmpass} - ffmpeg -sn -i ${output} -vf ass=${tmpass} \ - -codec:v ${vencoder} -codec:a copy \ - hardcoded_sub_${output} - mv --verbose hardcoded_sub_${output} ${output} - rm --verbose ${tmpass} -fi +[[ ${#o_hardcode_subs} -ne 0 ]] && rm --verbose ${tmpass}