[FFmpeg-user] mp4 opus invalid extradata size (missing header)

Juan Navarro juan.navarro at gmx.es
Tue Sep 3 19:38:46 EEST 2019


Hi,

I'm trying to record a plain RTP stream, both with GStreamer and with
FFmpeg, with either H.264 or VP8 video codecs, and OPUS audio in all cases.

I got this working for VP8+OPUS (WEBM) with GStreamer and FFmpeg, and
H.264+OPUS (MP4) with GStreamer, but _not_ FFmpeg. After some testing I
was able to isolate the issue to recording OPUS audio with FFmpeg into
MP4 container (a somewhat uncommon combination I know, but afaik MP4
should be technically able to store OPUS, and it works great with
GStreamer so it is definitely possible).

FFmpeg is missing some extradata, and after the recording is done (after
pressing 'q'), no moov or any other kind of header is written to the MP4
file. However, I guess there is actual OPUS audio in the file, as the
file takes several 100s KB.

FFmpeg version is today's Git master. Report logs, and input SDP files,
are attached to this email (with full command line and output, as per
the '-report' option).

For example, trying to load the file with VLC 3.0.7 shows up this:

    VLC media player 3.0.7 Vetinari (revision 3.0.7-0-g86cee31)
    [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f12acc16500] invalid size 0 in stsd
    [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f12acc16500] error reading header
    TagLib: MP4: Invalid atom size
    Qt: Session management error: None of the authentication protocols
    specified are supported
    QApplication: invalid style override passed, ignoring it.
    [00007f12800049e0] mp4 demux error: MP4 plugin discarded (no
    moov,foov,moof box)
    [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f1280000c80] invalid size 0 in stsd
    [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f1280000c80] error reading header
    [00007f12800049e0] avcodec demux error: Could not open output.mp4:
    Unknown error 1094995529
    TagLib: MP4: Invalid atom size


For reference, these commands are used for my tests:

WORKS

    ffmpeg \
         -protocol_whitelist file,rtp,udp \
         -fflags +genpts \
         -i recording/input-vp8.sdp \
         -map 0:a:0 -c:a copy \
         -f webm -flags +global_header \
         -y recording/output-ffmpeg-opus.webm


WORKS

    gst-launch-1.0 --eos-on-shutdown \
         filesrc location=recording/input-h264.sdp \
             ! sdpdemux timeout=0 name=demux \
         mp4mux name=mux ! queue \
             ! filesink location=recording/output-gstreamer-opus.mp4 \
         demux. ! queue \
             ! rtpopusdepay \
             ! opusparse \
             ! mux.


FAILS ("no moov" errors during playback)

    ffmpeg \
         -protocol_whitelist file,rtp,udp \
         -fflags +genpts \
         -i recording/input-h264.sdp \
         -map 0:a:0 -c:a copy \
         -f mp4 -strict experimental \
         -y recording/output-ffmpeg-opus.mp4

Relevant output (full log in attached files):

    Press [q] to stop, [?] for help
    # Press 'q' after some time recording...
    [mp4 @ 0x75d2580] invalid extradata size=   0.0kbits/s speed= 1.4x
    Error writing trailer of recording/output-ffmpeg-opus.mp4: Invalid
    data found when processing input


The RTP transport is provided by a media server (mediasoup), but the
actual encoded media comes straight from a Chrome WebRTC connection
(mediasoup just receives it and relays as plain RTP).

Do I need to add some '-flags', '-bsf', or '-movflags' to make this work?

Juan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ffmpeg-opus-mp4.log
Type: text/x-log
Size: 9447 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-user/attachments/20190903/ddcfdc29/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ffmpeg-opus-webm.log
Type: text/x-log
Size: 86013 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-user/attachments/20190903/ddcfdc29/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: input-h264.sdp
Type: application/vnd.stardivision.impress
Size: 302 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-user/attachments/20190903/ddcfdc29/attachment.sdd>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: input-vp8.sdp
Type: application/vnd.stardivision.impress
Size: 215 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-user/attachments/20190903/ddcfdc29/attachment-0001.sdd>


More information about the ffmpeg-user mailing list