Introduction to FFmpeg Dave Rodriguez FSU Office of






![But can’t I do that in…[insert commercial software]? • First, short answer: Yes, probably But can’t I do that in…[insert commercial software]? • First, short answer: Yes, probably](https://slidetodoc.com/presentation_image_h2/04fe51090df670add5a99c9c9555f612/image-7.jpg)

















- Slides: 24
Introduction to FFmpeg Dave Rodriguez FSU Office of Digital Research and Scholarship March 29, 2018
Goals of this session • Understand what FFmpeg is and why it’s valuable to know how to use it at the command-line • Understand the structure and syntax of FFmpeg commands • Introduce a variety of basic, useful commands that utilize different tools within FFmpeg • Introduce resources for further exploration, learning, and creative practice • To download the small folder of image and video files for this session: http: //bit. ly/2 uakei. K
What is FFmpeg? “A complete cross-platform solution to record, convert, and stream audio and video…the leading multimedia framework able to decode, encode, transcode, mux, demux, stream, filter, and play pretty much anything that humans and machines have created. ”
What is FFmpeg? • Open-source toolbox for manipulating audio-visual files • Launched in 2000 by Fabrice Bellard • Updated ~4 times per year • Uses a variety of tools and libraries to do its work • Found in the “guts” of countless GUI applications including VLC, Audacity, Blender, You. Tube, Handbrake, and Google Chrome • Can be operated autonomously at the command line
Graphical User Interface (GUI) vs. Command Line Interface (CLI)
What is FFmpeg? (cont. ) • Three basic tools (these will also be prompts used in every command!): • ffmpeg (media conversion) • ffplay (media player) • ffprobe (media analysis) • Some things you can do… • Make copies & derivatives • Re-wrap/encode files • Edit files • Handle/inspect weird media • Parse streams from files • Reveal stream metadata • Add audio/video effects and filters • Much more!
But can’t I do that in…[insert commercial software]? • First, short answer: Yes, probably (for now) • Second, longer answer: But should you have to, AND, what if you need to do more? What if you need to access a file that is no longer supported by commercial software? • As an open-source toolbox, FFmpeg empowers communities of users and developers to work outside traditional profit-driven models of innovation
Installation • Perhaps the most difficult part! (depending on your OS) • Great guide from Ashley Blewer • Most simple way (Mac w/ Homebrew) • To download the small folder for this session: http: //bit. ly/2 uakei. K
Basic Syntax and Structure of Commands • High Level Diagram of FFmpeg Command – [Command Prompt] [Input File] [Flags/Actions] [Output File] • Example – ffmpeg -i /filepath/inputfile. ext -flag some_action /filepath/outputfile. ext See: https: //amiaopensource. github. io/ffmprovisr/index. html#basic-structure
Our 1 st command – Simple Re-Wrap = to change a file’s container (i. e. file extension) [Command Prompt] [Input File] [Flags/Actions] [Output File] ffmpeg -i new_file. mkv -c copy -map 0 new_file. avi
Our 1 st command – Simple Re-Wrap Source: Ashley Blewer
2 nd Command - Re-Wrap + Re-Encode Re-Wrap = to change a file’s container (i. e. file extension) Re-Encode = transcode; to change the files codec (below, h. 264 to Pro. Res 422 LT) [Command Prompt] [Input File] [Flags/Actions] [Output File] ffmpeg -i inputfile. ext -c: v prores -profile: v 1 -vf yadif outputfile. mov See: https: //amiaopensource. github. io/ffmprovisr/index. html#to_prores See also: Types of Apple Pro Res Codecs BONUS ROUND: ffmpeg -i inputfile. ext -c: v prores -profile: v 1 -vf yadif -c: a pcm_s 16 le outputfile. mov
3 rd Command - Demux audio or video Demux = “demultiplexer; ” separate streams in a file into individual files [Command Prompt] [Input File] [Flags/Actions] [Output File] # Extract Audio ffmpeg -i inputfile. ext -c: a copy -vn outputfile. ext # Extract Video ffmpeg -i inputfile. ext -c: v copy -an outputfile. ext See: https: //amiaopensource. github. io/ffmprovisr/index. html#extract_audio
4 th Command - Make your own test pattern FFmpeg can also create content based on technical standards in addition to transcoding, playing, etc. [Command Prompt] [Input File] [Flags/Actions] [Output File] ffmpeg -f lavfi -i testsrc=size=1920 x 1080: rate=30 -f lavfi -i sine=frequency=1000: sample_rate=48000 -c: v libx 264 -c: a aac -t 15. /mytestfile. mp 4 See: http: //training. ashleyblewer. com/presentations/ffmpeg. html#13 See also: http: //www. bogotobogo. com/FFMpeg/ffmpeg_video_test_patterns_src. php
5 th Command - Generate. GIF from still images For this to work properly, img files should be numbered and named consistently and sequentially (i. e. input_name_001, input_name_002, etc. ) [Command Prompt] [Input File] [Flags/Actions] [Output File] ffmpeg -f image 2 -framerate 4 -pattern_type glob -i “input_name_*. ext” vf scale=250 x 250 outputfile. gif See: https: //amiaopensource. github. io/ffmprovisr/index. html#img_to_gif
6 th Command - Show pixels outside broadcast range This command will use ffplay and the signalstats filter to show any pixels that are out of broadcast range [Command Prompt] [Input File] [Flags/Actions] [Output File] ffplay -i inputfile. ext -vf signalstats=out=brng: color=cyan …OR… ffplay -f lavfi “movie=‘inputfile. ext’, signalstats=out=brng: color=cyan” See (v 1): https: //github. com/privatezero/NDSR/blob/master/Demystifying_FFmpeg_Slides. pdf See also (v 2): https: //amiaopensource. github. io/ffmprovisr/#brng
7 th Command - ffprobe to create metadata report In addition to printing metadata to the stdout, we can use ffprobe to generate metadata reports and save them as separate files. In this example, a. json file. [Command Prompt] [Input File] [Flags/Actions] [Output File] ffprobe -i. inputfile. ext -show_format -show_streams -print_format json >. /metadata. json See: https: //avpres. net/FFmpeg/probe_json. html
8 th Command - Adding Timecode As written below, this variation of the code will burn in timecode in lower center of the screen [Command Prompt] [Input File] [Flags/Actions] [Output File] # First, ffprobe to confirm framerate of inputfile. ext ffprobe -show_streams inputfile. ext …OR… ffprobe inputfile. ext # Next, draw and burn in the timecode to a new video file ffmpeg -i inputfile. ext -vf drawtext="fontfile=/Library/Fonts/Apple. Gothic. ttf: fontsize=12: timecode='00\: 00': fontcolor=white: box=1: boxcolor=black: rate=30/1: x=(w-text_w)/2: y=h/1. 2" outfile. ext See: https: //amiaopensource. github. io/ffmprovisr/#burn_in_timecode
Other advanced and/or useful commands/concepts… • Batch Processing with Bash (string together commands and/or do commands on multiple files or directories!) • https: //amiaopensource. github. io/ffmprovisr/#batch_processing_bash • Perceptual Hashing (create & compare unique “fingerprints” for AV content) • https: //amiaopensource. github. io/ffmprovisr/#perceptual-similarity • https: //privatezero. github. io/weaverblog/2017/12/12/Return-to-perceptual-hashing. html • Live Stream and Record • https: //amiaopensource. github. io/ffmprovisr/#record-and-stream • Cut detection • https: //amiaopensource. github. io/ffmprovisr/#csv-ydif • ISO for DVD burning • https: //amiaopensource. github. io/ffmprovisr/#create_iso
More fun stuff! - Stacking video filters http: //oioiiooixiii. blogspot. com/2016/08/ffmpeg-recursive-effects-ofstacking. html
More fun stuff! - Creating glitch/noise effects https: //stackoverflow. com/questions/15792105/simulating-tv-noise
More fun stuff! - Rainbow Chromakey http: //oioiiooixiii. blogspot. com/2017/09/ffmpeg-rainbow-trail-chromakeyeffect. html
Resources + Works Cited • • • • The Official FFmpeg Documentation Association of Moving Image Archivists Open Source Committee's ffmprovisr Ashley Blewer’s Audiovisual Preservation Training Andrew Weaver’s Demystifying FFmpeg Ben Turkus’ FFmpeg Presentation Reto Kromer’s FFmpeg Cookbook for Archivists Great talk on FFmpeg by Carl Eugen Hoyos, one of its earliest developers, from No Time to Wait 2 (November, 2017) - Carl’s talk begins at 02: 24: 00 (~ 20 min) Wiki: Fancy Filtering Examples Ashley Blewer’s FFmpeg + Art & FFmpeg + Preservation oioiiooixiii (blog that features some great FFmpeg scripts) Media. Info (open source application; basically GUI ffprobe) QC Tools (free, open source GUI video analysis/processing) FFmpeg Projects (long list of software and apps built with the framework)
Thank You! Happy FFmpeging!