FFmpeg Video Editing

Querying Available Codecs and Formats

ffmpeg -codecs
ffmpeg -formats

Extracting Streams

ffmpeg -i [INPUT] [-map 0:1 -map 0:2] -c:a [AUDIO CODEC] -c:v [VIDEO CODEC] 01_1.mkv

Cutting

ffmpeg -ss [TIME_START] -i [FILE] -ss [+TIME_START] -t [TIME_DURATION] -c copy [OUTPUT]

or

ffmpeg -i [FILE] -ss [TIME_START] -to [TIME_END] -c copy [OUTPUT]

Adding Subtitles

Add Subtitle with

ffmpeg -i [VIDEO_FILE] -vf subtitles=[.ASS_FILE] -c:a copy [OUTPUT]

.ass format example:

[Script Info]
Title: [TITLE]
Original Script: RoRo
Script Updated By: version 2.8.01
ScriptType: v4.00+
Collisions: Normal
PlayResY: 600
PlayDepth: 0
Timer: 100,0000
Video Aspect Ratio: 0
Video Zoom: 6
Video Position: 0

[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: DefaultVCD, Arial,28,&H00B4FCFC,&H00B4FCFC,&H00000008,&H80000008,-1,0,0,0,100,100,0.00,0.00,1,1.00,2.00,2,30,30,30,0

[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:01.18,0:00:06.85,DefaultVCD, NTP,0000,0000,0000,,{\pos(400,570)}The first line\NThe second line in subtitle

Downsampling FLAC

For instance,

ffmpeg -i input.flac -af "aresample=44100:resampler=soxr:precision=33:osf=s16:dither_method=shibata" -acodec flac output.m4a