Avidemux Forum

Avidemux => Main version 2.6 => Topic started by: bconway on January 01, 2022, 01:47:24 AM

Title: 2.8.0 repeatable crash - could be VC-1 video or LPCM audio related
Post by: bconway on January 01, 2022, 01:47:24 AM
I'm attempting to expand my collection of test files, and used MakeMKV to extract Harry Potter 1 from Blu-Ray. This is the first edition Blu-Ray, the one that doesn't have HD audio but has DD 5.1 and LPCM (arguably HD). Any attempt to load the file, or the 256 MB sample linked below, crashes with:

Assert failed :0
 file /Volumes/HudsonData/jenkins/MacOSX_Catalina/avidemux_plugins/ADM_demuxers/Matroska/ADM_mkv.h, line 173

Link to a 256 MB sample, created with dd (public, close the modal to view/download):

https://www.dropbox.com/s/e7bep6ouwhrojxa/harry_potter_vc1_lpcm_test.mkv?dl=0

Thanks.
Title: Re: 2.8.0 repeatable crash - could be VC-1 video or LPCM audio related
Post by: szlldm on January 01, 2022, 12:55:51 PM
Looks like audio related: "Overflow in reading  mkv audio".
Title: Re: 2.8.0 repeatable crash - could be VC-1 video or LPCM audio related
Post by: szlldm on January 01, 2022, 01:05:27 PM
As a temporary solution, you could remove the LPCM track, for example with MKVToolNix.
Title: Re: 2.8.0 repeatable crash - could be VC-1 video or LPCM audio related
Post by: bconway on January 01, 2022, 02:40:54 PM
Quote from: szlldm on January 01, 2022, 01:05:27 PMAs a temporary solution, you could remove the LPCM track, for example with MKVToolNix.
Thank you, I will do that. Hopefully the sample file is useful to someone.
Title: Re: 2.8.0 repeatable crash - could be VC-1 video or LPCM audio related
Post by: eumagga0x2a on January 01, 2022, 11:03:40 PM
The problem arises because we assume AAC_LATM for the second track from encountering MS/ACM compatibility layer with non-zero extradata (replacing MKV_MUX_LATM with WAV_PCM "fixes" the second audio track, the question is only how to tell various MS/ACM encapsulated audio types from each other).
Title: Re: 2.8.0 repeatable crash - could be VC-1 video or LPCM audio related
Post by: eumagga0x2a on January 01, 2022, 11:07:57 PM
I cut a corner too recklessly in [demuxers/Matroska] Try to cope with LATM encapsulated AAC streams (https://github.com/mean00/avidemux2/commit/63077d465cd6aa9422ee7ca8bf9770b87a4e4def).
Title: Re: 2.8.0 repeatable crash - could be VC-1 video or LPCM audio related
Post by: eumagga0x2a on January 02, 2022, 04:14:49 PM
diff --git a/avidemux_plugins/ADM_demuxers/Matroska/ADM_mkvEntries.cpp b/avidemux_plugins/ADM_demuxers/Matroska/ADM_mkvEntries.cpp
index 3ba20a63e..21ae0ac58 100644
--- a/avidemux_plugins/ADM_demuxers/Matroska/ADM_mkvEntries.cpp
+++ b/avidemux_plugins/ADM_demuxers/Matroska/ADM_mkvEntries.cpp
@@ -303,18 +303,21 @@ uint8_t mkvHeader::analyzeOneTrack(void *head,uint32_t headlen)
            {
                mixDump(entry.extraData,l);
                memcpy(&(t->wavHeader),entry.extraData,wavSize);
-                ADM_info("Encoding : %d\n",t->wavHeader.encoding);
-                wavSize+=2; // size of WAVEFORMATEX
+                ADM_info("Encoding : 0x%x\n",t->wavHeader.encoding);
+                if(t->wavHeader.encoding == 0xfffe)
+                    wavSize+=2; // size of WAVEFORMATEX
                int x=l-wavSize;
 
-                if(x>0) // If we have more than WAVEFORMATEX, it is extradata
+                if(t->wavHeader.encoding == 0xfffe)
+                {
+                    ADM_warning("Setting encoding to WAV_PCM\n");
+                    t->wavHeader.encoding = WAV_PCM;
+                }else if(x>0) // If we have more than WAVEFORMATEX, it is extradata
                {
                    ADM_info("Found %d bytes of extradata\n",x);
                    t->extraData=new uint8_t[x];
                    t->extraDataLen=x;
                    memcpy(t->extraData,entry.extraData+wavSize,x);
-                    if(t->wavHeader.encoding==0xfffe) // WAVE_FORMAT_EXTENSIBLE + extradata: might be AAC LATM
-                        t->wavHeader.encoding=MKV_MUX_LATM;
                }
                if(t->wavHeader.encoding==MKV_MUX_LATM)
                {

should fix that, just need to clarify whether it is okay to open the tree right now.
Title: Re: 2.8.0 repeatable crash - could be VC-1 video or LPCM audio related
Post by: bconway on January 02, 2022, 04:20:01 PM
Thanks for looking at this!
Title: Re: 2.8.0 repeatable crash - could be VC-1 video or LPCM audio related
Post by: eumagga0x2a on January 02, 2022, 04:30:08 PM
This patch won't fix broken timestamps in the video stream, however.

Regarding the PCM audio track, the problem would have been avoided if MakeMKV had used the proper tag for the codec (A_PCM/INT/LIT).
Title: Re: 2.8.0 repeatable crash - could be VC-1 video or LPCM audio related
Post by: eumagga0x2a on January 03, 2022, 09:41:21 PM
A more or less proper fix (https://github.com/mean00/avidemux2/commit/5bf6bd7a60c09f13278fd9e1a16bd38652295d57) for the issue of misidentified audio track has been pushed to the repository. It may take quite a while until fresh nightly builds from the master branch get generated and uploaded, though.