5) Common Use Cases and FFmpeg Commands
Common Use Cases and FFmpeg Commands
Case: I’m an archivist who wants to figure out the properties of an existing AV file…
Solution: Using ffprobe, a tool which is part of FFmpeg, you can reveal a number of relevant specifications pertaining to the file.
Command:
ffprobe -i {path/inputfile.extension} -show_format -show_streams -show_data -show_versions
Result: Properties (including format, codecs, duration, size, and bitrate) will be listed in the Terminal window.
Case: I’m an archivist who wants to generate thumbnails for videos in a collection…
Solution: You have multiple options for grabbing thumbnails. One way is to create a command to grab a thumbnail from a stated point in the video. You can also have thumbnails created periodically based off of a rate specified in the command.
Command:
ffmpeg -i {path/inputfile.extension} -ss 00:00:20 -f image2 -vframes 1 thumb.png
OR
ffmpeg -i {path/inputfile.extension} -f image2 -vf fps=fps=1 out%d.png
Result:
The first command will grab a thumbnail 20 seconds into the video
The second command will grab a thumbnail every second and output sequential png files (you can change fps=fps=1 to 1/60, 1/600, etc. to generate thumbnails every minute, 10 minutes, etc.)
Case:
I’m an archivist who wants to extract metadata and automatically populate fields in a metadata schema...
Solution: Use ffprobe to produce the specifications you need, define the output schema (in this case, xml), what specific properties you want listed, and finally the name of the input file and report file desired.
Command:
ffprobe -v quiet -pretty -print_format json -show_format -show_streams "{inputfilename}" > "{reportfilename}"
Result:
A report detailing information related to the file format and streams in JSON.
Case:
I’m an archivist who wants to create a clip from an existing video file without changing any characteristics of the file other than duration...
Command:
ffmpeg -i {inputfile.extension} -ss 00:00:00.00 -t ## -vcodec copy -acodec copy {outputfile.extension}
Case:
I'm an archivist who wants to play a video
Solution: Use ffplay, an FFmpeg tool, to play your video
Command:
ffplay {file input name/.extension}