HANDY TIP: Using FFprobe for stream analysis
by Michael Rampe on Jun 12, 2010 at 5:21:19 am
HANDY TIP:
You can easily extract bitrate data and frame types (I,P,B) using FFprobe.
At the time of writing, FFprobe version SVN-r92, Copyright (c) 2007-2009 Stefano Sabatini works for frame analysis amongst many other things. The FFprobe attachment to the trunk of FFmpeg version SVN-r23145, Copyright (c) 2000-2010 the FFmpeg developers is not fully complete. Never fear, it works great anyway. Just install the SVN-r92 FFprobe version and run it manually.
Re: HANDY TIP: Using FFprobe for stream analysis by Rodney Baker on Jun 12, 2010 at 9:03:08 am
Use sed/awk to massage the data into a suitable format for graphing, then use gnuplot to produce the output. Once that it settled, tie it all together using a shell script/python/perl or your language of choice. All the tools to do it exist already - why reinvent the wheel?
Re: HANDY TIP: Using FFprobe for stream analysis by Rodney Baker on Jun 13, 2010 at 3:34:18 am
Hi Michael. The syntax for sed and awk can be tricky, and they can both do pretty advanced stuff. I think awk may be the more appropriate tool for this, although it could be done directly using either Python or Perl too (but I'm not a programmer so I'm not the right person to ask about that).
Mind you, I'm no expert on awk or sed either, but I know that you can use either one to achieve what you want. Sed (Stream EDitor) is designed for line-by-line string editing/replacement, whereas awk is more powerful and probably more suited to parsing the data output from ffprobe and rewriting it into the format that you need for gnuplot. That is my understanding, anyway.
Re: HANDY TIP: Using FFprobe for stream analysis by Michael Rampe on Jun 13, 2010 at 4:02:58 am
[Rodney Baker]"(but I'm not a programmer so I'm not the right person to ask about that)."
Me either;-)
I did get some good results just then with:
./ffprobe -show_frames two_pass.mp4 | grep 'size\|coded_picture_number' > raw.dat && paste -s -d '\t\n' raw.dat > fixed.dat && sed -e 's/coded_picture_number=//g' -e 's/size=//g' fixed.dat > column.dat && gnuplot plot1
1. FFprobe lists all frame details
2. grep strips all lines except size and picture number and writes to a file
3. paste combines lines two by two from previous file to new file
4. sed takes the new file and strips the unnecessary text and creates a data file
5. gnuplot plots the datafile to image output
(the gnuplot "plot1" file contains:
set yrange [0:15000]
set ytics (15000, 10000, 5000)
set xrange [0:200]
set lmargin 9
set rmargin 2
plot 'column.dat' using 1:2 notitle with lines)
Not very elegant but it works as a proof of concept.
Thanks for your nudges in the right directions.
Michael
"half-way to world domination A.K.A. the belligerent blue bike shed"
Mission complete by Michael Rampe on Jun 14, 2010 at 7:56:41 am
After a bit of tinkering, I think I have got the result I was looking for. Open source bitrate graphing with frame type identification. The following two images are the results of one pass and two pass x264 encoding with FFmpeg. IPB frames are identified by colour. NOTE: As labelled, the y dimension is measured in Bytes per frame.
For context or interest, this is the test video that I have used for this experiment. (I created it with Blender, another great open source program;-)
I chose/created this video specifically for its inherently variable bitrate structure.
For the unix minded, how I did it?
Let me know if you get stuck;-)
# SOFTWARE NEEDED (all open source) FFmpeg (>SVN-r23145), FFprobe FFprobe (>SVN-r92, currently being merged into FFmpeg as of time of posting) gnuplot (>4.2), grep, sed.
# GNUPLOT "plot.txt"
set title "1pass"
set xlabel "frame number\n\n./ffmpeg -i funny_bubbles.mov -vcodec libx264 -vpre hq -b 1500k funnyhq.mp4"
set ylabel "Bytes per frame"
set yrange [0:35000]
set ytics (35000, 30000, 25000, 20000, 15000, 10000, 5000)
set xrange [-10:850]
set lmargin 12
set rmargin 2
set grid
set pointsize 2
set label 1 "I frames"
set label 1 at graph .85, .96 tc lt 1
set label 2 "P frames"
set label 2 at graph .85, .92 tc lt 2
set label 3 "B frames"
set label 3 at graph .85, .88 tc lt 3
plot 'column.dat' using 2:3:1 notitle with i lc rgb variable
Now, to work out how to write a sh script to make it easier.
Michael
"half-way to world domination A.K.A. the belligerent blue bike shed"
Re: Mission complete by John van Kemenade on Jun 30, 2010 at 5:41:54 pm
pretty impressive huh!
Can you point me to a win32 binary of this version of FFprobe.
FFprobe that is packed with the daily builds of FFmpeg does not contain the -show_frames option.
Re: Mission complete by kathija naseem on Feb 6, 2012 at 5:37:01 am
Hi,
Is it possible to use the same tool for files with asf formats. Because i tried with asf on Windows. I was able to parse it but I am not getting the size of each frame.
Re: HANDY TIP: Using FFprobe for stream analysis by Oussama Stiti on Mar 22, 2012 at 2:12:44 am
Hello,
I want to detect the distorded frames ( corrupted or loss) and, i want to edit a log file, wich exctract such informations, like slice #, frame ID, related frames, type of frame.
Is it possible with ffprobe, to display such informations ( damaged frame) ?
I'm running on ubuntu, and i'm broadcasting a video in the loopback IP, using a VLC player client, and a VLC player server.