diff options
author | Mattias Andrée <m@maandree.se> | 2025-03-15 11:33:20 +0100 |
---|---|---|
committer | Mattias Andrée <m@maandree.se> | 2025-03-15 11:33:29 +0100 |
commit | 7ac45ee235517114f6382810e3f1671e3fe715cc (patch) | |
tree | 4381bf5876a15e172c6717702da4562e7e83e663 /ffextract-audio | |
parent | Bump year (diff) | |
download | ffutils-7ac45ee235517114f6382810e3f1671e3fe715cc.tar.gz ffutils-7ac45ee235517114f6382810e3f1671e3fe715cc.tar.bz2 ffutils-7ac45ee235517114f6382810e3f1671e3fe715cc.tar.xz |
Prefix filenames for ffmpeg/ffprobe with file:, and tell when - is not supported1.0.2
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to '')
-rwxr-xr-x | ffextract-audio | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/ffextract-audio b/ffextract-audio index f72425f..7af0f43 100755 --- a/ffextract-audio +++ b/ffextract-audio @@ -42,10 +42,23 @@ if test $# = 2; then if test -z "${out_file}"; then usage fi + if test "${out_file}" = -; then + printf '%s: - is not supported for out-file\n' "$0" >&2 + exit 1 + fi +else + if test "${in_file}" = -; then + printf '%s: out-file must be specified if in-file is -\n' "$0" >&2 + exit 1 + fi fi getext () { - ffprobe -v error -select_streams a:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 -- "$1" + probed_file="$1" + if test ! "${probed_file}" -; then + probed_file="file:${probed_file}" + fi + ffprobe -v error -select_streams a:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 -- "${probed_file}" } removeext () { @@ -55,7 +68,11 @@ removeext () { extract () { printf '\033[1m%s\033[m\n' "Extracting audio track from ${1}" >&2 printf '\033[1m%s\033[m\n' "and storing as ${2}" >&2 - if ffmpeg -i "${1}" -vn -acodec copy ${ffmpeg_flag_y} -- "${2}"; then + in_file_prefixed="${1}" + if test ! "${in_file_prefixed}" -; then + in_file_prefixed="file:${in_file_prefixed}" + fi + if ffmpeg -i "${in_file_prefixed}" -vn -acodec copy ${ffmpeg_flag_y} -- "file:${2}"; then if test ${delete_in_file} = yes; then unlink -- "${1}" fi |