Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mp4 muxer broken - missing h264 extradata (AVCC) #35

Open
jpietek opened this issue Feb 11, 2020 · 2 comments
Open

Mp4 muxer broken - missing h264 extradata (AVCC) #35

jpietek opened this issue Feb 11, 2020 · 2 comments

Comments

@jpietek
Copy link

jpietek commented Feb 11, 2020

I'm struggling to get the mp4 muxer output working on Windows10 default video stack, thus Adobe Premiere project bin (on third party players like VLC or Chrome it's playable). The video stream is not recognized at all, no metadata, nothing. Audio is fine.

The muxer is set up similarly as in the mp4 example:

        let vstr = this.mux.newStream({
            name: 'h264',
            encoderName: 'libx264',
            time_base: [1, 90000],
            interleaved: true,
            sample_aspect_ratio: [1, 1],
        });

        Object.assign(vstr.codecpar, {
            width: this.clip.dst_probe.width,
            height: this.clip.dst_probe.height,
            format: 'yuv420p',
            color_space: 'bt709',
            sample_aspect_ratio: [1, 1]
        });

MP4Box -info output, beamcoder muxer:

[iso file] Box "avcC" size 8 invalid (read 17
(...)
Track # 1 Info - TrackID 1 - TimeScale 90000 - Media Duration 00:00:00.840
Track has 2 edit lists: track duration is 00:00:00.920
Media Info: Language "und (und)" - Type "vide:avc1" - 21 samples
Visual Track layout: x=0 y=0 width=1920 height=1080
MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21
AVC/H264 Video - Visual Size 1920 x 1080
        AVC Info: 1 SPS - 0 PPS - Profile Unknown @ Level 1.6
        NAL Unit length bits: 8
[AVC/HEVC] Not enough bits in bitstream !!
[AVC/HEVC] Not enough bits in bitstream !!
[AVC/HEVC] Not enough bits in bitstream !!
[AVC/HEVC] Not enough bits in bitstream !!
[AVC/HEVC] Not enough bits in bitstream !!
[AVC/HEVC] Not enough bits in bitstream !!
[AVC/HEVC] Not enough bits in bitstream !!
        SPS#1 hash: 2C6E8EB7626F90A283FDE68C6FBE67EE19A48284
Self-synchronized
        RFC6381 Codec Parameters: avc1.000010
        Average GOP length: 21 samples

I've finally figured out that the problem is with missing h264 extradata (AVCC) in stream->codecpar. The source of the video is MPEGTS, which does not provide it (null in js object). I guess the ffmpeg automaticaly adds a proper bitstream filter while transmuxing ts->mp4 (?).

Any idea how to achieve a similar to ffmpeg behaviour with beamcoder? I've tried generating the AVCC bytes on my own, but got it a bit wrong, having some missing frames in the video. Would be easier to get it done with libav itself.

@jpietek jpietek changed the title Mp4 muxer output not working on Windows Mp4 muxer broken - missing h264 extradata (AVCC) Feb 13, 2020
@jpietek
Copy link
Author

jpietek commented Feb 18, 2020

OK, I'll answer myself in case someone stumbles upon a similar problem.
To fix the mp4 just assign in the mp4 muxer:
vstr.codecpar.extradata = ts_demux.streams[video_index].codecpar.extradata;

@scriptorian
Copy link
Contributor

Thanks for this. The bitstream filter docs say that for ffmpeg the h264_mp4toannexb filter is auto-inserted for MPEG-TS (muxer mpegts) and raw H.264 (muxer h264) output formats. More to do!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants