News:

--

Main Menu

MKV audio but no video or "muxer cannot open"

Started by Ramboso, January 30, 2022, 03:34:23 PM

Previous topic - Next topic

Ramboso

Windows 10
with avidemux 2.7.8 when i cut an mkv (video HEVC and AAC audio) i receive with copy/copy/mkv muxer a mkv with the right size but with no video shown (the audio works well)

with avidemux 2.8 instead, when I'm trying to save I receive the error "muxer, cannot open"

How can i solve this?

eumagga0x2a

This must be specific to the file you try to save in copy mode. For starters, please reproduce the error using the latest available nightly build (r220130 at the moment), close Avidemux and keep it closed until you move or copy admlog.txt from %localappdata%\avidemux\ to a different location to avoid it being overwritten next time you launch Avidemux, then attach this admlog.txt to your reply.

Ramboso

I tried with 2.8.1 r220130 win64 and it still shows the error "muxer, cannot open".

admlog.txt is 11.4 MB (max size attachable is 256KB) so here is the link for downloading from mega:

https://mega.nz/file/YVlUnKaZ#OFZW4BWaeDioJDia7B_qAYkCN3HZRa0eA6UBnvgIGSg

eumagga0x2a

Thank you, the huge size of the log in this case is a bug in itself and should be fixed in future builds by the commit [demuxers/Matroska] Decode H.264 and HEVC NAL size only once.

The reason why things go wrong is bad global HEVC extradata (the information which tells the decoder how to interpret compressed data in video frames) in the source file. The first byte must be 1 (0x01), but it is 0 (0x00) here. Do you know by chance which application has created the file and the video stream?

You could try to load a copy of the file in a hex editor and replace the first byte of the extradata (please use MKVToolNix to identify the offset in the file).

Ramboso

#4
Hi, thanks for the reply.
I'm trying with 2 mkvs HEVC, both have the errors "matroska cannot open" with avidemux 2.8 or "saved mkv with audio but no video while correct GB size" with previous avidemux release.
I only trying to cut the last 5 minutes, using keyframe of course.

The first mkv is the original one, took from the web:
Writing application: mkvmerge v6.8.0 ('Theme for Great Cities') 64bit built on Mar  2 2014
Writing library: libebml v1.3.0 + libmatroska v1.4.1

The second mkv was created with mkvtoolinxGUI:
I merged the video (I took only the video track) of the first mkv with an AAC track (obtained from audacity)
mediainfo says:
mkvmerge v30.1.0 ('forever and more') 64bit
Writing library: libebml v1.3.6 + libmatroska v1.4.9


Quote from: eumagga0x2a on January 31, 2022, 04:30:31 PMYou could try to load a copy of the file in a hex editor and replace the first byte of the extradata (please use MKVToolNix to identify the offset in the file).

Sorry but, as a newbie, I didn't understand what to do.
Can you put that sentence in simple words or tell me exactly what to do?

eumagga0x2a

Quote from: Ramboso on February 02, 2022, 08:26:37 AMThe first mkv is the original one, took from the web

I see, so just a single one damaged file from probably dubious sources as copy operations don't change bad extradata (called "codec's private data" by MKVToolNix).

Quote from: Ramboso on February 02, 2022, 08:26:37 AM
Quote from: eumagga0x2a on January 31, 2022, 04:30:31 PMYou could try to load a copy of the file in a hex editor and replace the first byte of the extradata (please use MKVToolNix to identify the offset in the file).
Sorry but, as a newbie, I didn't understand what to do.
Can you put that sentence in simple words or tell me exactly what to do?

If you open the admlog.txt file you provided in a text editor and skip to line 202328, you will see the following:

