Analysing videos with ffmpeg

Some of my notes on using FFmpeg.

Extract I-Frames

ffmpeg -hide_banner \
	-i ./12327_20150418201800.mpg \
	-vf select="eq(pict_type\,PICT_TYPE_I)" \
	-t 10 \
	-q:v 2 \
	-vsync 0 \
	-loglevel debug \
	./tmp/image%03d.jpg

ffmpeg -hide_banner \
	-i ./1x01\ Ganz\ normale\ Jobs.m4v \
	-an \
	-vf 'select=gt(scene\,0.9)' \
	-vsync 0 -\
	f image2 \
	./tmp/thumb%03d.jpg

Analyze MPEG

ffprobe -hide_banner \
	-select_streams v \
	-count_frames \
	-show_frames \
	-print_format csv \
	-show_entries 'frame=key_frame,pict_type,pkt_pts_time,pkt_dts_time,best_effort_timestamp_time,pkt_pos,pkt_size' \
	-i ./30723_20150103224000.mpg

Frame-Types

I: intra, full-picture P: predicted, depends ons previous [IP] frames B: bidirectional, depend on future frames PTS: presentation time stamp, may jump DTS: decode time stamp, matches stream order

Cutting

ffmpeg -hide_banner \
	-i "concat:seg1.ts|seg2.ts|seg3.ts" \
	-c:v copy \
	-c:a copy \
	-movflags empty_moov \
	-flags global_header \
	-bsf:v dump_extra \
	./edited-final.mp4

Profile/Level

Written on December 3, 2017