Log in

View Full Version : FFmpeg: Lossless video conversion from AVI to MP4 possible for ALL codecs ?


mike23
6th February 2022, 08:42
I consider to convert some dozens of old AVI video files from AVI to MP4 container by using ffmpeg with the following simple command:

Code:

ffmpeg.exe -i oldvideo.avi -vcodec copy -acodec copy newvideo.mp4

I place strong emphasis to the fact that the conversion is lossless. No re-encoding should take place.

Does this really work for all kind of videos and codecs?

Even for those which are originally encoded with Divx or Xvid?

With or without constant bitrate?

Are the existing keyframes accessible as before?

Are timestamps and other existing tags (in header) kept?

Sometimes I read about some necessary additional parameters like "-map 0".
When are they required?

Thank you

Selur
6th February 2022, 10:04
Does this really work for all kind of videos and codecs?
Only those supported by the mp4 container.
Even for those which are originally encoded with Divx or Xvid?
Those two are MPEG-4 ASP video stream which are supported by the mp4 container, so: Yes.

With or without constant bitrate?
Doesn't matter, you are remuxint which does not change the video/audio stream, but repackages them.

Are the existing keyframes accessible as before?
Unless your decoder has a problem with the container and it's content: Yes.

Are timestamps and other existing tags (in header) kept?
By default headers supported by the target container are kept.

Sometimes I read about some necessary additional parameters like "-map 0".
When are they required?
reading https://www.ffmpeg.org/ffmpeg-all.html or some of the other documentation of ffmpeg should clean that up.

SeeMoreDigital
6th February 2022, 11:52
I consider to convert some dozens of old AVI video files from AVI to MP4 container by using ffmpeg...
Is there any particular reason why you want to re-mux your .avi contained (video and audio) streams into the .mp4 container?

Why not re-mux into the .mkv container, which supports far more video and audio formats than the .mp4 container ;)


EDIT: Check out the following topic: https://forum.doom9.org/showthread.php?t=183427

StainlessS
6th February 2022, 15:52
Warning,
ffmpeg, may allow you to remux video/audio into an incompatible container,
that does not guarantee that the video will be playable in that container [at least not by all players].

Is there any particular reason why you want to re-mux your .avi contained (video and audio) streams into the .mp4 container?

Why not re-mux into the .mkv container, which supports far more video and audio formats than the .mp4 container ;)

Good advice.

FranceBB
7th February 2022, 00:45
Good advice.

Yep, I would remux with mkvmergegui too.
It's just quick, easy and hassle free.
About MP4, there's also MP4Box with MP4BoxGUI as a muxer.

mike23
7th February 2022, 15:04
Is there any particular reason why you want to re-mux your .avi contained (video and audio) streams into the .mp4 container?

Why not re-mux into the .mkv container, which supports far more video and audio formats than the .mp4 container ;)


I play the resulting videos not only on computers/notebooks but on TVs as well.
I will copy multiple movies on an USB flash drive and put into into the USB ports of the TV.

In this scenario the TV built-in hardware decoder must understand MKV container format.
I remember times in the past when TV did not understand MKV.
So I was lost.

I am not sure if the majority of TVs are meanwhile capable of MKV.
The movies should be playable at least on TVs manufactured in the last 5 years.

SeeMoreDigital
7th February 2022, 16:08
I am not sure if the majority of TVs are meanwhile capable of MKV.
The movies should be playable at least on TVs manufactured in the last 5 years.
Most, if not all, 'smart TV's' support MKV contained files. All mine do ;)

StainlessS
10th February 2022, 08:13
This is sort of in same area as this thread,

I've never used x265 as my Android mobile phones with Mx_Player cannot seek in x265 [EDIT: in mp4 container],
just jumps back to beginning again. I recently got a new (2nd user) phone [XPeria XZ2 Premium],
and wanted to know if current MX_Player Pro and new phone still had problems,
It does. So, just for luck, I remuxed [EDIT: mp4] to mkv and as I had never tried mkv on the android devices,
I tried with mkv and ... no problems encountered. [same with my everyday carry Samsung Note 4, x265 in MKV OK].
Seeks OK, x265 in mkv now seems a viable alternative to x264 in mp4.
[EDIT: And way way faster x265 encode than when last time I tried - although I now tried on i7 so should be somewhat faster anyway]