[ADM_EditorSegment::addReferenceVideo] The video codec has some extradata (110 bytes)

 0000 : ..`.........x...  00 01 60 00 00 00 80 00 00 00 00 00 78 f0 00 fc
 0010 : .....G. ... @...  fd f8 f8 00 00 47 03 20 00 01 00 20 40 01 0c 01
 0020 : ...`............  ff ff 01 60 00 00 03 00 80 00 00 03 00 00 03 00
 0030 : x.........j.!...  78 95 c0 c0 00 00 fa 00 00 17 6a 14 21 00 01 00
 0040 : "B...`..........  22 42 01 01 01 60 00 00 03 00 80 00 00 03 00 00
 0050 : ..x....2.Y^I2.P   03 00 78 a0 03 c0 80 32 16 59 5e 49 32 bb 50 20
 0060 :  P."....D..s..    20 50 10 22 00 01 00 06 44 01 c1 73 c1 89

The first octet (byte) is 0 (or 0x00 where 0x indicates that the following number is hexadecimal rather than decimal, Avidemux leaves 0x out but keeps both zeros for proper visual alignment and thus better legibility), but it must be 0x01. The second byte is 1 (0x01), so either the first one is wrong or the whole extradata is shifted by one byte, but I guess the former is more likely and is easier to change.

To test whether changing just this one byte from 0 to 1 (actually, this flips just a single bit) is enough to repair the file, you need to, well, modify the file using a hex editor. To do this, you need to know exactly how many bytes you need to skip from the start of the file to land at a position where HEVC extradata begins. Use MKVToolNix info tool to identify the position of "Codec's private data" for the video track. At this position, you will see a sequence of bytes 0x63 0xA2 0x6E which is the ID of the Matroska element holding extradata (the first two bytes) and the length of the extradata (0x6E = 110). The bytes following this element header are extradata, you need to replace 0x00 immediately following 0x6E with 0x01 and save the file.

Of course, please operate on a copy of the file to have an unmodified backup in case something goes wrong.

eumagga0x2a

If the video is innocuous enough, you could also provide the first ~200 MiB of the source file as a sample via WeTransfer, Mega, Dropbox or Google Drive so that I can test it for you. Please use a tool like head or dd on *nix systems which cuts files completely independently from their content, don't use ffmpeg or any video editors for this task!

Ramboso

#7
It worked, my master.

So I use MKVToolNix info tool to identify the position of "Codec's private data" for the video track, which is 4387.

Then I opened the mkv with HxD and went:
search > go to... >
first I selected DEC
then
offset: 4387
offset relative to: begin

I landed on the 63 of this line

45 56 43 63 A2 EE 00 01 60 00 00 00 80 00 00 00

So I deleted the 00 after EE and put 01 via:

edit > insert bytes >

bytecount: 1
hex selected
hex-values: 01


Then I saved the new mkv, cut it with avidemux and saved with copy/copy/mkv muxer.
I didn't receive the error "muxer, cannot open" and the video is also shown.




Now I want to put a logo (png with transparent background) in the last 10 second of the mkv, then add 3 mins of another mkv. I have 2 problem:.

1) I can't add a transparent png logo via "add logo", it only works with png (but it has white background).
I also noticed that I can't put filters in "copy video output", but only if I select an actual codec (x265 for me).
Is it right?
What can I do?

2) I try to merge this mkv with the mkv that I resized to become 1920*800 (same as first mkv).
They are both HEVC.
If i save in copy/copy/mkv muxer I receive the error "codec or codec settings across a cut point do not match" and in fact the video is damaged after the joint point.
I know that works if I save in "x265 output video" but this stress the CPU for more than 6 hours and it still will not have the logo.
Can I save the file in "copy output video", without errors, maybe changing something with the HEX editor?

Anyway, doing another x265 compression, will not reduce the size of the file and maybe lost a bit of image quality (i.e. the texture of some scene)?
For example, before I can solve the puzzle thanks to your hex instructions, I had this problem trying with VSDC VIDEO EDITOR with the same mkvs.
The file still have the same resolution (1980*800) but the texture of some scene is gross compared to the original mkv.

eumagga0x2a

Quote from: Ramboso on February 02, 2022, 06:37:19 PMI jumped on the 63 of this line

45 56 43 63 A2 EE 00 01 60 00 00 00 80 00 00 00

Really 0xEE? 0xEE = 238 bytes instead of expected 0x6E = 110. The difference is again just a single flipped bit. It looks for me as if either the data in the file is way more corrupted than initially thought or your hardware is faulty and causes the defects in the first place.

