This website is released under |
Used FFmpeg CommandsBasics# 0. Set the desktop as working space # # In order to find the generated files easier. # * on macOS and Linux: cd ~/Desktop # * on Windows: cd Desktop # Generate the working files # 1. The Mandelbrot pattern is a fractal curve that allows to notice errors # quickly. This gives an image file. # # Parameters: # -f uses lafvi, FFmpeg’s virtual input device # -i choses the Mandelbrot pattern as input «file» # -t duration in seconds # -pix_fmt choses the YUV 4:2:0 planar pixel encoding [Y’CBCR would be the # accurate writing] # path, name and extension of the output file [no -o is needed] ffmpeg -f lavfi -i mandelbrot -t 10 -pix_fmt yuv420p mandelbrot.mov # 2. The musical note A (aka 440 Hz) gives a sound file. # # Parameters: # -f uses lavfi, FFmpeg’s virtual input device # -i evaluates a sinus function # -t duration in seconds # path, name and extension of the output file [no -o is needed] ffmpeg -f lavfi -i aevalsrc="sin(440*2*PI*t)" -t 10 A.wav # 3. Join the generated image and the sound files # # Parameters: # -i path, name and extension of the first input file # -i path, name and extension of the second input file # path, name and extension of the output file [no -o is needed] ffmpeg -i mandelbrot.mov -i A.wav mandelaaa.mov # 4. Extract the technical metadata # # Parameters: # -show_format shows the container’s metadata # -show_streams shows the codec’s metadata # -print_format choses the output format ffprobe mandelbrot.mov ffprobe -show_format mandelbrot.mov ffprobe -show_streams mandelbrot.mov ffprobe -show_format -show_streams mandelbrot.mov ffprobe -show_format -show_streams -print_format flat mandelbrot.mov ffprobe -show_format -show_streams -print_format json mandelbrot.mov ffprobe -show_format -show_streams -print_format xml mandelbrot.mov # See also: avpres.net/FFmpeg/probe_json # 5. Transform the container # # Consists on demultiplex the container given as input, copy the data # without decoding and encoding, and multiplex into the output container. # # Parameters: # -c in this example we chose to copy the codec ffmpeg -i mandelbrot.mov -c copy mandelbrot.avi # 6. MD5 hash values for each frame in the video stream # # Parameters: # -f library framemd5 is used to calculate the MD5 checksum ffmpeg -i mandelbrot.mov -f framemd5 mandelbrot_mov_frames.md5 ffmpeg -i mandelbrot.avi -f framemd5 mandelbrot_avi_frames.md5 Transformations# NOTE: The backward slash \ escapes the newline. This way you can split
# a command into more lines for readability.
# 7. Make a mezzanine file ProRes 422 HQ from the conservation files TIFF.
#
# Parameters:
# -f image2 forces the image file de-muxer for single image files
# NOTE: this parameter must be before the input file
# -i path, name and extension of the first input file
# The regex %06d matches six digits long numbers, possibly with
# leading zeroes. This allows to read in ascending order, one
# image after the other, the full sequence inside one folder.
# The command must of course match the naming convention
# actually used.
# -c:v we chose the ProRes codec
# -profile:v the video profile 3 is for HQ
# -filter:v we filter the video stream:
# - scaling to the correct size
# [we use the Lanczos scaling algorithm which is slower but
# better than the default bilinear algorithm]
# - padding the 4:3 format into the HD format with pillar-box
ffmpeg \
-f image2 \
-i DUFAY_TIFF/Dufay_%06d.tif \
-c:v prores \
-profile:v 3 \
-filter:v "scale=1440:1080:flags=lanczos, pad=1920:1080:240:0" \
-an \
Dufay_ProRes.mov
# See also: avpres.net/FFmpeg/sq_ProRes
# 8. Make an access file H.264 directly form the conservation files TIFF.
#
# Parameters:
# -c:v we chose the libx264 codec
# -preset we chose veryslow which gives the best result
# -qp a quantisation parameter of 18 means «visually lossless»
ffmpeg \
-f image2 \
-i DUFAY_TIFF/Dufay_%06d.tif \
-c:v libx264 \
-preset veryslow \
-qp 18 \
-filter:v "scale=1440:1080:flags=lanczos, pad=1920:1080:240:0" \
-pix_fmt yuv420p \
-an \
Dufay_H264_1.mp4
# See also: avpres.net/FFmpeg/sq_H264
# 9. Make an access file H.264 from the mezzanine file ProRes 422 HQ.
ffmpeg \
-i Dufay_ProRes.mov \
-c:v libx264 \
-preset veryslow \
-qp 18 \
-pix_fmt yuv420p \
-an \
Dufay_H264_2.mp4
# See also: avpres.net/FFmpeg/im_H264
Advanced# 10. Difference file
ffmpeg \
-i Dufay_H264_1.mp4 \
-i Dufay_H264_2.mp4 \
-filter_complex \
"[1]format=yuva444p, \
lut=c3=128, \
negate[1_with_alpha_channel]; \
[0][1_with_alpha_channel]overlay" \
Dufay_H264_delta.mp4
# See also: avpres.net/FFmpeg/delta
# 11. Split screen
ffmpeg \
-i Dufay_H264_1.mp4 \
-i Dufay_H264_2.mp4 \
-filter_complex \
"[0]crop=iw/2:ih:0:0, \
pad=iw*2:ih*1[left]; \
[1]crop=iw/2:ih:iw/2:0[right]; \
[left][right]overlay=w" \
Dufay_H264_split.mp4
# See also: avpres.net/FFmpeg/split
Exercises
2017-10-09 |