Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ivan-leschinsky/e9d3003c3958423cef3943b149b12d26 to your computer and use it in GitHub Desktop.
Save ivan-leschinsky/e9d3003c3958423cef3943b149b12d26 to your computer and use it in GitHub Desktop.
Video encoding with FFmpeg, a great tool with the shittiest user interface you can imagine: lots of confusing, unmemorable, unintuitive, undiscoverable command-line flags

Remux without transcoding

ffmpeg -i input.ts -c copy output.mp4

x264, AAC

ffmpeg -i input.avi -c:v libx264 -preset slow -crf 18 -pix_fmt yuvj420p -c:a aac -b:a 160k output.mp4

x265, AAC

ffmpeg -i input.avi -c:v libx265 -preset slow -crf 24 -x265-params range=full -c:a aac -b:a 128k output.mp4

HEVC_NVENC, pass-through audio

ffmpeg -i input.avi -c:v hevc_nvenc -preset slow -rc vbr_hq -cq 27 -tier high -dst_range 1 -c:a copy output.mp4

Remux without transcoding

ffmpeg -i input.ts -c copy output.mp4

x264, AAC

ffmpeg -i input.avi -c:v libx264 -preset slow -crf 18 -pix_fmt yuvj420p -c:a aac -b:a 160k output.mp4

x265, AAC

ffmpeg -i input.avi -c:v libx265 -preset slow -crf 24 -x265-params range=full -c:a aac -b:a 128k output.mp4

HEVC_NVENC, pass-through audio

ffmpeg -i input.avi -c:v hevc_nvenc -preset slow -rc vbr_hq -cq 27 -tier high -dst_range 1 -c:a copy output.mp4
REM Convert a Fraps capture to a Ut Video file with the trimming, cropping, and resizing you want, using a tool like TMPGEnc.
REM Export as AVI file output with UtVideo YUV420 BT.709 VCM (ULH0).
REM Specifying -pix_fmt yuvj420p will preserve the full range of lightness values, instead of washed-out blacks and whites.
ffmpeg -i input.avi -pix_fmt yuvj420p -c:v libx264 -preset medium -crf 23 -c:a aac -b:a 128k output.mp4
REM You can also use YUV422 and H.265:
ffmpeg -i input.avi -pix_fmt yuvj422p -c:v libx265 -preset fast -crf 26 -c:a aac -b:a 128k output.mp4
REM Fraps to H.265 with NVENC:
ffmpeg -i input.avi -ss 00:00:01.000 -to 00:05:00.000 -c:v hevc_nvenc -preset slow -rc vbr_hq -cq 27 -c:a aac -b:a 128k -dst_range 1 output.mp4
  1. Export from Premiere to a lossless, compressed AVI.
  2. Transcode AVI to H.264 using FFmpeg.

If you don't have the time or space to render a temporary lossless copy of your file on disk, you can use a frameserver instead.

Premiere export settings

Video

Setting Value
Format AVI
Video Codec UtVideo YUV420 BT.709 VCM
Width 1920
Height 1080
Frame Rate 29.97
Field Order Progressive
Aspect Square Pixels (1.0)

Audio

Setting Value
Sample Rate 48000 Hz
Channels Stereo
Sample Size 16 bit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment