Encode with ffmpeg using avi to mp4
Depending on how your original file was encoded, it may not be possible to keep the file size.
This command should keep frame sizes and rates intact while making an mp4 file:
ffmpeg -i infile.avi youroutput.mp4
And this command will give you information about your input file - the frame size, codecs used, bitrate, etc.:
ffmpeg -i infile.avi
You can also play with the acodec
and vcodec
options when you generate your output. Remember also that mp4 and avi files can use various codecs and your mileage may vary according to which codec you pick.
As far as i understand it's required to replace avi-container with mp4 one (formally - ISO base media file format ISO/IEC 14496-12 ).
if you run the following command:
ffmpeg -i input.avi -y output.mp4
In such case ffmpeg re-encodes elementary streams within input.avi (cahnge containers and re-encode is the default mode of ffmpeg). It's worth noticing that re-encoding might deteriorate visual and/or hearing quality.
Therefore, it's recommended to disable re-encoding by "c:v copy c:a copy" codec options:
ffmpeg -i input.avi -c:v copy -c:a copy -y output.mp4
In the above case ffmpeg merely changes shells (containers)
I was very interested in converting avi files to mp4. Reading your post, I remembered this ffmpeg command:
ffmpeg -i input.avi -strict -2 output.mp4
The command -strict -2
is necessitated by the AAC codec which is experimental, but works (libaac), if you add those two parameters.
The output file is high-quality by default.