News:

--

Main Menu

Merging two videos issue

Started by Anic297, January 09, 2021, 09:31:46 PM

Previous topic - Next topic

Anic297

Hello,

I'm trying to append one movie file to another one. I've encountered several errors that I managed to resolve (I think), but now I'm stumped; I can't figure what's still wrong.

The first movie file has a format of AVC1 and a size of 1920x1080 (50 fps). Its audio is AC3, 6 channels, 48000 Hz of frequency and 48000 Bps/384 kbps bitrate.
The second movie, before I did anything with it is an AVC1 and 50 fps with a size of 1280x720. Audio is MP2, 2 channels, 48000 Hz and a bitrate of 16000 Bps/128 kbps.

So I managed to convert the 2nd file to have the same properties than the first one (I used VLC for that conversion). When I compare the properties of both files (the one to append to and the converted one) in Avidemux, only these fields differ:
Apect Ration: "1:1 (1:1)" for the first file and "Unknown (83:84)" for the 2nd converted. I find it weird, but...
Duration (expected)
ExtraDataSize (115 for the 1st file; 43 for the 2nd converted).
The remaining fields are identical (I managed to have 6 audio tracks in the converted file).

Here's what I'm attempting: in Avidemux, I open the first file and append the converted 2nd file. The first frame of the appended file has a wrong duration of more than 2 hours, so I try to remove the first frame. Then, a message appears:
"Codec or codec settings across the deletion do not match. Playback of the video saved in copy mode may stop at this point.
Proceed anyway?"
I proceed. When playing the resulting file, the video is indeed corrupted (the appended video won't update/show, but the audio is ok).
However, codec and codec settings are the same, according to the properties shown in Avidemux. Perhaps there are hidden properties that Avidemux doesn't show and which are different between my two files thus making the problem?
I'm far than an expert in this, just thinking that if all properties are matching, the append should work. How may I know which property is still different, to convert otherwise, since Avidemux won't tell me?
BTW: all files are mkv files.

Help welcome.

eumagga0x2a

Quote from: Anic297 on January 09, 2021, 09:31:46 PMExtraDataSize (115 for the 1st file; 43 for the 2nd converted).
.......
However, codec and codec settings are the same, according to the properties shown in Avidemux.

No, they are not. If they were, both decoder configurations (extradata) would have been bit-identical.

If the first video was created by the x264 encoder, it might retain a pretty full list of encoder configuration, used to generate this video (Avidemux mentions this in its log file when saving a H.264 video in copy mode as it tries to inject it into the copy). You can check whether this info is present using the "mediainfo" application.

To re-encode the second video in a way which would allow to append it to the first one and save in copy mode, the both x264 configurations must match perfectly.

If the first video was created by a different encoder, the only viable strategy is to re-encode both. If you have a huge amount of storage space, I would recommend to use a lossless codec like Ut Video for the upscaling step (you need to use a recent Avidemux nightly for that).

Anic297

Thank you for your answer.

I tried with the Ut codec as you suggested, but I didn't expected the resulting size would be so huge (the original file being 1.5 GB, at around 45 GB, the target disk was full and the encoding had to abort).

Is there any benefit of having a file way larger than the original, by the way? I mean, even an uncompressed version wouldn't be visually better than the original, right? (I understand different codecs may need extra space for headers or such, but a 30x larger format, I don't understand how it's beneficial (and it is overkill for my needs)).

My files are episodes of a TV show, around 1.5 GB each. Can you recommend another lossless codec that would keep the original size not so different? (or perhaps I'm just misunderstanding something basic...)

eumagga0x2a

For a lossless codec, Ut Video encoder compresses pretty efficiently with median prediction method enabled.

Quote from: Anic297 on January 12, 2021, 09:59:30 AMI understand different codecs may need extra space for headers or such, but a 30x larger format, I don't understand how it's beneficial (and it is overkill for my needs

A raw uncompressed 1080p 50fps video stream with 4:2:0 chroma subsampling has a bitrate of 1244160000 (1.2 Gbit/s). From this starting point, even a bitrate of ~ 100 Mbit/s with Ut Video is still a ten-fold compression. Established lossy codecs like H.264 usually compress video by a factor beyond 200 (could easily go beyond 500 while still maintaining high quality for AV1).

The benefit from using a real lossless codec is to avoid accumulation of artifacts and quality degradation from an additional re-encoding step.

Quote from: Anic297 on January 12, 2021, 09:59:30 AMCan you recommend another lossless codec that would keep the original size not so different?

Choosing constant quality mode in x264 with quality set to 0 comes as close as possible to lossless, but the bitrate saving will be not great compared to Ut Video while being an order of magnitude slower. The only other really lossless alternative in Avidemux (HuffYUV) is much less efficient compared to Ut Video.

xyzzy

If you wanted to re-encode both files, you could encode the first file with avidemux to h264 or something else.  Then do the 2nd file with avidemux and use resize filter, etc. to make it the same resolution and framerate.  Use the same avidemux encoder config you used on the 1st file.  Now the encoder settings will match.

Then you can concatenate the two files in copy mode without re-encoding.