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

videowmark: ensure temp files get deleted when done

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 4c8c4a7d
......@@ -2,7 +2,6 @@ possible improvements:
- dynamic bit strength
videowmark:
temp files
--key
--help
stream issue
......
......@@ -24,21 +24,41 @@ function audio_encode_options
}'
}
function create_temp_files
{
local fd
for fd in "$@"
do
local tmpfile=$(mktemp /tmp/videowmark.XXXXXX)
eval "exec $fd>$tmpfile"
rm "$tmpfile"
done
}
if [ "$1" == "add" ]; then
# create tmpfiles
create_temp_files 3 4
orig_wav=/dev/fd/3
wm_wav=/dev/fd/4
# get audio as wav
ffmpeg -y -i "$2" tmp.wav
ffmpeg -y -i "$2" -f wav "$orig_wav"
# watermark
audiowmark add tmp.wav tmp1.wav "$4"
audiowmark add "$orig_wav" "$wm_wav" "$4"
# rejoin
ffmpeg -y -i "$2" -i tmp1.wav -c:v copy $(audio_encode_options "$2") -map 0:v:0 -map 1:a:0 "$3"
ffmpeg -y -i "$2" -i "$wm_wav" -c:v copy $(audio_encode_options "$2") -map 0:v:0 -map 1:a:0 "$3"
elif [ "$1" == "get" ]; then
# create tmpfiles
create_temp_files 3
wav=/dev/fd/3
# get audio as wav
ffmpeg -y -i "$2" tmp.wav
ffmpeg -y -i "$2" -f wav "$wav"
# get watermark
audiowmark get tmp.wav
audiowmark get "$wav"
elif [ "$1" == "probe" ]; then
echo $2 $(audio_encode_options "$2")
else
echo "videowmark: error parsing command line arguments"
fi
rm -f tmp*
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