[FFmpeg-user] importing rtp packet stream and decoding

Dave Horton daveh at beachdognet.com
Fri Sep 22 21:50:08 EEST 2017


So I am trying to feed the captured rtp stream into ffmpeg and get a transcoded output.  Not quite working and I could use some help

Basically I have 
1.  An sdp file that describes the rtp, and indicates which port (on localhost) the rtp will be arriving on
2.  A process / utility that reads the rtp from a file and then streams it to that port.

I have a node.js application managing all of this — the idea is that it will spawn ffmpeg, send the SDP in on its stdin, instruct ffmpeg about the output, then spawn the utility to start the rtp stream.

I start up ffmpeg with these arguments:

ffmpeg  -loglevel debug -y  -protocol_whitelist file,crypto,udp,rtp,pipe -i pipe:0 map 0:0 foo.wav

I feed it the SDP, and at that point all looks good — from the logging (which I will show below) it appears like ffmpeg has decoded the SDP and started listening on the rtp port specified in the SDP (127.0.0.1:40558 in this case).

However, once it begins receiving rtp it logs an error:  "Unable to find a suitable output format for ‘'

Am I doing something wrong with my command above?  My intent is to instruct it to take the first rtp stream and encode it a wav file called ‘foo.wav’.

Here is the complete output (note because I am starting ffmpeg as a child process the logging is coming through the parent process which is adding the 'ffmpeg stderr says..’ etc)

************ console log
args: -loglevel debug -y  -protocol_whitelist file,crypto,udp,rtp,pipe -i pipe:0 map 0:0 foo.wav

ffmpeg stderr says: ffmpeg version N-85641-gdd49eff-tessus Copyright (c) 2000-2017 the FFmpeg developers
  built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
  configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzmq --enable-libzvbi --enable-version3 --disable-ffplay --disable-indev=qtkit

ffmpeg stderr says:   libavutil      55. 61.100 / 55. 61.100
  libavcodec     57. 93.100 / 57. 93.100
  libavformat    57. 72.101 / 57. 72.101
  libavdevice    57.  7.100 / 57.  7.100
  libavfilter     6. 86.100 /  6. 86.100
  libswscale      4.  7.101 /  4.  7.101
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '' ... matched as output url.
Reading option '-protocol_whitelist' ... matched as AVOption 'protocol_whitelist' with argument 'file,crypto,udp,rtp,pipe'.
Reading option '-i' ... matched as input url with argument 'pipe:0'.
Reading option 'map' ... matched as output url.
Reading option '0:0' ... matched as output url.
Reading option 'foo.wav' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
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 pipe:0.
Successfully parsed a group of options.
Opening an input file: pipe:0.
[sdp @ 0x7fd483808000] Format sdp probed with size=2048 and score=50

ffmpeg stderr says: [sdp @ 0x7fd483808000] audio codec set to: pcm_mulaw
[sdp @ 0x7fd483808000] audio samplerate set to: 8000
[sdp @ 0x7fd483808000] audio channels set to: 1
[sdp @ 0x7fd483808000] audio codec set to: pcm_alaw
[sdp @ 0x7fd483808000] audio samplerate set to: 8000
[sdp @ 0x7fd483808000] audio channels set to: 1
[sdp @ 0x7fd483808000] audio codec set to: pcm_alaw
[sdp @ 0x7fd483808000] audio samplerate set to: 8000
[sdp @ 0x7fd483808000] audio channels set to: 1
[udp @ 0x7fd4835012e0] end receive buffer size reported is 65536
[udp @ 0x7fd4835014e0] end receive buffer size reported is 65536
[sdp @ 0x7fd483808000] setting jitter buffer size to 500
[sdp @ 0x7fd483808000] Before avformat_find_stream_info() pos: 286 bytes read:286 seeks:0 nb_streams:1



start pcap reader..
running /Users/dhorton/beachdog-enterprises/beachdog-networks/git/voxbone/node-transcode-pcap/bin/pcapreader
args: ["--port","40558","test/rtpengine.pcap"]
ffmpeg stderr says: [sdp @ 0x7fd483808000] All info found

ffmpeg stderr says: [sdp @ 0x7fd483808000] After avformat_find_stream_info() pos: 286 bytes read:286 seeks:0 frames:1

ffmpeg stderr says: Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, sdp, from 'pipe:0':
  Metadata:
    title           : 
ffmpeg stderr says: session
  Duration: N/A, start: 0.000000, bitrate: 64 kb/s

ffmpeg stderr says:     Stream #0:0, 1, 1/8000: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s
Successfully opened the file.
Parsing a group of options: output url .
Successfully parsed a group of options.
Opening an output file: .
[NULL @ 0x7fd483818e00] Unable to find a suitable output format for ''
: Invalid argument

ffmpeg stderr says: [AVIOContext @ 0x7fd483416820] Statistics: 286 bytes read, 0 seeks

ffmpeg exited with 1


On Sep 19, 2017, at 9:59 AM, Dave Horton <daveh at beachdognet.com> wrote:



I don't know how to feed the captured rtp stream, my
guess is you have to edit the sdp file and resend the
stream.


Carl

Yes, I am starting to think this could be quite complicated.  I have a pcap file with rtp, and I have the related SDPs for the two streams, but after looking into the ffmpeg code a bit it seems like it can only take rtp streams from a network port, not a file, which seems to mean that I would have to:

- rewrite the udp headers to change the src and dest addresses to localhost from their original values
- probably this means updating the checksums in the udp packets as well
- do the same with the sdps
- find some way to play the (modified) rtp stream from a file to a localhost udp port (I don’t think ffmpeg can do this, since it can’t take rtp input from a file?)
- spawn an instance of ffmpeg, feed it the modified sdp and point it to the localhost port for rtp input to get a decoded version of the audio out

The whole thing seems pretty complicated and likely to be quite brittle…unless I am missing something ?




More information about the ffmpeg-user mailing list