Avidemux Forum

Avidemux => MacOSX => Topic started by: bgentile on December 28, 2021, 10:39:12 AM

Title: Size of Video Changes
Post by: bgentile on December 28, 2021, 10:39:12 AM
I'm trying to cut commercials out of a recording and get this error message:

The size of the video changes at frame 36696 from 1920x1080 to 1280x720. This is unsupported and will result in a crash.
Proceed nevertheless?
This warning won't be shown again for this video.

When I try to edit out video segments it crashes.

How can I handle this? I am trying to cut out commercials but still keep closed captions.

I'm running 2.7.8.
Title: Re: Size of Video Changes
Post by: eumagga0x2a on December 28, 2021, 05:43:12 PM
The only option is to run Avidemux from the Terminal where it prints the offset of each resolution switch, write down all offsets, then split the original transport stream file into sections with matching video dimensions at exactly those offsets using e.g. Unix command-line tools like dd, head or tail, then load/append matching fragments in Avidemux.

2.7.8 is an unsupported old release, please update to 2.8.0.
Title: Re: Size of Video Changes
Post by: Talonflame on November 03, 2023, 09:09:24 PM
Can you please help me in a private message, I have the same problem but I don't know what to do. Would be great if you can help me ;)
Title: Re: Size of Video Changes
Post by: eumagga0x2a on November 08, 2023, 10:39:48 PM
Talonflame, please read a few tutorials how to use the Terminal app on macOS first. I would recommend adding "zsh" to your search keywords – tutorials which assume bash to be the shell invoked by the Terminal app are very old, tutorials which don't even mention the shell are probably too superficial.

With that done, you launch Avidemux 2.8.2 nightly from the Terminal (assuming it is installed to the default location)

/Applications/Avidemux_2.8.2.app/Contents/MacOS/Avidemux2.8
and let it index a MPEG-TS file with resolution changing on-the-fly. Please make sure that there is no *.idx2 file for that video yet. Avidemux will show you a warning "The size of the video changes at frame etc". Let it proceed with indexing, then close Avidemux.

Now search the messages in the Terminal (Command + F) for "Size change" (uncheck the default "Ignore Case" search option to make search as specific as possible), for each such line, copy it including the offset value (the info we need) and paste into a text document.

In a new Terminal window, change directory to the location of the source video and run

dd if="your source video.ts" of="/path/to/your/separated/video/part_01.ts" bs=1 count=$(( 0xFIRST_OFFSET_IN_HEX - 1 ))
This should save the first segment of the source video as "part_01.ts" in directory "/path/to/your/separated/video". You should be familiar with path syntax and know what is a full path, a relative path, the meaning of ".", ".." and "~".

For subsequent segments, please proceed as

dd if="your source video.ts" of="/path/to/your/separated/video/part_NN.ts" bs=1 seek=$(( 0xPREVIOUS_OFFSET_IN_HEX - 1 )) count=$(( 0xCURRENT_OFFSET_IN_HEX - 0xPREVIOUS_OFFSET_IN_HEX ))
with NN incrementing by one each time (so you get part_02.ts, part_03.ts and so on), finishing with

dd if="your source video.ts" of="/path/to/your/separated/video/part_NN.ts" bs=1 seek=$(( 0xLAST_OFFSET_IN_HEX - 1 ))
I am not completely sure that we need to subtract one from offset value to start output and cannot find a suitable sample to test. You need to replace "0xSOME_OFFSET_IN_HEX" with corresponding hex values, the prefix "0x" indicated that following characters belong to a hexadecimal value. Please mind the gap, sorry, the spaces inside parentheses. On the contrary, spaces between values in arithmetic evaluations are just for legibility.

Please be aware that dd overwrites existing files (if file permissions and ownership allow) without warning if you pass a wrong value to the of option.
Title: Re: Size of Video Changes
Post by: eumagga0x2a on November 08, 2023, 10:55:55 PM
Part 2

Once you have split the source MPEG-TS file into segments part_01.ts, part_02.ts, part_03.ts etc, you need to group all segments into subfolders by their video resolution. Usually, there are only two resolutions, but this cannot be taken for granted.

After that you should identify which resolution the actual content you are interested in has, load the first segment of that resolution in Avidemux and append one by one the remaining from the same subfolder. This should allow to export the video.

However, as audio tracks may switch formats not exactly at segment boundaries and even the number of tracks can vary between segments, the result may still be unusable and/or make Avidemux crash on playback or re-encoding.