Inhaltsverzeichnis

ffmpeg

Video transcodieren (Auflösung und Dateigröße kleiner machen)

mit h264

ffmpeg -i video_1920x1080.mp4 -vf scale=-1:720 -c:v libx264 -crf 18 -preset veryslow -c:a copy video_1280x720.mp4

HEVC, h265 2pass-Kodierung

ffmpeg -y -i input.mp4 -c:v libx265 -b:v 2600k -x265-params pass=1 -an -f null /dev/null && \
ffmpeg -i input.mp4 -c:v libx265 -b:v 2600k -x265-params pass=2 -c:a copy output.mp4

libaom AV1 2 pass-Kodierung

Leider ist die AV1-Kodierung auf einem Standard-Notebook oder Office-PCs unglaublich langsam und daher unrealistisch (Stand 01/2023). Ohne effektive GraKa kommt man danicht weiter.

ffmpeg -i input.mp4 -c:v libaom-av1 -b:v 2M -pass 1 -an -f null /dev/null && \
ffmpeg -i input.mp4 -c:v libaom-av1 -b:v 2M -pass 2 -c:a libopus output.mkv

unter Windows

ffmpeg.exe -i input.mp4 -c:v libaom-av1 -b:v 2M -pass 1 -an -f null NUL && 
ffmpeg.exe -i input.mp4 -c:v libaom-av1 -b:v 2M -pass 2 -c:a libopus output.mkv 

video/audio-delay korrigieren

Fall 1: audio beginnt vor video (150 ms = 0.15 s)

ffmpeg -i video.mp4 -itsoffset 0.150 -i video.mp4 -c:v copy -c:a copy -map 0:0 -map 1:1 video_insync.mp4

Fall 2: video beginnt vor audio (150 ms = 0.15 s)

ffmpeg -i video.mp4 -itsoffset 0.150 -i video.mp4 -c:v copy -c:a copy -map 0:1 -map 1:0 video_insync.mp4

videos zusammenführen (concatenate)

ffmpeg -f concat -safe 0 -i liste.txt -c copy OUT.mp4

wobei liste.txt unter Windows

liste.txt
file 'd:/videos/t1.mp4'
file 'd:/videos/t2.mp4'

video schneiden

ffmpeg -i in.mp4 -ss [start] -t [dauer] -c copy out.mp4

oder

ffmpeg -i in.mp4 -ss [start] -to [bis-zum-zeitpunkt] -c copy out.mp4

audio file einem video hinzufügen

ffmpeg -i IN-video-mit-EN-tonspur.mp4 \
-i audio-DE.m4a \
-c copy \
-map 0:v:0 \
-map 0:a:0 \
-map 1:a:0 \
-metadata:s:a:0 language=eng \
-metadata:s:a:1 language=deu \
OUT-video-EN-DE.mp4

Das mapping: Datei 0 ist das Video, Datei 1 die deutsche Audiospur und schreibt die Metadaten der Sprache mit hinein, damit man bei switchen im Video die entsprechende Tonspur angezeigt bekommt

videoformate 16:9

Recommended width and height for videos with 16:9 aspect ratios:

Best Choice:     2nd Best:        3rd Best:
Multiples of 16  Multiples of 8   Multiples of 4
1920 x 1080      1792 x 1008      1856 x 1044
1280 x 720       1152 x 648       1216 x 684
1024 x 576        896 x 504       1088 x 612
 768 x 432        640 x 360        960 x 540
 512 x 288        384 x 216        832 x 468
 256 x 144        128 x 72         704 x 396
                                   576 x 324
                                   448 x 252
                                   320 x 180
                                   192 x 108

Transkodieren mit allen Streams

entscheidend ist -map 0, das alle streams einbindet

ffmpeg -i input.mkv -c copy -map 0 output.mp4

oder mit h264 transcode-Einstellungen

ffmpeg \
-analyzeduration 100M -probesize 100M \
-i input.mkv \
-map 0 \
-codec:v libx264 -crf 21 \
-codec:a aac -b:a 384k \
-codec:s copy \
output.mp4

Untertitel einbinden


ffmpeg -i infile.mp4 -i infile.srt -c copy -c:s mov_text outfile.mp4