Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Always make sure that you have the latest version installed
- ffmpeg.zeranoe.com
- STANDARD VIDEO ENCODE
- ffmpeg -i input.file -ss 00:00:10.000 -to 00:00:20.000 -c:v libvpx -crf 4 -vf scale=640:-1 output.file
- Merging audio
- video.file -i audio.file -c:v copy/libvpx -c:a copy/libvorbis -strict experimental output.file
- Extracting/converting audio
- input.file output.file
- Extracting and/or converting into multiple different formats
- input.file output.file1 output.file2 output.file3 etc
- Using image instead of video
- -loop 1 -i image.file -i audio.file output.file
- OVERLAY
- One overlay:
- -filter_complex "[0:v][1:v] overlay=x:y:enable='between(t,0,20)'"
- [0:v] refers to the first video stream (or the first input file) [1:v] refers to the second video stream (or the second input file) that is used as the overlay.
- overlay=x:y means that the overlay will be placed y pixels down and x pixels to the right from the top left corner that is 0:0.
- enable='between(t,0,20)' means that the overlay will be placed between 0 and 20 seconds, remove to make the overlay present from start to finish
- Multiple overlays:
- -filter_complex -"[0:v][1:v] overlay=x:y:enable='between(t,0,20)' [tmp]; [tmp][2:v] overlay=x:y:enable='between(t,0,20)' [tmp]; [tmp][3:v] overlay=x:y:enable='between(t,0,20)'"
- [tmp] is a temporary output file that you then need to specify as the source (instead of [0:v]) or else ffmpeg will ignore the subsequent commands leading to only one overlay present in output file
- HARDCODE SUBTITLES INTO VIDEO
- Image based:
- input.file -filter_complex "[0:v][0:s(:#)]overlay[v]" -map "[v]" -map 0:a output.file
- change # according to which subtitle you want. 0 is first subtitle stream, 1 is the second. etc.
- Ass sub external:
- input.file -vf subtitles=sub.file output.file
- Ass sub internal:
- input.file -vf subtitles=input.file output.file (add :si=1 for second stream)
- Can only hardcode .ass subtitles
- Converting to ass
- sub.srt sub.ass
- Change subtitle color and font
- input.file subtitles=sub.srt:force_style='FontName=DejaVu Serif,PrimaryColour=&HAA00FF00' output.file
- Extracting subtitle from video
- input.file -an -vn -c:s:0 subfile sub.subfile
- remember to hardcode video before changing resolution
- MERGE VIDEO
- Vertically merge:
- -i input1.file (top) -i input2.file (bottom) -filter_complex vstack output.file
- Horizontally merge:
- -i input1.file (left) -i input2.file (right) -filter_complex hstack output.file
- note:when stacking vertically/horizontally quality of video might degrade
- Splice video:
- -i input1.file -i input2.file -filter_complex "[0:v:0] [1:v:0] concat=n=2:v=1 [v]" -map "[v]" output.file
- Splice video with audio:
- -i input1.file -i input2.file "[0:v:0] [0:a:0] [1:v:0] [1:a:0] concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" output.file
- Splice multiple videos
- -f concat -i textfile.file -fflags +genpts output.file
- note: textfile should have multiple lines looking like this:
- file 1.mp4
- file 2.mp4
- file 3.mp4
- file 4.mp4
- (mp4 can be changed to other video formats)
- FILTERS
- -ss (start of video)
- -to (end of video)
- -c:v (video codec)
- -c:a (audio codec)
- -b:v [enter number followed by K (Kilobit) or M (Megabit)] (video bitrate)
- -b:a [cannot be set lower than 50k] (audio bitrate)
- -vf scale=height:width [-1 on either side to scale resolution to corresponding height/width] (change resolution)
- -auto-alt-ref [0/1] (disables/enables alternate reference frames)
- OPTIONAL
- -y (automatically replace duplicate file)
- -threads # (number of threads used)
- -metadata title="title" (embedding title to video)
- -an (disable audio)
- -sn (disable subtitles)
- -vn (disable video)
- -r (framerate (not recommended))
- -aq 5 [higher is better] (constant audio quality)
- -crf [4-63 lower is better (0 for lossless)] (constant video quality)
- -bufsize (for more accurate average bitrate)
- -minrate (sets minimum video bitrate (useless))
- -maxrate (sets maximum video bitrate, used in conjunction with -bufsize)
- -acodec [can be used instead of -c:a] (audio codec)
- -vcodec [can be used instead of -c:v] (video codec)
- -movflags +faststart (will make the video play before completely dl'd by browser (only for browser viewing))
- -stream_loop -1 (loops video)
- -loop 1 (loops image (not gif))
- OTHER FILTERS
- -strict experimental
- -filter_complex
- -vf=video filter
- -af=audio filter
- AUDIO CODECS
- libvorbis (.ogg, low quality)
- libfaac (.aac)
- libmp3lame (.mp3)
- libopus (.ogg, high quality, does not support quality based commands)
- VIDEO CODECS
- libvpx
- libx264
- COMMANDS
- -formats (lists all supported formats)
- -codecs (lists all supported codecs)
- -filters (lists all supported filters)
- -help (lists commands)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement