Commit 2bf8a91d authored by Stefan Westerfeld's avatar Stefan Westerfeld

videowmark: die on error

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 194957f1
......@@ -2,6 +2,5 @@ possible improvements:
- dynamic bit strength
plausibility checks
die on errors
stream issue
opus length ffprobe -show_format phil.mkv
#!/bin/bash
function die
{
echo >&2 "videowmark: error: $@"
exit 1
}
# auto detect codec and bitrate from input stream, generate ffmpeg options for audio encoder
function audio_encode_options
{
......@@ -85,20 +91,21 @@ if [ "$1" == "add" ]; then
wm_wav=/dev/fd/4
# get audio as wav
ffmpeg $FFMPEG_VERBOSE -y -i "$2" -f wav "$orig_wav"
ffmpeg $FFMPEG_VERBOSE -y -i "$2" -f wav "$orig_wav" || die "extracting audio from video failed (ffmpeg)"
# watermark
audiowmark "${AUDIOWMARK_ARGS[@]}" add "$orig_wav" "$wm_wav" "$4"
audiowmark "${AUDIOWMARK_ARGS[@]}" add "$orig_wav" "$wm_wav" "$4" || die "watermark generation failed (audiowmark)"
# rejoin
ffmpeg $FFMPEG_VERBOSE -y -i "$2" -i "$wm_wav" -c:v copy $(audio_encode_options "$2") -map 0:v:0 -map 1:a:0 "$3"
ffmpeg $FFMPEG_VERBOSE -y -i "$2" -i "$wm_wav" -c:v copy $(audio_encode_options "$2") -map 0:v:0 -map 1:a:0 "$3" || \
die "merging video and watermarked audio failed (ffmpeg)"
elif [ "$1" == "get" ]; then
# create tmpfiles
create_temp_files 3
wav=/dev/fd/3
# get audio as wav
ffmpeg $FFMPEG_VERBOSE -y -i "$2" -f wav "$wav"
ffmpeg $FFMPEG_VERBOSE -y -i "$2" -f wav "$wav" || die "extracting audio from video failed (ffmpeg)"
# get watermark
audiowmark "${AUDIOWMARK_ARGS[@]}" get "$wav"
audiowmark "${AUDIOWMARK_ARGS[@]}" get "$wav" || die "retrieving watermark from audio failed (audiowmark)"
elif [ "$1" == "probe" ]; then
echo $2 $(audio_encode_options "$2")
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment