Similar question here, but no solution: https://www.reddit.com/r/linuxquestions/comments/m00f0/hex_output_from_ffmpeg_when_run_in_a_loop/
I'm trying to batch encode some video. I have a list of filenames in a text file and read each one in a bash loop. This is it:
OUT=./out
mkdir -p $OUT
while read inputfile; do
b=$(basename "$inputfile")
outputfile="$OUT/$b"
echo
echo
echo "$inputfile"
echo "$outputfile"
echo
ffmpeg -i "$inputfile" "$outputfile" || exit
done < files.txt
When I run it, the ffmpeg command seems to start OK, then spits out a massive wall of red hex dump like text (as below). It does finish without error, but the file is only a few hundred frames long.
[libx264 @ 0x1b68d60] frame= 537 QP=31.44 NAL=0 Slice:B Poc:70 I:2 P:239 SKIP:987 size=516 bytes
stream #1:
keyframe=1
duration=0.024
dts=25.992 pts=25.992
size=336
00000000 ff fb 84 64 1a 0e d3 21 3f d4 93 18 6a e6 33 a4 ...d...!?...j.3.
00000010 6a 63 25 22 4a 0c d1 1d 52 6c bd ab c0 bf 23 69 jc%"J...Rl....#i
... LOTS MORE
The other really weird thing is that the next inputfile
in the bash loop is broken and has only the last few characters, which does not happen if I simply comment out the ffmpeg
line.
What could ffmpeg be doing to interfere with the bash loop like this?
(ffmpeg 2.8.6, bash 4.3.42(1), fedora 23)
The ffmpeg verbosity is quite tricky. Some ideas can be found in their online manual page. A good option is to use the warning level options ‘warning, 24’
like this:
ffmpeg -v 24 -nostdin ...
Found the answer here: https://unix.stackexchange.com/questions/241535/problem-with-ffmpeg-in-bash-loop
Somehow the read
command's stdin
ends up shared by ffmpeg
. Still not sure why, but the answer is to re-route the ffmpeg
stdin
from /dev/null
. E.g.:
ffmpeg -i "$inputfile" "$outputfile" < /dev/null || exit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With