Quote from: Ramboso on February 02, 2022, 06:37:19 PM1) I can't add a transparent png logo via "add logo", it only works with png (but it has white background).

You need to create a PNG image with transparency, yes. What is the problem with that? This is a more or less trivial task for an image editing software like e.g. The GIMP.

Or did you mean that transparent areas of a PNG are displayed opaque white in filter preview in Avidemux? I just checked, it works fine for me with my local build on Linux and I would not expect this to be suddenly broken for other platforms but who knows...

Quote from: Ramboso on February 02, 2022, 06:37:19 PMI also noticed that I can't put filters in "copy video output", but only if I select an actual codec (x265 for me).
Is it right?

Yes, it is. Any modification of the picture implies that the video needs to be re-encoded. For this reason video filters are not accessible when in copy mode to keep users from adding filters in copy mode and complaining about them having no effect.

Quote from: Ramboso on February 02, 2022, 06:37:19 PMWhat can I do?

Re-encode the video  :)

Quote from: Ramboso on February 02, 2022, 06:37:19 PM2) I try to merge this mkv with the mkv that I resized to become 1920*800 (same as first mkv).
They are both HEVC.
If i save in copy/copy/mkv muxer I receive the error "codec or codec settings across a cut point do not match" and in fact the video is damaged after the joint point.

This is what the compatibility check in Avidemux is for. To be able to save appended video in copy mode, all codec settings (i.e. the entire extradata) of all videos involved must match perfectly, bit for bit.

Quote from: Ramboso on February 02, 2022, 06:37:19 PMCan I save the file in "copy output video", without errors, maybe changing something with the HEX editor?

No, there is nothing you can easily correct with a hex editor. If the first video was generated by x265 encoder and it has documented its configuration (MediaInfo application would report it if present), you could try re-encoding the second one using exactly the same configuration. This may work, but it is a tedious task.

Quote from: Ramboso on February 02, 2022, 06:37:19 PMAnyway, doing another x265 compression, will not reduce the size of the file and maybe lost a bit of image quality (i.e. the texture of some scene)?

As the HEVC compression is lossy, any additional generation will both worsen the quality and inflate stream size.

Ramboso

Quote from: eumagga0x2a on February 02, 2022, 08:46:16 PMReally 0xEE? 0xEE = 238 bytes instead of expected 0x6E = 110. The difference is again just a single flipped bit. It looks for me as if either the data in the file is way more corrupted than initially thought or your hardware is faulty and causes the defects in the first place.

It's EE in the first mkv dowloaded from the web, although mkv toolnix info shows 110 of dimension

Quote from: eumagga0x2a on February 02, 2022, 08:46:16 PM
Quote1) I can't add a transparent png logo via "add logo", it only works with png (but it has white background).

You need to create a PNG image with transparency, yes. What is the problem with that? This is a more or less trivial task for an image editing software like e.g. The GIMP.

Or did you mean that transparent areas of a PNG are displayed opaque white in filter preview in Avidemux? I just checked, it works fine for me with my local build on Linux and I would not expect this to be suddenly broken for other platforms but who knows...

I already have the png, that's a sentence with solid words and transparent background.

You cannot view this attachment.

When I select it from avidemux "add logo" filter, it still shows "no image selected" beside the "select image" button, like I didn't select anything. It works with the jpg image instead (that have solid words but white background, obviously ruining the video).

You cannot view this attachment.

I'm using 2.8.1 r220130 win64 on windows 10.


Quote from: eumagga0x2a on February 02, 2022, 08:46:16 PMIf the first video was generated by x265 encoder and it has documented its configuration (MediaInfo application would report it if present), you could try re-encoding the second one using exactly the same configuration. This may work, but it is a tedious task.

The 1st video is the second one of this quote (created from the first and then with mkvtoolnix),
Quote from: Ramboso on February 02, 2022, 08:26:37 AMThe first mkv is the original one, took from the web:
Writing application: mkvmerge v6.8.0 ('Theme for Great Cities') 64bit built on Mar  2 2014
Writing library: libebml v1.3.0 + libmatroska v1.4.1

