So, I have a bunch of .mp4 files and I need to change the video and audio codecs in order to be able to play them on my device.
The video codec is currently h264 and I need mpeg4.
The audio codec is aac and I need mp3.
I'm trying to convert them via this ffmpeg command:
ffmpeg -y -i input -s:v 800x480 -c:v mpeg4 -c:a mp3 output
It works fine, except for the quality because ffmpeg is using a very low bitrate.
My question now is if I need to specify a quality/bitrate or if it is possible to tell ffmpeg to use the original bitrate somehow.
-vcodec copy
is not an option because the video codec stays the same.
Best Answer
The defaults for
mpeg4
are not well chosen, so the target bitrate is quite low. Specify your own target with-b:v 2M
(depending on your resolution) or even better, use constant quality with-q:v 5
(as suggested by Mulvya in the comments). In the latter case, lower values mean better quality.No – it wouldn't even make sense to do that. If you are going from one codec to another, they might be less or more efficient. Each codec offers different quality at different bitrates – for example, H.264 is much more efficient than MPEG-4 Part II. H.265 is 30–50% more efficient than H.264, etc. The same goes for the actual encoders implementing the codecs: x264 is more efficient than the reference H.264 encoder, etc.
Therefore, taking the original bitrate may not work well. And even keeping the same codec, if you re-compress, you might want to use an even higher bitrate to avoid generation loss.