<!DOCTYPE html><html><head><title></title><style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><div>On Sat, Oct 31, 2020, at 5:17 AM, Carl Eugen Hoyos wrote:<br></div><blockquote type="cite" id="qt" style=""><div>> I am trying to write the contents of an RTP-OPUS stream to an OGG-OPUS file. The purpose is to send a WebRTC session to Google's Speech-to-text API, which accepts OGG-OPUS as input.<br></div><div>><br></div><div>> The opus muxer requires that an opus header be present in extradata. It seems that the demuxer from my RTP stream doesn't include this.<br></div><div>><br></div><div>> If I construct the opus header myself and insert it into extradata, everything works great. This seems like a hack though. Is this something that the RTP demuxer should be doing?<br></div><div><br></div><div>At least channel count and sample rate are supposed to be read<br></div><div>from the SDP file.<br></div></blockquote><div><br></div><div>Yes, indeed the sample rate and channel count is read by the sdp demuxer, specifically in rtsp.c/sdp_parse_rtpmap(). This function assigns these values to codecpar->sample_rate and codecpar->channels. The problem is that the opus muxer expects codecpar->extradata to also be set with a valid opus header. See oggenc.c/ogg_init, lines 500-504.<br></div><div><br></div><div>My question is, where is the appropriate place for extradata to be assigned?<br></div><div><br></div><div>1) Should it be done by the user? This is what I'm doing I'm done now. It feels like a hack and isn't possible unless you're using the C API.<br></div><div><br></div><div>2) Should it be done in the demuxer somewhere? ff_rtp_parse_open in rtpdec.c does some codec specific changes to codecpar. Maybe this is an appropriate place to build an opus header for extradata.<br></div><div><br></div><div>3) Should it be done in the muxer? Instead of throwing an error, maybe ogg_init() should create a header based on the sample_rate and channel count in codecpar. It can use some sensible defaults for the rest.<br></div><div><br></div><div>4) Carl, you had a patch about a year ago to libavcodev/opus.c that looks like it addressed a similar issue.<br></div><div><a href="https://ffmpeg.org/pipermail/ffmpeg-devel/2019-September/250177.html">https://ffmpeg.org/pipermail/ffmpeg-devel/2019-September/250177.html</a><br></div><div>It looks like the patch never landed because of a regression with webm playback. I noticed that the patch doesn't seem to assign the sample rate in the opus header (at offset 12), only the channel count (at offset 9). Maybe thats why?<br></div><div><br></div><div>Anyway, thanks for the reply!</div></body></html>