The second mkv was created with mkvtoolinxGUI:
I merged the video (I took only the video track) of the first mkv with an AAC track (obtained from audacity)
mediainfo says:
mkvmerge v30.1.0 ('forever and more') 64bit
Writing library: libebml v1.3.6 + libmatroska v1.4.9

 then hex edited, cutted with avidemux and saved in copy video output; media info shows:
created with: Lavf58.76.100
compressor: Lavf58.76.100
errordetectiontype: per level 1

So it's always been an HEVC, 1920*1080.


The second mkv that I want to merge was an AVC mkv 854*480p
 created with: handbrake 1.07 2017010900
compressor: Lavf57.7.2

that I cutted, resized with avidemux and encoded with x265 in video output and then is:
HEVC 1920*800 mkv
created with: Lavf58.76.100
compressor: Lavf58.76.100
errordetectiontype: per level 1

So I don't think I can use the same configuration, with avidemux at least.

Anyway, I understand that I have to re-encode in x265 but really the png logo is still a problem with avidemux. I don't have linux so I can't try on that OS.

Quote from: eumagga0x2a on February 02, 2022, 08:46:16 PMAs the HEVC compression is lossy, any additional generation will both worsen the quality and inflate stream size.
Ok, thanks. For that reason (and for the 6 hours running process on the CPU at 100%) I want to re-encode the whole thing only when I will solve the png logo problem  ::)

Ramboso

#10
I solved the png logo issue loading the png with already transparence background
Quote from: Ramboso on February 03, 2022, 10:45:03 AMpreviewtext.png
on this page https://transparent.imageonline.co/ and download the new png, that seems the same.

You cannot view this attachment.

With this new png file, it works, don't know why.

Maybe if you want to try with the same files that I posted, you will find the bug and maybe fix it for a new release.

Disclaimer: The first png logo was downloaded from fontmeme.com and not created by me.

Quote from: Ramboso on February 03, 2022, 10:45:03 AM
QuoteAs the HEVC compression is lossy, any additional generation will both worsen the quality and inflate stream size.
Ok, thanks. For that reason (and for the 6 hours running process on the CPU at 100%) I want to re-encode the whole thing only when I will solve the png logo problem  ::)

So I re-encoded the video in HEVC (x265) and the texture went bad, also the GB size was reduced.
Which video codec output or configuration should I choose to keep the GB file size approximately the same without losing quality (almost as if it is in copy output)?

eumagga0x2a

Quote from: Ramboso on February 03, 2022, 05:52:09 PMWith this new png file, it works, don't know why.

The PNG file which doesn't work in Avidemux uses a pretty exotic pixel format YA8 (8 bits luminance, 8 bits alpha) we don't support. The one which works uses the usual RGBA.

Quote from: Ramboso on February 03, 2022, 05:52:09 PMSo I re-encoded the video in HEVC (x265) and the texture went bad, also the GB size was reduced.

This:

[ADM_PP] 11:39:46-833 Initializing postproc
[cleanup] 11:39:46-833 Deleting post proc
[update] 11:39:46-833 updating post proc
[update] 11:39:46-837 Enabled type:3 strength:3

Please make sure to disable post-processing. It is enabled and thus responsible for this quality loss (and compressibility gain).

Quote from: Ramboso on February 03, 2022, 10:45:03 AMIt's EE in the first mkv dowloaded from the web, although mkv toolnix info shows 110 of dimension

This is highly intriguing.

Ramboso

#12
Quote from: eumagga0x2a on February 03, 2022, 11:27:11 PMThe PNG file which doesn't work in Avidemux uses a pretty exotic pixel format YA8 (8 bits luminance, 8 bits alpha) we don't support. The one which works uses the usual RGBA.
Understand, I don't know where to find this info in file properties in windows10; thanks anyway.

Quote from: Ramboso on February 03, 2022, 05:52:09 PMSo I re-encoded the merged video in HEVC (x265) and the texture went bad, also the GB size was reduced.
Which video codec output or configuration should I choose to keep the GB file size approximately the same without losing quality (almost as if it is in copy output)?
Quote from: eumagga0x2a on February 03, 2022, 11:27:11 PMThis:

