[FFmpeg-user] Unable to record VP8+Opus from RTP+SDP

Juan Navarro juan.navarro at gmx.es
Mon Aug 12 18:59:30 EEST 2019


Hi,

I'd like to record an RTP stream with one VP8 video and one OPUS audio;
these are originated from Chrome and then distributed as plain RTP
streams. I've written a basic SDP file to use as input for ffmpeg, but
my results have been mixed:

1) Recording only the video works fine with a WEBM container (using
"-vcodec copy -an -f webm"). ffmpeg is able to automatically find out
properties of the video, such as the resolution, and it stores it fine.
Other players (VLC tested) are able to open the file.

2) Recording only the audio is possible, again if using WEBM (with
"-acodec copy -vn -f webm"), but seems that no Opus headers/metadata are
stored. While ffplay is able to play the recorded file, other players
complain about it. E.g. VLC says "opus error: cannot read Opus header",
"opus error: initial Opus header is corrupted". There is, however, no
error or warning message printed out from the debug FFmpeg output.

Interestingly enough, using other container, e.g. OGG (with "-f opus"
and a .ogg output file), then the recording won't start at all due to
missing extradata:

    [opus @ 0x5e5d380] No extradata present
    Could not write header for output file #0 (incorrect codec
    parameters ?): Invalid data found when processing input


3) Recording of both audio and video in WEBM or Matroska doesn't work,
ffmpeg complains about not being able to get the video resolution (but
it was able to do so when recording only video):

    [sdp @ 0x6094a00] Could not find codec parameters for stream 1
    (Video: vp8, 1 reference frame, yuv420p): unspecified size
    Consider increasing the value for the 'analyzeduration' and
    'probesize' options
    [webm @ 0x6098640] dimensions not set
    Could not write header for output file #0 (incorrect codec
    parameters ?): Invalid argument

Note that I've already tried setting analyzeduration and probesize to
10M, this takes a long time to start the ffmpeg command but in the end
doesn't really change the outcome.


This is the input SDP:

    v=0
    o=- 0 0 IN IP4 127.0.0.1
    s=-
    c=IN IP4 127.0.0.1
    t=0 0
    m=audio 5006 RTP/AVP 109
    a=rtpmap:109 opus/48000/2
    m=video 5004 RTP/AVP 120
    a=rtpmap:120 VP8/90000



And these are the commands:

# Audio recording

    ffmpeg -protocol_whitelist file,rtp,udp \
         -fflags +genpts -i input.sdp \
         -map 0:a:0 -acodec copy -vn \
         -f webm -flags +global_header -y recording.webm


# Video recording

    ffmpeg -protocol_whitelist file,rtp,udp \
         -fflags +genpts -i input.sdp \
         -map 0:v:0 -vcodec copy -an \
         -f webm -flags +global_header -y recording.webm


# Audio+Video recording, this is the final use case I'd like to end up
solving, although being able to run the previous two commands will help
me learn and understand more about how FFmpeg works:

    ffmpeg -protocol_whitelist file,rtp,udp -nostdin -loglevel debug \
         -fflags +genpts -i input.sdp \
         -map 0:a:0 -map 0:v:0 -acodec copy -vcodec copy \
         -f webm -flags +global_header -y recording.webm




Given how easy it is to break the recording of the audio (eg. when
trying OGG format, instead of WEBM), I'm inclined to think that these
problems are matter of finding the right options for some of the ffmpeg
commands, and make the streams play well with the container. I want to
avoid transcoding, so all codecs should be "copy". After all, the target
here is to just store incoming media from Chrome, not to reencode it...

Could anyone give me a hand here?


PS. If anyone has a solution and wants the karma, I posted this question
in SuperUser:
https://superuser.com/questions/1468786/rtp-ffmpeg-dimensions-not-set-only-when-there-is-audiovideo



----

Full ffmpeg debug output:

ffmpeg version 4.2-static https://johnvansickle.com/ffmpeg/ Copyright
(c) 2000-2019 the FFmpeg developers
   built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
   configuration: --enable-gpl --enable-version3 --enable-static
--disable-debug --disable-ffplay --disable-indev=sndio
--disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r
--enable-gnutls --enable-gmp --enable-libgme --enable-gray
--enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf
--enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband
--enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis
--enable-libopus --enable-libtheora --enable-libvidstab
--enable-libvo-amrwbenc --enable-libvpx --enable-libwebp
--enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d
--enable-libxvid --enable-libzvbi --enable-libzimg
   libavutil      56. 31.100 / 56. 31.100
   libavcodec     58. 54.100 / 58. 54.100
   libavformat    58. 29.100 / 58. 29.100
   libavdevice    58.  8.100 / 58.  8.100
   libavfilter     7. 57.100 /  7. 57.100
   libswscale      5.  5.100 /  5.  5.100
   libswresample   3.  5.100 /  3.  5.100
   libpostproc    55.  5.100 / 55.  5.100
