Streaming video in real time (which is cool, cause you can pass this to f in matcherservice and indexer-service
Scaling, width: 1/2, height scaled accordingly to preserve aspect ratio
Add black pads on margin
Convert to 1080p
Add logo
Increase contrast by 25%(https://ffmpeg.org/ffmpeg-filters.html#eq)
Change video bit rate to 200K
Change frame rate to 10 frames per second
Cut 19 seconds of video and audio from cbs_1b_watch.mxf
Figure out # of frames in video
General information about a file
Draw Box(https://ffmpeg.org/ffmpeg-filters.html#drawbox)
Convert HLS to MP4
Splice
Get Every Frame of a Video
// read frames from movie saving to jpeg
ffmpeg -i file.mpg -r 1/1 $filename%03d.jpg
Get Only One Frame
// extract one frame, starting at second 20, get one frame
ffmpeg -i 1.1Burger_King.mp4 -ss 00:00:20.000 -vframes 1 out.png
Crop out 10%
Pixelation
ffmpeg -i input -qscale # output
Where # = 0 preserves the quality of the input video, and the higher the number the more pixilation (noticeable at >15-20)
Closed Captions / Subtitles
(text only)
ffmpeg -i input -vf subtitles=subfile output
(text with black box border outline)
ffmpeg -i input -vf subtitles=subfile:force_style='BorderStyle=3' output
Where subfile = .srt format subtitle file.
Rotate Video
ffmpeg -i input -vf transpose=# output
Where # = 0,1,2,3 for Vertical Flip, 90 degrees Clockwise, 90 degrees Counterclockwise, 90 degrees Clockwise + Vertical Flip.
Adjust Volume
(1/10x)
ffmpeg -i input -af "volume=0.1" output
(10x)
ffmpeg -i input -af "volume=10" output
Picture in Picture
(Top Right Corner)
ffmpeg -i input -r 29.97 -vf "movie=small, scale=212:120 [vid2]; [in][vid2] overlay=main_w-overlay_w-10:10" output
Where small = the smaller embedded video.
The following PIP is a working example using chain of filters.
// Scale ad.mp4 by half, and overlay it on top of main.mp4, overlaid at middle of main.mp4
ffmpeg -i main.mp4 -i ad.mp4 -filter_complex "[1]scale=iw/2:ih/2 [pip]; [0][pip] overlay=main_w/2:main_h/2" pip_output.mp4
Adjust Brightness
(darker, val * (< 1))
ffmpeg -i input -vf "lutyuv=val*0.5" output
(brighter, val * (> 1))
ffmpeg -i input -vf "lutyuv=val*2" output
Splicing Video
ffmpeg -i input.wmv -ss 00:00:30.0 -c copy -t 00:00:10.0 output.wmv
ffmpeg -i input.wmv -ss 30 -c copy -t 10 output.wmv
Simulate sending frames (and then playing them back) over a TCP port
Correct Timestamps
Get Number of Frames From Video File
Install imagemagick
required for 'convert' and 'display' commands used below.
Convert between Raw Y bytes files and other common image formats
Display raw y frame
Or you can always set the output file on a convert command to "x:" which will display instead of save:
Add Frame number or timecode to any video
Requires ffmpeg --with-freetype
ffmpeg -i test2.mov -vf "drawtext=fontfile=Arial.ttf: text=%{n}: x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000099" -y output.mov
On Linux you need to specify the whole font path: /usr/share/fonts/truetype/msttcorefonts/Arial.ttf
ffmpeg -i TimeCode.mov -r 30 -vf "[in]setpts=0.7992*PTS[middle1];[middle1]scale=960:540[middle] ; [middle]drawtext=fontfile=/Library/Fonts/Arial\ Narrow\ Bold.ttf: text='':timecode='00\:00\:00\:00':r=30: fontcolor=white: fontsize=35: x=750: y=430[out]" -filter:a "atempo=1.25125125125" TimeCode540p.mp4
This one takes every .mp4 file in a directory and rescales it to 1920x1080, and adds a frame counter on the top and bottom left. (Two counters to detect possible tearing artefacts while rendering from ffplay)
for i in `ls *.mp4` ; do ffmpeg -i ${i} -vf "[in]scale=1920:1080[middle];[middle]drawtext=fontfile=/Library/Fonts/Arial.ttf: text=%{n}: x=lh/2: y=h-(3*lh/2): fontcolor=white: box=1: boxborderw=4: boxcolor=0x000000ff: fontsize=32[middle2];[middle2]drawtext=fontfile=/Library/Fonts/Arial.ttf: text=%{n}: x=lh/2: y=lh/2: fontcolor=white: box=1: boxborderw=4: boxcolor=0x000000ff: fontsize=32[out]" -y 1080p/${i} ; done
Rename captures frames without timecode
This renames all files with names like frame213-143920102.y to frame213.y.
Linux (Ubuntu) installation instructions
The instructions on this page will allow you to compile ffmpeg from source on Ubuntu, Debian, or Mint, including many important libraries.