Code Select Expand
[ADM_PP] 11:39:46-833 Initializing postproc
[cleanup] 11:39:46-833 Deleting post proc
[update] 11:39:46-833 updating post proc
[update] 11:39:46-837 Enabled type:3 strength:3


Where should I write this code?

Quote from: eumagga0x2a on February 03, 2022, 11:27:11 PMPlease make sure to disable post-processing. It is enabled and thus responsible for this quality loss (and compressibility gain).

You cannot view this attachment.
It was like this, except for "deringing" that wasn't checked.
But I don't understand if I have to keep the HEVC (x265) in video output or other codec. I'm talking about merging the 2 mkvs with the filter logo added.
Sorry for being inexperienced.

Quote from: eumagga0x2a on February 03, 2022, 11:27:11 PM
QuoteIt's EE in the first mkv dowloaded from the web, although mkv toolnix info shows 110 of dimension

This is highly intriguing.

The same with another mkv from the same author, and I hex edited that too of course.

eumagga0x2a

Quote from: Ramboso on February 04, 2022, 11:05:39 AMI don't know where to find this info in file properties in windows10

I actually used ffprobe on command line to obtain the info.

Quote from: Ramboso on February 04, 2022, 11:05:39 AMIt was like this, except for "deringing" that wasn't checked.

Avidemux doesn't enable post-processing by default since quite a long time already, but old versions did. You have probably inherited such a configuration. I would advise to disable post-processing completely, at least as precaution.

However, as szlldm pointed out (not on the forum), post-processing was entirely ineffective in 2.8.0 and subsequent 2.8.1 nightly builds, thus I must have been wrong attributing poor picture quality to post-processing.

Quote from: Ramboso on February 04, 2022, 11:05:39 AMBut I don't understand if I have to keep the HEVC (x265) in video output or other codec.

As you re-encode the entire video, you are free to choose whatever codec suits your needs best. HEVC is definitely one of the best lossy codecs available (well, the other is VP9) and the x265 encoder for HEVC is orders of magnitude faster than the libvpx-based VP9 encoder. Usually the choice is either H.264 (encoder: x264) for best compatibility and still a good quality, HEVC for best quality and encoding speed to compression rate ratio but worse HW decoder support and VP9 for best quality when encoding speed and HW decoder support don't matter (or you know that your target device can decode VP9 in hardware).

If you try to re-encode just the video you try to append in order to use copy mode to export the result of merging, you obviously would need to re-encode to HEVC as the first video is HEVC. However, without knowing the exact x265 configuration used to generate the first video, it is almost impossible to guess it right so that resulting extradata matches the one of the first video.

Ramboso

#14
Ok, understand.
Quote from: eumagga0x2a on February 04, 2022, 12:24:57 PMIf you try to re-encode just the video you try to append in order to use copy mode to export the result of merging, you obviously would need to re-encode to HEVC as the first video is HEVC. However, without knowing the exact x265 configuration used to generate the first video, it is almost impossible to guess it right so that resulting extradata matches the one of the first video.
I though about that.
The second mkv is HEVC, but, as you pointed out, they were generated by different programs.
Isn't this the x265 configuration used to generate the first video?
Quote from: Ramboso on February 02, 2022, 08:26:37 AMThe first mkv is the original one, took from the web:
Writing application: mkvmerge v6.8.0 ('Theme for Great Cities') 64bit built on Mar  2 2014
Writing library: libebml v1.3.0 + libmatroska v1.4.1
Or are you talking about CFR and other stuff like that?

Anyway, the first merged x265 mkv has a CRF of 20 (default in avidemux I think), a ruined texture and it is 730MB smaller (2.41GB vs 1.78 GB). Talking about the one mentioned in this message.
Quote from: Ramboso on February 03, 2022, 05:52:09 PMSo I re-encoded the video in HEVC (x265) and the texture went bad, also the GB size was reduced.

I tried to re-encode a small sample (30 seconds) of the video with different CRFs, and it seems to me that 15 CRF don't mess the texture, but the GB size is more than doubled, without considering the time taken in the process.