Skip to content

Instantly share code, notes, and snippets.

@sponomarev
Created October 17, 2014 09:22
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 sponomarev/6a2c85da27b911421cd8 to your computer and use it in GitHub Desktop.
Save sponomarev/6a2c85da27b911421cd8 to your computer and use it in GitHub Desktop.
convert any source video to fixed size flv with coloured letterboxes
# params: $input, $output, $width, $height, $color
# for landscape (normal) orientation
ffmpeg -y -i $input -vcodec flv1 -vf "scale=iw*min($width/iw\,$height/ih):ih*min($width/iw\,$height/ih), pad=$width:$height:($width-iw*min($width/iw\,$height/ih))/2:($height-ih*min($width/iw\,$height/ih))/2:color=$color" -vb 4000k -acodec mp3 -ar 44100 -ab 320k -vsync 1 -async 1 $output
# for portrait orientation
ffmpeg -y -i $input -vcodec flv1 -vf "transpose=1, scale=iw*min($width/iw\,$height/ih):ih*min($width/iw\,$height/ih), pad=$width:$height:($width-iw*min($width/iw\,$height/ih))/2:($height-ih*min($width/iw\,$height/ih))/2:color=$color" -vb 4000k -acodec mp3 -ar 44100 -ab 320k -vsync 1 -async 1 $output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment