diff --git a/.config/zsh/completions/_cutvid b/.config/zsh/completions/_cutvid index 80e62a7..52c072d 100644 --- a/.config/zsh/completions/_cutvid +++ b/.config/zsh/completions/_cutvid @@ -33,7 +33,7 @@ _arguments '-h[short help text]' \ '--to[timestamp]:timestamp:' \ '--vencoder[video encoder]:encoder:_cutvid_vencoders' \ '--aencoder[audio encoder]:encoder:_cutvid_aencoders' \ - '--hardcode-subs[hardcode ASS subtitles]' \ + '--hardcode-subs[hardcode ASS subtitles]:number:' \ '1:input file:_files' \ '2:output file:_files' \ '*:ffmpeg options:' diff --git a/.config/zsh/functions/cutvid b/.config/zsh/functions/cutvid index 3f6a409..63f1741 100755 --- a/.config/zsh/functions/cutvid +++ b/.config/zsh/functions/cutvid @@ -12,13 +12,13 @@ local -a o_aencoder=() local -a o_hardcode_subs=() zparseopts -D -K -- h=o_help -help=o_help -from:=o_from -to:=o_to \ -vencoder:=o_vencoder -aencoder:=o_aencoder \ - -hardcode-subs=o_hardcode_subs + -hardcode-subs:=o_hardcode_subs if [[ ${#o_help} -ne 0 || ! -v 2 || ${#o_from} -ne 2 || ${#o_to} -ne 2 ]]; then local ret=$(( ${#o_help} ^ 1 )) print -u $(( 1 + ${ret} )) "usage: ${0} [-h|--help]" \ "--from --to " \ - "[--vencoder ] [--aencoder ] [--hardcode-subs]" \ - " [FFMPEG OPTIONS]" + "[--vencoder ] [--aencoder ]" \ + "[--hardcode-subs ] [FFMPEG OPTIONS]" print "\e[3mYou can set bitrates with -b:v and -b:a in FFMPEG OPTIONS." \ "The -vn / -an / -sn / -dn options can be used to skip inclusion of" \ "video, audio, subtitle and data streams respectively." \ @@ -38,12 +38,14 @@ local vencoder="copy" local aencoder="copy" [[ ${#o_vencoder} -eq 2 ]] && vencoder=${o_vencoder[2]} [[ ${#o_aencoder} -eq 2 ]] && aencoder=${o_aencoder[2]} +local subnumber=0 +[[ ${#o_hardcode_subs} -eq 2 ]] && subnumber=${o_hardcode_subs[2]} local subtitle_options=(-codec:s copy) local compat_options=(-pix_fmt yuv420p) # Android doesn't like yuv420p10le if [[ ${#o_hardcode_subs} -ne 0 ]]; then local tmpass=$(mktemp --suffix='.cutvid.ass') - ffmpeg -i ${input} -y ${tmpass} + ffmpeg -i ${input} -map 0:s:${subnumber} -y ${tmpass} subtitle_options=(-sn -vf ass=${tmpass} ) fi