Avidemux Forum

Avidemux => Windows => Topic started by: SandSmudge on January 02, 2022, 03:47:20 PM

Title: Failure to Append .mp4 files
Post by: SandSmudge on January 02, 2022, 03:47:20 PM
Hello, a new user and new member. Heard about your app from a YouTube site and decided to try. I am attempting to merge two .mp4 video files and running into an error condition. The two .mp4 files are transcoded outputs from Handbrake and used the exact same settings to create each of the .mp4 files.

The error message from Avidemux is: Width is different between first and this video stream

The two files are halves of a DVD that I would like to merge into one .mp4 file. The first file is 341,885KB and the second is 316,396KB. Is there a size limitation issue with Avidemux that will not allow this?

Regards and thanks for your help,
Title: Re: Failure to Append .mp4 files
Post by: eumagga0x2a on January 02, 2022, 03:56:20 PM
For appending videos, the coded pixel dimensions of all videos involved must match exactly (for copy mode, not just the dimensions but also codec and codec settings must match perfectly). What does Avidemux report (Alt+Return or "File" --> "Information" or click onto the blue button "I" in the toolbar) for each of the files when loaded separately?
Title: Re: Failure to Append .mp4 files
Post by: eumagga0x2a on January 02, 2022, 04:01:05 PM
To merge both, you would need to resize + re-encode one of the videos to match the dimensions of the other one. If the FPS and/or interlacing mode differ, you should add filters to correct these properties as well.
Title: Re: Failure to Append .mp4 files
Post by: SandSmudge on January 02, 2022, 04:33:37 PM
Hello,
Thanks for your quick reply. I did find the "Information" button and noticed that the files are different in the following areas:

Image size:  #1= 716x364          #2= 718x364
Frame rate:  #1= 23.991fps        #2= 23.993fps
Avg Bitrate: #1= 448kbps          #2= 420kbps

From your comments, I assume they have to match "exactly", correct?

Now, the question is... How do I adjust these three parameters? Is there a tool that does this or is this functionality included in Avidemux ?

Regards,
Title: Re: Failure to Append .mp4 files
Post by: SandSmudge on January 02, 2022, 04:43:25 PM
OK, trying to dive deeper into Handbrake to determine if I can "force" these params to match on an encode. Getting beyond my comfort zone, but I'll try.
Title: Re: Failure to Append .mp4 files
Post by: eumagga0x2a on January 02, 2022, 04:48:49 PM
Very unusual image dimensions, I'd say invalid for DVD. Bitrate doesn't matter, frame rate is probably meant to be "Film" (24000/1001).
Title: Re: Failure to Append .mp4 files
Post by: eumagga0x2a on January 02, 2022, 04:52:55 PM
If DVD is unencrypted, you should be able to copy the VOB files to harddisk and load them (the first one, the sequentially named fragments should be loaded automatically) in Avidemux directly.
Title: Re: Failure to Append .mp4 files
Post by: eumagga0x2a on January 02, 2022, 04:56:57 PM
Quote from: SandSmudge on January 02, 2022, 04:33:37 PMHow do I adjust these three parameters? Is there a tool that does this or is this functionality included in Avidemux ?

If the strange dimensions are not a result of handling Handbrake wrong (in this case the problem should be solved at its source), there are multiple filters in Avidemux to perform crop and resize operations with or without preserving aspect ratio.

Regarding FPS, it would make sense to post admlog.txt (located in %localappdata%\avidemux\ directory) from loading the particular MP4 file in Avidemux.
Title: Re: Failure to Append .mp4 files
Post by: SandSmudge on January 02, 2022, 05:24:58 PM
Thanks for all the good direction. I'll have to step my way through what you said. (I only know enough to be dangerous.) I do have decrypted .vob files, but they are from a two-sided DVD, which made me have two sets of .vob files that are not numbered in one set of files. I think what you are trying to tell me is that I can use Avidemux to transcode the .vob files into one .mp4, rather than using Handbrake which creates two .mp4 files that I am trying to merge.... is that correct? Wondering if I can rename the second side .vob files to be in sequence from the first side?
Title: Re: Failure to Append .mp4 files
Post by: eumagga0x2a on January 02, 2022, 05:43:23 PM
If the two-sided DVD is meant to be manually flipped onto the other side vs dual-layer DVDs where the switch happens automatically, then you should not try to make Avidemux load all VOBs as if they were parts of a single stream. If both sets of VOBs share the same dimensions, fps and interlacing mode, you should append the second one (i.e. load/append the first file of the second set after the first set has been loaded).

