Skip to content

Instantly share code, notes, and snippets.

@ahmadarif
Last active May 14, 2018 14:11
Show Gist options
  • Save ahmadarif/9ce436d233a8d852e41118349d4aaa15 to your computer and use it in GitHub Desktop.
Save ahmadarif/9ce436d233a8d852e41118349d4aaa15 to your computer and use it in GitHub Desktop.

https://www.wowza.com/docs/how-to-encode-vod-using-ffmpeg-with-wowza-streaming-engine

OLD SYSTEM

ffmpeg -loglevel quiet -y -i input.mkv -s 256x144 -y -strict experimental -acodec aac -ab 24k -ac 2 -ar 48000 -vcodec libx264 -vprofile baseline -level 30 -g 48 -sc_threshold 0 -pass 1 -b:v 50k -threads 16 output.mkv

ffmpeg -loglevel quiet -y -i input.mkv -s 640x360 -y -strict experimental -acodec aac -ab 64k -ac 2 -ar 48000 -vcodec libx264 -vprofile baseline -level 30 -g 48 -sc_threshold 0 -pass 2 -b:v 400k -threads 16 output.mkv

ffmpeg -loglevel quiet -y -i input.mkv -s 1920x1080 -y -strict experimental -acodec aac -ab 128k -ac 2 -ar 48000 -vcodec libx264 -vprofile baseline -level 30 -g 48 -sc_threshold 0 -pass 2 -b:v 2500k -threads 16 output.mkv

FROM WOWZA BASIC TUTORIAL

ffmpeg -i input.mkv -pix_fmt yuv420p -deinterlace -vf "scale=1280:720" -vsync 1 -threads 0 -vcodec libx264 -r 29.970 -g 60 -sc_threshold 0 -b:v 1024k -bufsize 1216k -maxrate 1280k -preset medium -tune film -acodec aac -b:a 128k -ac 2 -ar 48000 -af "aresample=async=1:min_hard_comp=0.100000:first_pts=0" -y output.mp4

ffmpeg -i input.mkv -pix_fmt yuv420p -deinterlace -vf "scale=1280:720" -vsync 1 -threads 0 -vcodec libx264 -r 29.970 -g 60 -sc_threshold 0 -b:v 1024k -bufsize 1216k -maxrate 1280k -preset medium -tune film -acodec aac -b:a 128k -ac 2 -ar 48000 -af "aresample=async=1:min_hard_comp=0.100000:first_pts=0" -f mp4 -y output.mp4

ffmpeg -loglevel quiet -y -i input.mkv -s 1280x720 -y -strict experimental -acodec aac -ab 96k -ac 2 -ar 48000 -vcodec libx264 -vprofile baseline -level 30 -g 48 -sc_threshold 0 -pass 2 -b:v 1200k -threads 16 output-complex.mp4

SIMPLE DAN BAGUS

  • 240p

    ffmpeg -i input.mkv -s 426x240 -threads 16 hasil-240p.mp4
  • 360p

    ffmpeg -i input.mkv -s nhd hasil-ntsc.mp4
    
    # or
    
    ffmpeg -i input.mkv -s 640x360 hasil-ntsc-2.mp4
  • 480p

    ffmpeg -i input.mkv -s ntsc hasil-ntsc.mp4
    
    # or
    
    ffmpeg -i input.mkv -s 720x480 hasil-ntsc-2.mp4
    
    # or (youtube recomendation)
    
    ffmpeg -i input.mkv -s 854x480 -g 60 -sc_threshold 0 -loglevel quiet -y hasil-480p-youtube.mp4
  • 720p

    ffmpeg -i input.mkv -s hd720 hasil-hd720.mp4
    
    # or
    
    ffmpeg -i input.mkv -s 1280x720 hasil-hd720-2.mp4

Optimization encoding

-threads 0 # use all core for enccoding process
-threads 16 # use 16 core for encoding process

Bitrate Quality (default 23)

-crf 23

Rewrite file

-y output.mp4

example: ffmpeg -i input.mkv -s nhd -y hasil-ntsc.mp4

SHOW FILE INFORMATION

ffprobe -v quiet -print_format json -show_format -show_streams output.mkv

For adaptive-bitrate switching

-sc_threshold 0

YOUTUBE RECOMENDATION

  • 2160p: 3840x2160
  • 1440p: 2560x1440
  • 1080p: 1920x1080
  • 720p: 1280x720
  • 480p: 854x480
  • 360p: 640x360
  • 240p: 426x240

ffmpeg.org

  • ‘ntsc’ -> 720x480
  • ‘pal’ -> 720x576
  • ‘qntsc’ -> 352x240
  • ‘qpal’ -> 352x288
  • ‘sntsc’ -> 640x480
  • ‘spal’ -> 768x576
  • ‘film’ -> 352x240
  • ‘ntsc-film’ -> 352x240
  • ‘sqcif’ -> 128x96
  • ‘qcif’ -> 176x144
  • ‘cif’ -> 352x288
  • ‘4cif’ -> 704x576
  • ‘16cif’ -> 1408x1152
  • ‘qqvga’ -> 160x120
  • ‘qvga’ -> 320x240
  • ‘vga’ -> 640x480
  • ‘svga’ -> 800x600
  • ‘xga’ -> 1024x768
  • ‘uxga’ -> 1600x1200
  • ‘qxga’ -> 2048x1536
  • ‘sxga’ -> 1280x1024
  • ‘qsxga’ -> 2560x2048
  • ‘hsxga’ -> 5120x4096
  • ‘wvga’ -> 852x480
  • ‘wxga’ -> 1366x768
  • ‘wsxga’ -> 1600x1024
  • ‘wuxga’ -> 1920x1200
  • ‘woxga’ -> 2560x1600
  • ‘wqsxga’ -> 3200x2048
  • ‘wquxga’ -> 3840x2400
  • ‘whsxga’ -> 6400x4096
  • ‘whuxga’ -> 7680x4800
  • ‘cga’ -> 320x200
  • ‘ega’ -> 640x350
  • ‘hd480’ -> 852x480
  • ‘hd720’ -> 1280x720
  • ‘hd1080’ -> 1920x1080
  • ‘2k’ -> 2048x1080
  • ‘2kflat’ -> 1998x1080
  • ‘2kscope’ -> 2048x858
  • ‘4k’ -> 4096x2160
  • ‘4kflat’ -> 3996x2160
  • ‘4kscope’ -> 4096x1716
  • ‘nhd’ -> 640x360
  • ‘hqvga’ -> 240x160
  • ‘wqvga’ -> 400x240
  • ‘fwqvga’ -> 432x240
  • ‘hvga’ -> 480x320
  • ‘qhd’ -> 960x540
  • ‘2kdci’ -> 2048x1080
  • ‘4kdci’ -> 4096x2160
  • ‘uhd2160’ -> 3840x2160
  • ‘uhd4320’ -> 7680x4320
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment