News:

--

Main Menu

Appending two mp4 videos does not work

Started by thoste, February 17, 2024, 11:29:46 AM

Previous topic - Next topic

thoste

I have two *.mp4 videos. They have the same width/height, the same fps, the same AVS H.265 video codec and the same AAC codec.

They differ only a little bit in video and audio bitrate. However this shouldn't matter

Now I want to append them with Avidemux WITHOUT re-encoding.

According to what I read so far in Internet it should be sufficient for appending that all chunks have the same width/height, fps and codecs. That is given here.

But when I perform the append operation (with "copy" in Avidemux video and audio section then the result is broken.
I cannot play the second part in VLC.

Whats wrong?

I attached as a sample two .mp4 files

https : // filedoge.com/download/43055fba4cab1cf67af91871a10ed96c11079a6d1f8516a91f2c926fb750e711d3082a271e070d5148cb

eumagga0x2a

I admit that I haven't yet looked at the files, but regardless the internet, I've repeated many times here in the forum that for appended videos to allow export in copy mode the codec extradata of all reference videos must match perfectly. Avidemux usually warns when this is not the case. If there hasn't been such a warning, this would constitute a bug.

Elstar`

Quote from: eumagga0x2a on February 17, 2024, 11:48:05 AMI admit that I haven't yet looked at the files, but regardless the internet, I've repeated many times here in the forum that for appended videos to allow export in copy mode the codec extradata of all reference videos must match perfectly. Avidemux usually warns when this is not the case. If there hasn't been such a warning, this would constitute a bug.
There is no warning when trying to join several videos from same youtube channel, for example.

Elstar`

Quote from: thoste on February 17, 2024, 11:29:46 AMWhats wrong?
They are encoded with different parameters (for example, ReFrames does not match), and different encoding libraries (x264 and something unknown). You need to reencode.

Silox

Problem between both video files is the colorspace.
VID-first WA0016.mp4         colorspace: bt709        (1)
VID-second-WA0017.mp4        colorspace: smpte170m    (6)
When you merge booth files with AD then VLC etc will not play the file correctly and in AD the second video is not showing or just green blank in VD. Somehow AD does not handle it but you can use ffmpeg CLI to merge both files together (concat) and it works without to re-encode. Otherwise you have to re-encode the file to same colorspace bt709 (-colorspace 1) or the other file to smpte170m (-colorspace 6). Look into ffmpeg help file.
  -colorspace        <int>        ED.V....... color space (from 0 to INT_MAX) (default unknown)
     bt709           1            ED.V....... BT.709
     smpte170m       6            ED.V....... SMPTE 170 M
I think in case of using ffmpeg CLI it does just keeps the raw header information of every merged file original and that should be the reason why you also can concat different files also with different resolutions what then looks strange in player of course. Anyway, just test it and do what you prefer.

eumagga0x2a

Quote from: Silox on February 21, 2024, 09:04:59 PMSomehow AD does not handle it but you can use ffmpeg CLI to merge both files together (concat) and it works without to re-encode.

Would you please be so kind to provide that merged by ffmpeg file as a sample? (Codec properties changing on-the-fly are perfectly legal in a MPEG-TS, but not in containers which require out-of-band extradata like MP4 and MKV.)

Please use preferably WeTransfer, Mega, Dropbox or Google Drive to provide samples, thank you.

Silox

Quote from: eumagga0x2a on February 21, 2024, 11:03:46 PMPlease use preferably WeTransfer, Mega, Dropbox or Google Drive to provide samples, thank you.
I'm not registered on any of those websites. What about any free host? Otherwise if you did download the 2 example files from "thoste" then just concat the files with ffmpeg by yourself in copy mode and you got the same merged files like me.

PS: Has this forum / server no free space to attach some user content?

eumagga0x2a

WeTransfer doesn't require registration for files below 2 GiB in size (at least it didn't require any in recent past), it also doesn't require to provide a recipient's email address albeit it tries to make visitors believe otherwise.

Quote from: Silox on February 22, 2024, 10:04:56 PMWhat about any free host?

Mostly either not working, terrible or blocked in my region. Many providers allow sharing files via links like in this post.

Quote from: Silox on February 22, 2024, 10:04:56 PMif you did download the 2 example files from "thoste"

No, I didn't, else I wouldn't have bothered you.

Quote from: Silox on February 22, 2024, 10:04:56 PMPS: Has this forum / server no free space to attach some user content?

Within size limit of 512 kiB.



Silox

Ok one info I have seen today. The two videos I did concat with ffmpeg in copy mode are playing in VLC etc as I said already but the frame rate did change from 25 to 3.56 fps and the entire video has now a length of 6:37. The first video is playing fine and the second video is playing with 3.56 fps. Also audio does not match in this case what makes this concat in copy mode useless.

But, if you still want to merge both video files then you can use a little detour & ffmpeg again. Just use the not correctly working "concat" single file and demux the video stream as h264 and audio stream as aac file. Now you got both streams separated in folder and now mux both A/V streams with an mp4 container together with the frame rate of 25 (which both original videos have) you have to set before the input command (just optional). After this you got now a working video with a length of 56 seconds without to re-encode any stream. As I said its a small detour but a good alternative if you want prevent the re-encode.

Step List:
1.) Create concat text file (concat.txt) with both video paths inside....
file 'c:\....\VID-first WA0016.mp4'
file 'c:\....\VID-second-WA0017.mp4'

2.) Execute ffmmpeg CLI command
ffmpeg -f concat -safe 0 -i "c:\...\concat.txt" -c copy "c:\...\concat_video.mp4"

3.) Demux A/V streams
ffmpeg -i "c:\....\concat_video.mp4" -c copy "c:\....\concat.h264"
ffmpeg -i "c:\....\concat_video.mp4" -c copy "c:\....\concat.aac"

4.) Mux both streams into mp4 container
ffmpeg -i "c:\....\concat.h264" -i "c:\....\concat.aac" -c "c:\....\copy new_video.mp4"

5.) Done! Play video.
I did upload the three video files (Original & Results Video) on any free host. If you can't access this host in your region then use VPN or proxy IP to get access. The WeTransfer host requires Email data I don't use for this now also don't wanna use any temp mail.
Results.7z - 6.8 MB
pass: concat_demux_h264_aac_mux_mp4PS: @eumagga0x2a - Some internal server free space for us users to upload examples (image / video) would be helpfully. Otherwise if you can't then look around for some basic free hosts we should use in the future you know.