FFmpeg Grundlagen

Inhaltsübersicht

  • Einführung
  • Umpacken
  • Transcodieren
  • Bildformat ändern
  • A/V trennen
  • Ausschnitte

FFmpeg? Wosisdes?

Das FFmpeg-Projekt besteht aus einer Reihe von freien Computerprogrammen und Programmbibliotheken, die digitales Video- und Audiomaterial aufnehmen, konvertieren, senden (streamen) und in verschiedene Containerformate verpacken können.

Unter anderem enthält es mit libavcodec eine umfangreiche Sammlung von Audio- und Videocodecs.

 

Quelle: Wikipedia: FFmpeg

Wo kriegt man's her?

...vom Bio-Bauernmarkt.

Digital Video Trinity

Basis Syntax

ffmpeg [-y] -i INPUT_FILE [PARAMETER] [-f FORMAT] OUTPUT_FILE

FFmpeg, was kannst Du?

  • Liste Container: -formats
    File formats:
      D. = Demuxing supported
      .E = Muxing supported
    			
  • Liste Codecs: -codecs / -encoder / -decoder
    Codecs:
      D..... = Decoding supported
      .E.... = Encoding supported
      ..V... = Video codec
      ..A... = Audio codec
      ..S... = Subtitle codec
      ...I.. = Intra frame-only codec
      ....L. = Lossy compression
      .....S = Lossless compression
    			

Umpacken

ffmpeg -i INPUT_FILE -c copy OUTPUT_FILE

Ergebnis prüfen

ffprobe -i INPUT_FILE

ffprobe -i INPUT_FILE [-show_format] [-show_streams] [-of ...] [-pretty]

 

FFprobe Dokumentation

A/V separat

  • Video 'None': -vn
  • Audio 'None': -an

Codec

  • Videocodec: -c:v CODEC
  • Audiocodec: -c:a CODEC
  • A + V 1:1 kopieren: -c copy

Transcodieren

ffmpeg -i INPUT_FILE -c:v ffv1 -c:a pcm_s24le OUTPUT_FILE

ffmpeg -i INPUT_FILE -c:v ffv1 -c:a pcm_s16le OUTPUT_FILE

Video 1

  • Auflösung: -s WIDTHxHEIGHT
  • Seitenverhältnis: -aspect X:Y
  • Framerate: -r FPS

Bildformat ändern

ffmpeg -i INPUT_FILE -an -c:v ffv1 -s 720x576 OUTPUT_FILE

ffmpeg -i INPUT_FILE -an -c:v ffv1 -aspect 4:3 OUTPUT_FILE

ffmpeg -i INPUT_FILE -an -c:v ffv1 -r 30000/1001 OUTPUT_FILE

Video 2

  • Farbmodell/tiefe: -pix_fmt FORMAT

pix_fmt?

  • yuv422p = YUV 4:2:2 planar
  • yuv420p

  • yuv422p10le
  • yuv420p10le

  • yuva422p

  • Keep-or-die: -pix_fmt +

 

Liste: -pix_fmts

Subsampling ändern

ffmpeg -i INPUT_FILE -c:v ffv1 -pix_fmt yuv422p OUTPUT_FILE

(Achtung: re-encoding)

Audio

  • Audiocodec: -c:a CODEC
  • Samplerate: -ar SAMPLERATE
  • Kanäle: -ac CHANNELS
  • Bitrate: -b:a BITRATE{k,M}

A/V separat

  • Nur Bild (Original):
    ffmpeg -i INPUT_FILE -an -c:v copy OUTPUT_FILE
  • Nur Ton (Original):
    ffmpeg -i INPUT_FILE -vn -c:v copy OUTPUT_FILE
  • Nur Ton (MP3):
    ffmpeg -i INPUT_FILE -vn -c:a mp3 -b:a 128k out.mp3
  • Nur Ton (FLAC):
    ffmpeg -i INPUT_FILE -vn -c:a flac out.flac

Video 3

  • Bitrate: -b:v BITRATE{k,M}
  • Bitrate (min): -minrate BITRATE
  • Bitrate (max): -maxrate BITRATE
  • GOP size: -g FRAMES

Video Ausschnitte

  • Startposition: -ss DURATION
  • Rückwärts: -sseof DURATION
  • Länge: -t DURATION

 

DURATION:
Timecode: [-][HH:]MM:SS[.m]
oder
Sekunden: [-]S[.m]

Video Ausschnitte

  • Start Offset:
    ffmpeg -ss DURATION -i INPUT_FILE -c copy OUTPUT_FILE
  • Nur Anfang:
    ffmpeg -t DURATION -i INPUT_FILE -c copy OUTPUT_FILE
  • Offset + Länge:
    ffmpeg -ss DURATION -t DURATION -i INPUT_FILE -c copy OUTPUT_FILE

Transcoding II

FFV1

FFV1, which stands for "FF video codec 1", is a lossless intra-frame video codec.

 

  • Codec: -c:v ffv1
  • Version: -level {1,3}
  • Coder: -coder {0=golomb,1=range}
  • Context: -context {0=small,1=large}
  • Slices: -slices {4,6,9,12,16,24,..}
  • CRC: -slicecrc {0,1}

 

Quellen: Wikipedia: FFV1, ffv1.info

FFV1

ffmpeg -i INPUT_FILE -an -c:v ffv1 -level 3 -slices 24 -slicecrc 1

ProRes

"Apple ProRes is a lossy video compression format developed by Apple Inc. for use in post-production"

 

  • Codec: -c:v {prores,prores_aw,prores_ks}
  • Profiles: -profile:v {proxy,lt,standard,hq,4444,4444xq}

 

Quellen/Links: Wikipedia: Apple ProRes, FFmpeg docs, Kieran Kunya's Blog, FinalCut docs

ProRes

ffmpeg -i INPUT_FILE -an -c:v prores_ks -profile:v hq

H.264

"x264 H.264/MPEG-4 AVC encoder wrapper. [...]
libx264 supports an impressive number of features, [...]"

 

  • Codec: -c:v libx264
  • Bitrate: -b:v BITRATE{k,M}
  • CRF: -crf 0 (lossless) - 51 (worst)
  • Presets: -preset:v {ultrafast,superfast,veryfast,faster,fast,medium(*),slow,slower,veryslow}
  • Feintuning: -tune {film,animation,grain,...}

 

Quellen/Links: FFmpeg Wiki, FFmpeg docs

H.264

ffmpeg -i INPUT_FILE -an -c:v libx264 -preset:v superfast -crf 22

XDCAM HD422

Ist gar kein eigener Codec
sondern ein MPEG-2/PCM Profil.

 

Links: Wikipedia: XDCAM formats

XDCam HD422

Mit "ffmbc"

		
ffmbc -threads 4 -i test.mov -s 1920x1080 -tff -target xdcamhd422 \
-acodec pcm_s24le -ar 48000 -f mxf out1.mxf \
-acodec pcm_s24le -ar 48000 -newaudio \
-map_audio_channel 0:1:0:0:1:0 -map_audio_channel 0:1:1:0:2:0
		
	

	

Links

License and Credits

Der Text dieser Präsentation steht unter einer freien Lizenz zur Verfügung:

Creative Commons "Attribution-ShareAlike"
(CC-BY-SA)

Peter Bubestinger-Steindl
(p.bubestinger@av-rd.com)