What command lines to use to convert from avi to mp4, but without destroying the framesize and making the file small as the original size or a little bit bigger, and same thing with mp4 to avi? Whenever I tried converting it became like 2 gb
4 Answers
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.
- 103
- 3
- 1,208
- 10
- 11
-
8I think it's better to use `ffprobe -i infile.avi` instead of `ffmpeg -i infile.avi` for getting informations, as the latter results in the "At least one output file must be specified" error. – Sep 23 '12 at 10:41
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 (change containers and re-encode is the default mode of ffmpeg). It's worth noticing that re-encoding might deteriorate visual and/or audio 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)
- 753
- 1
- 6
- 15
- 261
- 2
- 3
-
When copying both audio and video you can use -c copy rather than specifying both. – Hipponax43 Aug 09 '21 at 15:57
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.
-
The output quality seems to be the same as with `ffmpeg -i infile.avi youroutput.mp4` as given in @rbanffy 's answer? – aspiring1 Aug 13 '20 at 10:07
I have found this one:: Libav in Linux.
Installation: run command
sudo apt-get install libav-tools
Video conversion command:
Go to folder containing the video and run in terminal
avconv -i oldvideo.mp4 -ar 22050 convertedvideo.webm
- 107
- 6
- 101
- 1
-
for windows you can use mingw32 and configure Libav as follows: ./configure --target-os=mingw32 --arch=x86 --enable-shared --enable-static --enable-dxva2 --disable-encoders --enable-hwaccel=dxva2 --extra-cflags=-O3 --enable-pthreads and then compile Libav with 'make' . Thus, you can get windows version of 'avconv' – Shevach Riabtsev Aug 11 '21 at 08:00
-
On MAC you can install libav by simple command: brew install libav – Shevach Riabtsev Aug 11 '21 at 08:05
-