m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/ffmpeg.md
diff options
context:
space:
mode:
Diffstat (limited to 'ffmpeg.md')
-rw-r--r--ffmpeg.md56
1 files changed, 54 insertions, 2 deletions
diff --git a/ffmpeg.md b/ffmpeg.md
index 7495cb0..40b6ae7 100644
--- a/ffmpeg.md
+++ b/ffmpeg.md
@@ -1,16 +1,46 @@
# ffmpeg tricks
+## Convert
+
+Works for audio, too.
+
+ ffmpeg -i in.EXT1 out.EXT2
+
## Cut
ffmpeg -i in.mp4 -codec:v copy -codec:a copy -ss START_TIME -t DURATION out.mp4
ffmpeg -ss START_TIME -t DURATION -i in.mp4 -codec:v copy -codec:a copy out.mp4
-## Resize
+## Quality
+
+### Resize
ffmpeg -i in.mp4 -s 720x480 out.mp4
# -1 means to automatically preserve aspect ratio
ffmpeg -i in.mp4 -filter:v scale=720:-1 out.mp4
+### Bitrate
+
+* `-b:a 192k`: specify audio bitrate to 192 kbps
+* `-b:v 2M`: specify video bitrate to 2 mbps
+
+### Encoding
+
+H.265 is one of the top recommended formats, for size:quality ratio.
+
+ ffmpeg -i in.mp4 -vcodec libx265 -crf <value> out.mp4
+
+Reasonable `crf` values could be 24 to 30.
+
+## Audio/video delay
+
+ ffmpeg -i "$input" -itsoffset <offset in seconds> -i "$input" -map 1:v -map 0:a -c:a copy -c:v libx264 "$output"
+
+For reverse offset, swap 1 and 0.
+
+Basically, take the input once with an offset, once without. Take the audio from
+one of them, video from the other.
+
## Rotate
# 90 degrees clockwise
@@ -39,7 +69,21 @@ For the transpose parameter you can pass:
## Concatanate audio
- ffmpet -i in1.mp3 -i in2.mp3 -i in3.mp3 -filter_complex '[0:0][1:0][2:0]concat=n=3:v=0:a=1' output.mp3
+ ffmpeg -i in1.mp3 -i in2.mp3 -i in3.mp3 -filter_complex '[0:0][1:0][2:0]concat=n=3:v=0:a=1' output.mp3
+
+## Concatanate videos
+
+Works well especially for large number.
+
+Create file `list.txt`
+
+ file 'video1.mp4'
+ file 'video2.mp4'
+ ...
+
+Then
+
+ ffmpeg -f concat -i list.txt -c copy combined.mp4
## Fitlering
@@ -52,3 +96,11 @@ For the transpose parameter you can pass:
[in1] ... [ink] filter_name=option1=val1:...:optionn=valn [out1] ... [outm]
* Use `-filter_complex` if more than one input or output stream.
+
+## Video file info
+
+Just running
+
+ ffmpeg -i video.mp4
+
+will fail, but give a bunch of info about the file (including resolution, fps, etc)