Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

I was using my Odroid XU4 based media server to transcode some videos using ffmpeg when I came across some strange errors appearing on the console. When I would run ffmpeg as a single command, it would work, however running it in a loop presented errors (or rather strange behaviour).

This is the kind of output I was seeing...
 ffmpeg output
Press [q] to stop, [?] for help
frame=24 fps=0.0 q=0.0 size=0kB time=00:00:01.77 bitrate=0.0kbits/s speed=3.52x
error parsing debug value
debug=0
frame=46 fps= 38 q=0.0 size=0kB time=00:00:02.68 bitrate=0.0kbits/s speed= 2.2x
Enter command: <target>|all <time>|-1 <command>[ <argument>]


Instead of processing the video file, ffmpeg would stop and wait for user input. The message 'error parsing debug value' would also be displayed prior to input being asked.

Turns out this happens because by default ffmpeg is in interactive mode. This means that the output it was producing was being used as input and eventually certain input characters caused ffmpeg to stop and ask for user input.

There are two ways to stop this from happening:
  1. Add '< /dev/null' to the end of the ffmpeg command so it reads input from the null device instead of standard input
  2. Add '-nostdin' to the ffmpeg command as per documentation to stop it reading input from standard input by default


I went for the first option, so my command to transcode all AVI files in a directory to H.264 with AAC MKV files looked like this:
 ffmpeg command
find . -name "*.avi" -print0|sed -e "s/.avi//g"| while read -d $'\0' file; do ffmpeg -y -i "$file.avi" -vcodec h264 -acodec aac -vbr 4 -movflags +faststart "$file.mkv" < /dev/null; done




-i

A quick disclaimer...

Although I put in a great effort into researching all the topics I cover, mistakes can happen. Use of any information from my blog posts should be at own risk and I do not hold any liability towards any information misuse or damages caused by following any of my posts.

All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle). Use of any information contained in this blog post/article is subject to this disclaimer.
Hi! You can search my blog here ⤵
NOTE: (2022) This Blog is no longer maintained and I will not be answering any emails or comments.

I am now focusing on Atari Gamer.