Article Image

If you want to optimize your audio / video files, you should check ffmpeg. Here are some tips to use it in command line. First of all, open up the console :)

Convert audio and video bitrate:

ffmpeg.exe -i video.mp4 -b:a 128k -b:v 1200k convertvideo.mp4

A full line of commands:

ffmpeg -i source_video.avi input -acodec aac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -s 320x180 -title X final_video.mp4

Explications :

  • Source : source_video.avi
  • Audio codec : aac
  • Audio bitrate : 128kb/s
  • Video codec : mpeg4
  • Video bitrate : 1200kb/s
  • Video size : 320px by 180px
  • Generated video : final_video.mp4

Converting for the web:

ffmpeg -i -vcodec h264   -an -strict -2 output.mp4
ffmpeg -i -vcodec libvpx -an output.webm

ffmpeg -i -vcodec h264 -acodec aac -strict -2 output.mp4
ffmpeg -i -vcodec libvpx -acodec libvorbis output.webm

<video width="320" height="240" controls>
  <source src="movie.mp4" type='video/mp4'></source>
  <source src="movie.webm" type='video/ogg'></source>

Gobal Cheatcheet

-codecs    # list codecs
-c:v       # video codec (-vcodec) - 'copy' to copy stream
-c:a       # audio codec (-acodec)

-fs SIZE         # limit file size (bytes)

-b:v 1M          # video bitrate (1M = 1Mbit/s)
-b:a 1M          # audio bitrate

-aspect RATIO    # aspect ratio (4:3, 16:9, or 1.25)
-r RATE          # frame rate per sec
-s WIDTHxHEIGHT  # frame size
-vn              # no video

-aq QUALITY      # audio quality (codec-specific)
-ar 44100        # audio sample rate (hz)
-ac 1            # audio channels (1=mono, 2=stereo)
-an              # no audio
-vol N           # volume (256=normal)



Blog Logo

Florent Bertiaux

I'm a blogger



I learned something new

A blog from @kxrz - Dev tips and tricks

Back to Overview