0

I am running ffmpeg on headless servers with the intention of keeping these processes running for hours on end. I would like to parse the output for useful information like "fps", "time" "bitrate" or any warnings/errors and pass them to other processes, i.e. a web server.

By default ffmpeg prints to the terminal with this information every second on a new line. This makes parsing it very cumbersome and eventually degrades in performance the longer the terminal output becomes.

  • Is parsing the terminal output the right strategy here and is there a flag for something like bash's "echo -a" append function within ffmpeg? I've set a few of the -v flags to change the output but none match my needs!

  • Is there a way I can directly invoke something like "getFps()" on the running ffmpeg process itself to return the current encoding rate?

Thanks

sg90
  • 39
  • 4
  • wonder if one is stderr and one stdout. There's also "-loglevel" settings, FWIW. Or run ffmpeg twice, once for fps, once to really go. GL! – rogerdpack Jan 14 '15 at 21:02
  • *"This makes parsing it very cumbersome and eventually degrades in performance the longer the terminal output becomes."* -- why is that? your description suggests that the work should be the same: parse one line per second -- a very light load. Have you seen [Python: read streaming input from subprocess.communicate()](http://stackoverflow.com/a/17698359/4279)? – jfs Jan 14 '15 at 21:27
  • 1
    as an alternative, you could use gstreamer. You could create an arbitrary Gstreamer pipeline that performs necessary transformations. Here's [a minimal player code example](https://gist.github.com/zed/de5ebbc08805a941a7f7). – jfs Jan 14 '15 at 21:34
  • The parsing degrades performance as I am having to get the last line of a terminal that is always growing. I may be wrong but subprocess.communicate() or subprocess.stdout.readline() reads from the first line? Unfortunately I am stuck with ffmpeg in my pipeline! – sg90 Jan 14 '15 at 22:05
  • @J.F.Sebastian Thanks for the pointers, it appears to be a misunderstanding on my end. I'll read into your example and report back my results! – sg90 Jan 14 '15 at 22:25

0 Answers0