(I'd like to clarify that auto-append of sequential files in the demuxer (MPEG-PS or MPEG-TS) is very different from appending via the editor. The former specifically treats all fragments as a single file, the latter creates a new decoder instance, a new segment in the timeline etc.)
Title: Re: Failure to Append .mp4 files
Post by: SandSmudge on January 02, 2022, 06:13:47 PM
Yes, DVD is meant to be physically flipped over to play second half of film. So I have two identical batches of decrypted vob files. I have a Plex Media Server that only recognizes one of the mp4 files (even tho I do have two), hence I am trying to get one merged or complete mp4 file that is recognized in the library.

I will play with Avidemux to see if I can load the vob file batches as you describe. BTW, is there a manual stored anywhere online?
Title: Re: Failure to Append .mp4 files
Post by: eumagga0x2a on January 02, 2022, 06:23:11 PM
Quote from: SandSmudge on January 02, 2022, 06:13:47 PMBTW, is there a manual stored anywhere online?

There is a Wiki and some third-party tutorials on YouTube, mostly terribly outdated. Please feel free to ask here whenever you have questions.
Title: Re: Failure to Append .mp4 files
Post by: SandSmudge on January 02, 2022, 09:27:57 PM
Thanks for all your time and you help, you have been fantastic.

Sorry for the time, had to take a break and run errands. Wife was starting to get a little worried I was never going to move from PC   :-*

I've gotten the vob files loaded and appended in the proper order, and I can play the entire film in Avidemux with just a slight black screen delay between vob strings. Thanks for your help. Now, I am trying to figure out how to run the encoder to create the contiguous mp4 file. I have the "Output Format" set to Mp4 Muxer.

Do I need to change the Video Output or Audio Output settings to anything different than "copy"? I tried "Saving" the file, but got an error that "video was too short". The error occurs at the end of the first batch of vob files.
Title: Re: Failure to Append .mp4 files
Post by: SandSmudge on January 02, 2022, 09:31:58 PM
I'm assuming the "black space" between batches of vob files is causing the error message. Am I correct? is there a way to eliminate the black space so the two batches are connected?
Title: Re: Failure to Append .mp4 files
Post by: SandSmudge on January 02, 2022, 10:04:04 PM
Playing with video and audio output settings. Seems to be working. Thanks again for all your help.

Regards,
New Fan in North Carolina
Title: Re: Failure to Append .mp4 files
Post by: eumagga0x2a on January 02, 2022, 10:53:05 PM
Quote from: SandSmudge on January 02, 2022, 09:27:57 PMI've gotten the vob files loaded and appended in the proper order, and I can play the entire film in Avidemux with just a slight black screen delay between vob strings.

It would be helpful to see the admlog.txt from %localappdata%\avidemux\ from the above operation to assess the situation.

Quote from: SandSmudge on January 02, 2022, 09:27:57 PMI have the "Output Format" set to Mp4 Muxer.

Yes, this is the right muxer if you would like to re-encode the video from MPEG-2 e.g. to H.264 using the x264 encoder plugin to be able to watch it on mobile devices (H.264 is decoded in hardware while MPEG-2 while much less complex is decoded in software, greatly increasing battery drain). As you probably know, H.264 is a lossy codec, so the quality will always* degrade when you re-encode.

If you would like just to merge both streams in one single stream to be watched either on a computer or on a TV set capable of reading from mass storage devices, you might leave both video and audio at copy and export using MpegPS muxer.

Quote from: SandSmudge on January 02, 2022, 09:27:57 PMI tried "Saving" the file, but got an error that "video was too short". The error occurs at the end of the first batch of vob files.

admlog.txt might provide sligntly more insights, but generally this error when saving to MP4 happens when decode timestamps are missing or collide (they absolutely must increase from one frame to the next one). The MpegPS and MpegTS muxers which like the MP4 one are just shells around the libavformat library also need decode timestamps to be sane, so depending on the particular problem it might not work in this case either.

Re-encoding the stream instead of copying can help though.

*) Setting quantizer to zero should produce lossless output at cost of a huge file size and slow operation.
Title: Re: Failure to Append .mp4 files
Post by: SandSmudge on January 02, 2022, 11:24:40 PM
Thanks very much! I was playing with the Video/Audio Outputs (Mpeg4/AAC worked), and played with A & B markers and cuts to remove "black space" between vob batches.

WORKED!!!!! Now have 1 contiguous mp4 file that streams seamlessly.

You are awesome, and this tool is great! will play with other vids as well ! Great help, and great many thanks!

Regards,
Title: Re: Failure to Append .mp4 files
Post by: eumagga0x2a on January 02, 2022, 11:44:03 PM
Glad it worked :-)

Quote from: SandSmudge on January 02, 2022, 11:24:40 PMMpeg4/AAC worked

"Mpeg4" includes a big family of different codecs, most of them obsolete except of the widely used H.264 output by the "Mpeg4 AVC (x264)" software encoder and depending on your hardware eventually also by the "Nvidia H264" hardware encoder in Avidemux.

Forget about the remaining Mpeg4 encoders, they are legacy/obsolete nowadays.