Vanilagy/webm-muxer

Corrupt videos

Closed this issue · 4 comments

Hi
Some videos I encoded are corrupted and can't be played in any player.

Using FFMPEG, i get the following error. Something about "unspecified pixel format" and "analyzeduration" and "probesize".
Do you have any Idea what might be wrong?

[matroska,webm @ 0000021cea7ab4c0] Could not find codec parameters for stream 0 (Video: vp9 (Profile 0), none(tv, smpte170m), 1280x1280): unspecified pixel format
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
Input #0, matroska,webm, from '.\test.mp4':
Metadata:
encoder : https://github.com/Vanilagy/webm-muxer
Duration: 00:00:09.64, start: 0.000000, bitrate: 2229 kb/s
Stream #0:0(eng): Video: vp9 (Profile 0), none(tv, smpte170m), 1280x1280, SAR 1:1 DAR 1:1, 1k tbr, 1k tbn (default)

How did you encode the video? Show me your code. Looks like the decoder-specific information is missing.

function initEncoder(
    encoderConfig: VideoEncoderConfig,
    muxerCodec: string,
): { mux: Muxer<ArrayBufferTarget>; enc: VideoEncoder } {
    // https://github.com/Vanilagy/webm-muxer
    let mux = new Muxer({
        target: new ArrayBufferTarget(),
        video: {
            codec: muxerCodec, // V_VP9, V_VP8, V_VP9, V_AV1, A_OPUS and A_VORBIS.
            width: encoderConfig.width,
            height: encoderConfig.height,
        },
        firstTimestampBehavior: 'offset', //'strict' | 'offset' | 'permissive'
    });

    let enc = new VideoEncoder({
        output: (chunk, meta) => {
            mux.addVideoChunk(chunk, meta as any);
            postMessage(EncodeWorkerResponse.FRAME_ENCODED({}));
        },
        error: e => console.error(e),
    });
    enc.configure(encoderConfig);

    return { mux, enc };
}
newFrame = new VideoFrame(offCanvas, {
        timestamp: frame.timestamp,
    });
   
    frameCounter++;
    let keyFrame = false;

    if (performance.now() - lastKeyFrame >= 300) {
        keyFrame = true;
        lastKeyFrame = performance.now();
    }

    encoder.encode(newFrame, { keyFrame });
    newFrame.close();

    if (payload.stopAfterFrame) {
        await encoder.flush();
        encoder?.close();

        muxer.finalize(); // Buffer contains final WebM file
        const buffer = muxer.target;
        lastKeyFrame = 0;

        if (buffer) {
            postMessage(EncodeWorkerResponse.ENCODING_COMPLETE({ data: buffer.buffer }));
        } else {
            postMessage(E.left({ message: 'invalid buffer after multiplexing' }));
        }
    }

The codec is either one of ['vp8', 'vp8.0', 'vp09.00.10.08', 'vp09.02.10.08', 'av01.0.05M.08', 'av01.0.08M.08']

It worked so far, the problems might have started with Chrome 130.0.0.0 update, but this I am still investigating.

Hi, @Vanilagy fyi I found the problem:

It seems that the Problem is Android 15 together with vp9, both profiles produce corrupt videos.
For now I disabled vp9 in our app. Thanks

@davidstrahm I see! Good to know. If you think this is a Chromium issue, you should report it.