How to convert a MKV file to H.264/AVC with a resolution of 640×360 using FFMPEG

conversionffmpegvideo

I have a MKV video which I want to put in my mobile (a Nokia XM 5800) and based on this I can play H.264/AVC format videos on it. Based on what I have read, the container should be MP4 and I can encode it using XVID codec. The problem is I don't know how.

Since I am using Linux (Arch), I was wondering if I can achieve this using FFMPEG. If so, please enlighten me on how to do this. I want the video to use the native screen size of the device, 640×360, with a reasonably good video and audio quality.

If you can also suggest other tools that will make it easier, please suggest.

I also prefer command line tools over GUI ones.

Best Answer

Avidemux has a useful GUI interface that will let you resize and transcode. mencoder (part of MPlayer) can do it too, but it's also command line.

I think the ffmpeg line you want is something like this:

ffmpeg -s 640x360 -i in.mkv -vcodec libx264 -o new.mp4
  • -s sets the output size
  • -i is input file
  • -vcodec sets the output codec (see ffmpeg -codecs for your full list)
  • -o sets the output filename (see ffmpeg -formats for your full list)
Related Question