Skip to content

Instantly share code, notes, and snippets.

@djhaskin987
Created February 2, 2024 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djhaskin987/63d5d0efc39a80da1a79a6b0acac0beb to your computer and use it in GitHub Desktop.
Save djhaskin987/63d5d0efc39a80da1a79a6b0acac0beb to your computer and use it in GitHub Desktop.

FFmpeg

Documentation

So much documentation.

Recipes

  • Encode for 1080p blu-ray: https://web.archive.org/web/20211016213149/http://www.x264bluray.com/home/1080i-p

    1080p Primary and Secondary Streams

    1080p23.976 / 1080p24

    x264 --bitrate XXXXX --preset veryslow --tune film --bluray-compat --vbv-maxrate 40000 --vbv-bufsize 30000 --level 4.1 --keyint 24 --open-gop --slices 4 --colorprim "bt709" --transfer "bt709" --colormatrix "bt709" --sar 1:1 --pass 1 -o out.264 input.file
    
    x264 --bitrate XXXXX --preset veryslow --tune film --bluray-compat --vbv-maxrate 40000 --vbv-bufsize 30000 --level 4.1 --keyint 24 --open-gop --slices 4 --colorprim "bt709" --transfer "bt709" --colormatrix "bt709" --sar 1:1 --pass 2 -o out.264 input.file
    

    NB: the following two streams are encoded using fake-interlaced mode. This allows the stream to be encoded progressively yet flagged as interlaced.

    1080p25

    x264 --bitrate 
    XXXXX --preset veryslow --tune film --bluray-compat --vbv-maxrate 40000 --vbv-bufsize 30000 --level 4.1 --keyint 25 
    --open-gop 
    --slices 4 --fake-interlaced 
    --colorprim "bt709" --transfer "bt709" --colormatrix "bt709" --sar 1:1 --pass 1 -o out.264 input.file
    
    x264 --bitrate 
    XXXXX --preset veryslow --tune film --bluray-compat --vbv-maxrate 40000 --vbv-bufsize 30000 --level 4.1 --keyint 25 
    --open-gop 
    --slices 4 --fake-interlaced 
    --colorprim "bt709" --transfer "bt709" --colormatrix "bt709" --sar 1:1 --pass 2 -o out.264 input.file
    

    1080p29.97

    x264 --bitrate XXXXX 
    --preset veryslow --tune film --bluray-compat --vbv-maxrate 40000 --vbv-bufsize 30000 --level 4.1 --keyint 30 
    --open-gop 
    --slices 4 --fake-interlaced 
    --colorprim "bt709" --transfer "bt709" --colormatrix "bt709" --sar 1:1 --pass 1 -o out.264 input.file
    
    x264 --bitrate XXXXX 
    --preset veryslow --tune film --bluray-compat --vbv-maxrate 40000 --vbv-bufsize 30000 --level 4.1 --keyint 30 --open-gop --slices 4 --fake-interlaced --colorprim "bt709" --transfer "bt709" --colormatrix "bt709" --sar 1:1 --pass 2 -o out.264 input.file
    
  • Don't transcode to disk, transcode to s3:

fifo=$(mkstemp ...)
ffmpeg ... unix://${fifo}
# in another process
s3 cp ${fifo} s3://<destination>

Works for to or from, probably!

Other interesting FFMpeg protocols: tcp, tls, udp, aqmp, http, sftp, hls.

Also, you can just mount s3 on the filesystem and use it to push out HLS using the HLS demuxer.

  • FFMPEG CAN SEND STUFF TO RTMP links AND STREAM IT. LIVESTREAMS.

  • Transcode to HLS, putting output to some HTTP server:

ffmpeg -re -i in.ts -f hls -method PUT http://example.com/live/out.m3u8

Various options for DRM+ffmpeg.\

I particularly like the use of bento4 in that guide for VOD.

How to install

Mac OSX

Linux

Ubuntu

I'm pretty sure it's just apt-get install -y ffmpeg.

Fedora

You need rpmfusion, then just dnf install ffmpeg

Static Builds

Provided by the wonderful John Van Sickle..

ffmpeg Made Easy: GUI tools

How can I make ffmpeg more digestible?

Browser

I drool over ffmpeg.guide but I can't seem to log in. I can get to the demo though.

Looks really good.

Mac OS X

ffWorks looks good, but ultimately is a more limited tool.

FFmpegGUI is exactly what I want, but I can't get it to build and it appears abandoned.

Linux

Class topics

  • Installation and Overview
  • Burn in subtitles and apply Overlays (make your own Technologik): FILTERS
  • Match input bitrates and quality or change it up: CODECS
  • Transcode an HLS and put it directly on S3 without writing to disk: MUXERS
  • Extract frames (one filter for each): BLARG
  • Select scene frames, Create sprite sheets, create mosaics (select)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment