[FFmpeg-user] FFMPEG HTTP to RTP then RTP to HTTP with OPUS

Brad Hambleton brad.j.hambleton at gmail.com
Mon Jun 8 13:09:15 EEST 2020


I'm taking a HTTP output to FFMPEG and copying the audio (no video) to an
RTP:
ffmpeg -i http://192.168.0.40:20110 -c:a copy -f rtp rtp://
192.168.87.40:20210?pkt_size=1328 -sdp_file opus.sdp

At the other end receiving the RTP and pushing it back to HTTP:
ffmpeg -re -protocol_whitelist rtp,file,udp -i opus.sdp -c:a copy -listen 1
-method GET -f opus http://192.168.87.40:20220

2 Problems:

1) Currently the encoding process doesn't optimize packets.
92 1.004672 192.168.0.40 192.168.0.40 UDP 392 52954 → 20210 Len=332
93 1.004727 192.168.0.40 192.168.0.40 UDP 392 52954 → 20210 Len=332
94 1.004789 192.168.0.40 192.168.0.40 UDP 392 52954 → 20210 Len=332
95 1.004855 192.168.0.40 192.168.0.40 UDP 392 52954 → 20210 Len=332
96 1.004908 192.168.0.40 192.168.0.40 UDP 392 52954 → 20210 Len=332

Each packet length is 332, which leaves a lot of wasted space.  I'd like to
get close to 1500 (Stack 4 together I get 1328 which is close enough)
Is there a command in the FFMPEG/RTP that will optimize packets?
I added ?pkt_size=1328 to the RTP however that only sets max, not
preferred.

2) I get the following error when I try to HTTP to RTP via copy:
C:\Decode>ffmpeg -re -protocol_whitelist rtp,file,udp -i opus.sdp -c:a copy
-listen 1 -method GET -f opus http://192.168.0.40:20220
ffmpeg version git-2020-05-23-26b4509 Copyright (c) 2000-2020 the FFmpeg
developers
  built with gcc 9.3.1 (GCC) 20200523
  configuration: --enable-gpl --enable-version3 --enable-sdl2
--enable-fontconfig --enable-gnutls --enable-iconv --enable-libass
--enable-libdav1d --enable-libbluray --enable-libfreetype
--enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb
--enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy
--enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame
--enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264
--enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma
--enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf
--enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa
--enable-libspeex --enable-libxvid --enable-libaom --disable-w32threads
--enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid
--enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2
--enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 48.100 / 56. 48.100
  libavcodec     58. 87.101 / 58. 87.101
  libavformat    58. 43.100 / 58. 43.100
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 83.100 /  7. 83.100
  libswscale      5.  6.101 /  5.  6.101
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, sdp, from 'opus.sdp':
  Metadata:
    title           : No Name
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Audio: opus, 48000 Hz, stereo, fltp
[opus @ 00000221a9a4d280] No extradata present
Could not write header for output file #0 (incorrect codec parameters ?):
Invalid data found when processing input
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
    Last message repeated 1 times

Tried a variety of additions to the RTP to HTTP CLI to get it to work, but
still nothing.

-flags -global_header -reconnect_streamed 1 -headers "X-Forwarded-For:
13.14.15.66"

Is there a specific OPUS or HTTP header that can be added to get it to
work.  Decoding and Encoding does work for RTP to HTTP, the idea isn't to
decode/encode at either point, just to copy the audio, change the
container..

Cheers


More information about the ffmpeg-user mailing list