How do I convert a MKV file to H.264/AVC with a resolution of 640x360 using FFMPEG?
Solution 1
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 (seeffmpeg -codecs
for your full list) -
-o
sets the output filename (seeffmpeg -formats
for your full list)
Solution 2
Splitting without re-encoding:
ffmpeg -ss [start-time] -t [length-time] -i [in-file-path] \
-vcodec copy -acodec copy [out-file-path]
Example:
ffmpeg -ss 00:00:00.00 -t 00:10:00.00 -i "/some/path/to/file.mp4" \
-vcodec copy -acodec copy "/some/path/to/new file.mp4"
Related videos on Youtube
Eric
Updated on September 18, 2022Comments
-
Eric over 1 year
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, 640x360, 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.
-
Eric about 12 yearsThanks, I will try this out. I forgot to mention that I prefer command line tools over GUI ones [question updated].