Splitting the commandline.
Reading option '-protocol_whitelist' ... matched as AVOption
'protocol_whitelist' with argument 'file,rtp,udp'.
Reading option '-nostdin' ... matched as option 'stdin' (enable or
disable interaction on standard input) with argument 0.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging
level) with argument 'debug'.
Reading option '-fflags' ... matched as AVOption 'fflags' with argument
'+genpts'.
Reading option '-i' ... matched as input url with argument 'input.sdp'.
Reading option '-map' ... matched as option 'map' (set input stream
mapping) with argument '0:a:0'.
Reading option '-map' ... matched as option 'map' (set input stream
mapping) with argument '0:v:0'.
Reading option '-acodec' ... matched as option 'acodec' (force audio
codec ('copy' to copy stream)) with argument 'copy'.
Reading option '-vcodec' ... matched as option 'vcodec' (force video
codec ('copy' to copy stream)) with argument 'copy'.
Reading option '-f' ... matched as option 'f' (force format) with
argument 'webm'.
Reading option '-flags' ... matched as AVOption 'flags' with argument
'+global_header'.
Reading option '-y' ... matched as option 'y' (overwrite output files)
with argument '1'.
Reading option 'recording.webm' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option nostdin (enable or disable interaction on standard
input) with argument 0.
Applying option loglevel (set logging level) with argument debug.
Applying option y (overwrite output files) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url input.sdp.
Successfully parsed a group of options.
Opening an input file: input.sdp.
[NULL @ 0x6094a00] Opening 'input.sdp' for reading
[sdp @ 0x6094a00] Format sdp probed with size=2048 and score=50
[sdp @ 0x6094a00] audio codec set to: opus
[sdp @ 0x6094a00] audio samplerate set to: 48000
[sdp @ 0x6094a00] audio channels set to: 2
[sdp @ 0x6094a00] video codec set to: vp8
[udp @ 0x609d480] end receive buffer size reported is 131072
[udp @ 0x6096f80] end receive buffer size reported is 131072
[sdp @ 0x6094a00] setting jitter buffer size to 500
[udp @ 0x6097e80] end receive buffer size reported is 131072
[udp @ 0x6097600] end receive buffer size reported is 131072
[sdp @ 0x6094a00] setting jitter buffer size to 500
[sdp @ 0x6094a00] Before avformat_find_stream_info() pos: 157 bytes
read:157 seeks:0 nb_streams:2

[sdp @ 0x6094a00] max_analyze_duration 5000000 reached at 5000000
microseconds st:0
[sdp @ 0x6094a00] Could not find codec parameters for stream 1 (Video:
vp8, 1 reference frame, yuv420p): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize'
options

[sdp @ 0x6094a00] After avformat_find_stream_info() pos: 157 bytes
read:157 seeks:0 frames:252
Input #0, sdp, from 'input.sdp':
   Metadata:
     title           : -
   Duration: N/A, start: 0.000000, bitrate: N/A
     Stream #0:0, 252, 1/48000: Audio: opus, 48000 Hz, stereo, fltp
     Stream #0:1, 0, 1/90000: Video: vp8, 1 reference frame, yuv420p,
90k tbr, 90k tbn, 90k tbc
Successfully opened the file.
Parsing a group of options: output url recording.webm.
Applying option map (set input stream mapping) with argument 0:a:0.
Applying option map (set input stream mapping) with argument 0:v:0.
Applying option acodec (force audio codec ('copy' to copy stream)) with
argument copy.
Applying option vcodec (force video codec ('copy' to copy stream)) with
argument copy.
Applying option f (force format) with argument webm.
Successfully parsed a group of options.
Opening an output file: recording.webm.
[file @ 0x60e7000] Setting default whitelist 'file,crypto'

Successfully opened the file.
[webm @ 0x6098640] dimensions not set
Could not write header for output file #0 (incorrect codec parameters
?): Invalid argument
Stream mapping:
   Stream #0:0 -> #0:0 (copy)
   Stream #0:1 -> #0:1 (copy)
     Last message repeated 1 times
[AVIOContext @ 0x6123800] Statistics: 0 seeks, 0 writeouts

[AVIOContext @ 0x6095480] Statistics: 157 bytes read, 0 seeks



More information about the ffmpeg-user mailing list