Codecs - Advanced

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

2021-09

Codecs - Advanced

What would you like to know?

Open topics

  • LTO generation handling
  • Bitrate:
    • CBR vs VFR vs CRF
    • Min/max, 2-pass
  • Deinterlacing

AV Properties

Revisited

Tools

  • Mediainfo
  • ffmpeg
  • ffprobe
  • VLC
  • ffmprovisr
  • RAWcooked

FFmpeg et al.

The beauty of CLI is that anything you can do on the commandline, you can fully automate and integrate into workflows the same way.

 

…and it’s like reading the book, rather than watching the movie.

Categories

  • Quality
    • FFmpeg’s “pix_fmt”
    • Changing subsampling
  • Format conversion
    • Changing container
    • Audio to PCM
    • Video to lossless (FFV1)
    • Image sequence+audio to videofile (and back)
  • Handling
    • Framemd5 / streamhash
    • Extract segment without re-encoding
  • Metadata
    • Add/edit descriptive metadata
    • Apply LUT
    • DVB: Extract subtitles + merge into new container

- QUALITY -

FFmpeg’s “pix_fmt”

$ ffmpeg -pix_fmts

Changing subsampling / bit depth

$ ffmpeg -i input_file -c:v libx264 -crf 21 -c:a copy -pix_fmt yuv422p out.mkv
$ ffmpeg -i input_file -c:v libx264 -crf 21 -c:a copy -pix_fmt yuv420p10le out.mkv

- FORMAT CONVERSION -

Changing container

$ ffmpeg -i video_in.mov -c copy \
-map 0 video_out.mkv

Audio to PCM

$ ffmpeg -i video_in.mov -c:v copy -c:a pcm_s16le \
-map 0 video_out.mkv

Video to lossless (FFV1)

$ ffmpeg -i video_in.mov -c:v ffv1 -c:a copy \
-pix_fmt + -map 0
video_out.mkv

Video file to image+audio sequence

$ ffmpeg -i XDCAM_sample.mxf \
-pix_fmt rgb24 out/reel1_%06d.dpx \
-c:a pcm_s16le out/audio.wav

…and reverse

$ ffmpeg -f image2 -r 24 -start_number 1234 \
-i out/reel1_%06d.dpx \
-i out/audio.wav \
-c:v libx264 -crf 22 \
-c:a aac -b:a 192k \
-vf scale=1920:-1 -pix_fmt yuv420p \
access_copy.mp4

- HANDLING -

framemd5

Decoded:

$ ffmpeg -i input_file.xxx -f framemd5 input_file.xxx.framemd5

Stream data as-is:

$ ffmpeg -i input_file.xxx -c copy -f framemd5 \
input_file.xxx.framemd5

streamhash

$ ffmpeg-rel -hide_banner -i amanda_excerpt.m2t \
-map 0 -c copy \
-f streamhash -hash md5 - -v quiet

Extract segment

without re-encoding

$ ffmpeg -i input_file -c copy -ss 00:01:23 -t 20 out1.mkv

- METADATA -

Add/edit metadata

$ ffmpeg -i input_file -c copy -map 0 \
-metadata title="This is the title" \
-metadata artist="The artist" \
output.mkv

Apply LUT

$ ffmpeg -i in.mxf -vf "lut1d=CanonLog3_10-to-Linear_FL_Ver.2.0.cube" \
-c:v libx264 -g 300 -pix_fmt yuv420p -crf 22 \
-c:a aac -b:a 192k \
-map 0 delme.mp4

Extract subtitles

$ ffmpeg -txt_page 777 -txt_format text -txt_duration 2000 \
-i orf2.ts -vn -an -c:s srt \
orf2_sub.srt

Extracts only the subtitles (from Teletext page 777) as formatted text (SRT).

Combine AV + Sub

$ ffmpeg -i orf2.ts -i orf2_sub.srt -c copy \
-map 0:v -map 0:a \
-map 1:s -c:s srt \
out.mkv

Copies all audio+video+subtitle streams (no transcoding) into a Matroska container: (This is useful for subtitle content and timing validation/debugging)

RAWcooked

“It’s like ZIP for film.”

 

RAWcooked is a convenient CLI frontent for converting image/audio/folder film data into FFV1/FLAC in MKV - and fully reversibly back.

RAWcooked

$ rawcooked dpx/ --check-padding -o rawcooked.mkv

Special cases

  • No container = raw data stream
    (Example: DV, ffmpeg -formats | grep raw)
  • Mid-stream changes 😱
    (Examples: MXF, DV, digital broadcast streams)
  • Data errors:
    Anything can happen. Depends on format and application.

The REAL End.

Questions & Comments welcome! :)

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