This page intentionally left blank. ⬇️, ➡️, or spacebar 🛰 to start slidedeck. --- class: middle, center .center[![ffmpeg](/img/ffmpeg.png)] # Art with FFmpeg --- # Art with FFmpeg? Well, maybe not art. But here are some ways to manipulate or create interesting video files. --- # Fuzzing Fuzzing or fuzz testing is an automated software testing technique that involves providing invalid, unexpected, or random data as inputs to a computer program. [source](https://en.wikipedia.org/wiki/Fuzzing) --- # Noise Random damage can be assigned to video and audio streams using the ["noise" bitstream filter](http://ffmpeg.org/ffmpeg-bitstream-filters.html#noise). This is good for making "bad" test video files to push your player or quality analysis to its limits, especially if you repeat the noise generation in multiple sweeps. Here's an example of mixing things up: `ffmpeg -i input.mp4 -codec:v huffyuv -bsf:v noise -codec:a copy noise.mkv` --- # More Noise `ffmpeg -i new_file.mov -bsf noise -map 0 -c copy fuzzed.mov` is the basic script for adding some noise. Play around with containers and codecs to learn how different errors manifest themselves. If you want MORE, you can simply up the noise filter (default is 1), like this: `ffmpeg -i new_file.mov -bsf noise=80 -map 0 -c copy fuzzed.mov` .center[![ffmpeg](/img/smpte-fuzzed2.png)] --- # Random "TV" noise ``` ffmpeg -f lavfi -i nullsrc=s=1280x720 -filter_complex \ "geq=random(1)*255:128:128;aevalsrc=-2+random(0)" \ -t 5 output.mkv ``` .center[![ffmpeg](/img/noise.gif)] [source](https://stackoverflow.com/questions/15792105/simulating-tv-noise) --- # Random "TV" noise in color (Mac only) ``` ffmpeg -f rawvideo -video_size 1280x720 -pixel_format yuv420p -framerate 25 \ -i /dev/urandom -ar 48000 -ac 2 -f s16le -i /dev/urandom -codec:a copy \ -t 5 output.mkv ``` .center[![ffmpeg](/img/noise-color.gif)] [source](https://stackoverflow.com/questions/15792105/simulating-tv-noise) --- # Force pixel format 1. Make a file: `ffmpeg -f lavfi -i smptebars=size=720x576:rate=25 -f lavfi -i "sine=frequency=1000:sample_rate=48000" -c:a pcm_s16le -t 10 -c:v ffv1 new_file.mkv` 2. Probe it! `ffmpeg -i new_file.mkv` This one should be set to `yuv420p(progressive)` 3. Pick a filter! `ffmpeg -pix_fmts` Watch out -- there are a lot! 4. Re-re-remix! `ffmpeg -loglevel error -i new_file.mkv -f rawvideo - | ffmpeg -y -f rawvideo -framerate 25 -video_size 1280x720 -pixel_format yuv420p16le -i - -pix_fmt yuv420p wild_video.mkv` 5. See next slide for results. [source](https://stackoverflow.com/questions/15792105/simulating-tv-noise) --- # Force pixel format The previous should turn regular SMPTE bars into this: ![ffmpeg](/img/pixel-format.gif) --- # Slit-scan .center[![ffmpeg](/img/slitscan.png)] [source](http://oioiiooixiii.blogspot.com/2017/11/ffmpeg-temporal-slice-stacking-effect.html) --- # Rainbow trail! .center[![ffmpeg](/img/rainbow.png)] [source](http://oioiiooixiii.blogspot.com/2017/09/ffmpeg-rainbow-trail-chromakey-effect.html) --- # Life .center[![ffmpeg](/img/life.gif)] *Conway's Game of Life* --- # Life Play it: ``` ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800 ``` Save it: ``` ffmpeg -f lavfi -i life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800 -t 5 output.mkv ``` \* Do you see the difference in parameters between `ffplay` and `ffmpeg`? `ffmpeg` requires the `-i` flag for input and can add the `-t 5` (for time) and `output.mkv` to save the video, while ffplay just streams the video. [documentation](https://ffmpeg.org/ffmpeg-filters.html#life) --- # Video countdown `ffplay -f lavfi "color=s=2x2:r=1:d=10,format=gray,geq=lum=9-N,datascope=s=24x12,crop=6:12:10:0,scale=iw*30:ih*30:flags=neighbor,pad=720:480:(720-iw)/2:(480-ih)/2"` .center[![ffmpeg](/img/countdown.gif)] [source](https://twitter.com/dericed/status/935660022289387523) --- # Additional Resources - [oioiiooixiii blog](http://oioiiooixiii.blogspot.com/) --- # Learning more - [FFmpeg](/presentations/ffmpeg.html) - [FFplay](/presentations/ffplay.html) - [FFprobe](/presentations/ffprobe.html) - [FFmpeg & Preservation](/presentations/ffmpeg-preservation.html) [Home](/)