ffmpeg
**FFmpeg** is a well-known multimedia processing tool used to edit audio and video files programmatically. It can convert and transform over 100 different codecs and is integrated into many applications under the hood. It works by demuxing the input into audio and video tracks, decoding them into uncompressed data, performing transformations, then re-encoded and muxed into the requested output format. It also comes with `ffplay` and `ffprobe` to play and examine metadata from files, respectively.
I had to install the ffmpeg-full package in Homebrew to get the library dependencies I needed.
Usage
ffmpeg Flags:
-ithe input file, ex:ffmpeg -i input.mp4 output.mov-ccodec, ex:-c:v mpeg -c:a mp3specifies the MPEG video codec and MP3 for the audio-bbitrate, used to change output quality, such as-b:v 1M-rchanges the frame rate,-r 30is 30 fps-schanges the resolution,-s 640x480changes to 480p-vfthe filter graph, allowing transformations:scale=640:360eq=brightness=0.5
Instead of specifying them one by one on the command line, you can create a text with inputs:
file video1.mp4
file video2.mp4
...
You can then use options like -f concat (format = concat) with the special "copy" codec to skip the decode/filter/encode process. It can still be used for some transformations, such as with -ss (start time) and -t (duration) to cut a portion of the file. Together, this might look like:
ffmpeg -i input.mp4 -ss 00:00:30 -t 00:00:10 -c copy output.mp4
You can also use ffmpeg on subtitles, transforming .srt to .ass files and embedding them into your video using -vf.
Fix a video
The video container in these examples doesn't matter. This command basically asks ffmpeg to demux, then remux the video as is.
ffmpeg -i video.mkv -c copy video_fixed.mkv
If error detection is a roadblock, try:
ffmpeg -err_detect ignore_err -i 'input.mp4' -c copy 'input-fixed.mp4'