No creo que FFmpeg admita esto de forma nativa. Me las arreglé para escribir una secuencia de comandos que permite ocurrencias únicas o múltiples:
stream_count=$(/usr/bin/ffprobe -select_streams s -show_entries stream=index,codec_name -of csv=p=0 "path/to/file.ext" |& grep -cE 'Subtitle: dvd_subtitle|Subtitle: hdmv_pgs' || :)
if [ "$stream_count" -gt 0 ]
then
stream_id=$(/usr/bin/ffprobe -select_streams s -show_entries stream=index,codec_name -of csv=p=0 "path/to/file.ext" |& grep -E 'Subtitle: dvd_subtitle|Subtitle: hdmv_pgs' || :)
if [ "$stream_count" = 1 ]
then
exclude_stream=$(echo "$stream_id" | grep -oP '0:[0-9]{1,3}')
exclude_stream="-map -$exclude_stream"
else
counter=0
until [ "$counter" = "$stream_count" ]
do
counter=$((counter+1))
excluded_stream="$(echo "$stream_id" |& grep -oP '0:[0-9]{1,3}' |& sed -n "${counter}"p)"
if [ ! -z "$excluded_stream" ]
then
if [ "$exclude_stream" = "*$excluded_stream*" ] #If ffprobe returns encode errors within the streams, double results may be returned for the problematic stream which this circumvents
then
counter="$stream_count"
else
exclude_stream="$exclude_stream -map -$excluded_stream"
fi
fi
excluded_stream=""
done
fi
fi
ffmpeg -y -i "path/to/file.ext" -map 0 $exclude -c:v libx264 -crf 20 -level 4.1 -profile:v high -c:a copy -q:a 100 -preset faster -strict -2 -movflags faststart -threads 2 -nostdin -stats "file.mkv" #exclude isn't wrapped as it invalidates the opening hyphen
Si alguien tiene alguna sugerencia para mejorar aún más este script, me encantaría escucharlo.
Gracias @LordNeckbeard por las modificaciones sugeridas al comando ffprobe.
ffprobe -loglevel error -select_streams s -show_entries stream=index,codec_name -of csv=p=0 input.ext