[FFmpeg-user] importing rtp packet stream and decoding

Dave Horton daveh at beachdognet.com
Fri Sep 22 22:26:58 EEST 2017


On Sep 22, 2017, at 2:50 PM, Dave Horton <daveh at beachdognet.com> wrote:

>> 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

Sorry, my bad — I was able to fix that error — which was a simple typo in my command that led to a blank output url.

With that fixed, I get further:

Now I am able to generate a wav file, but I still have several issues and questions

1.  It sounds like crap — the audio is recognizable but barely.  Something is either wrong in the input feed I am sending, or what ffmpeg thinks it is receiving.  I did a wireshark trace during the execution to see exactly what was going over the wire, and it was the true and correct RTP packets as best I can tell (RTP headers, sequence numbers, payload types, etc all look good).

2.  ffmpeg takes quite a while to decode this file….maybe an additional 10 seconds after the utility has finished sending….how can I signal to ffmpeg that the stream is over?

3.  Is there any good way to synchronize ffmpeg with the sending utility?  Right now, I start ffmpeg first, but I have no way of knowing when it has opened the socket on the local port and is ready to receive.  I’m currently just waiting 2 seconds after feeding it the SDP before I start sending RTP, but is there a better way?

***new logs**

args: -loglevel debug -y -protocol_whitelist file,crypto,udp,rtp,pipe -re -i pipe: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 '-protocol_whitelist' ... matched as AVOption 'protocol_whitelist' with argument 'file,crypto,udp,rtp,pipe'.
Reading option '-re' ... matched as option 're' (read input at native frame rate) with argument '1'.
Reading option '-i' ... matched as input url with argument 'pipe:0'.
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.
Applying option re (read input at native frame rate) with argument 1.
Successfully parsed a group of options.
Opening an input file: pipe:0.
[sdp @ 0x7ff9f4000000] Format sdp probed with size=2048 and score=50

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

[Note: I start sending RTP here]

ffmpeg stderr says: [sdp @ 0x7ff9f4000000] All info found

ffmpeg stderr says: [sdp @ 0x7ff9f4000000] After avformat_find_stream_info() pos: 286 bytes read:286 seeks:0 frames:1
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, sdp, from 'pipe:0':
  Metadata:
    title           : 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 foo.wav.
Successfully parsed a group of options.
Opening an output file: foo.wav.
[file @ 0x7ff9f3417e40] Setting default whitelist 'file,crypto'

ffmpeg stderr says: Successfully opened the file.

ffmpeg stderr says: Stream mapping:
  Stream #0:0 -> #0:0 (pcm_alaw (native) -> pcm_s16le (native))
cur_dts is invalid (this is harmless if it occurs once at the start per stream)

ffmpeg stderr says: detected 8 logical cores

ffmpeg stderr says: [graph_0_in_0_0 @ 0x7ff9f51000a0] Setting 'time_base' to value '1/8000'
[graph_0_in_0_0 @ 0x7ff9f51000a0] Setting 'sample_rate' to value '8000'
[graph_0_in_0_0 @ 0x7ff9f51000a0] Setting 'sample_fmt' to value 's16'
[graph_0_in_0_0 @ 0x7ff9f51000a0] Setting 'channel_layout' to value '0x4'

ffmpeg stderr says: [graph_0_in_0_0 @ 0x7ff9f51000a0] tb:1/8000 samplefmt:s16 samplerate:8000 chlayout:0x4
[format_out_0_0 @ 0x7ff9f5100660] Setting 'sample_fmts' to value 's16'

ffmpeg stderr says: [AVFilterGraph @ 0x7ff9f5200340] query_formats: 4 queried, 9 merged, 0 already done, 0 delayed

ffmpeg stderr says: Output #0, wav, to 'foo.wav':
  Metadata:
    INAM            : session
    ISFT            : Lavf57.72.101

ffmpeg stderr says:     Stream #0:0, 0, 1/8000: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 8000 Hz, mono, s16, 128 kb/s
    Metadata:
      encoder         : Lavc57.93.100 pcm_s16le

[my sending RTP utility is done here…]
[these next few log lines are pumped out slowly over ~5-8 seconds]

ffmpeg stderr says: size=       8kB time=00:00:00.52 bitrate= 129.4kbits/s speed=1.04x    
ffmpeg stderr says: size=      16kB time=00:00:01.02 bitrate= 128.7kbits/s speed=1.02x    
ffmpeg stderr says: size=      24kB time=00:00:01.52 bitrate= 128.5kbits/s speed=1.01x    
ffmpeg stderr says: size=      32kB time=00:00:02.02 bitrate= 128.4kbits/s speed=   1x    
ffmpeg stderr says: size=      38kB time=00:00:02.70 bitrate= 116.0kbits/s speed=1.07x    
ffmpeg stderr says: pipe:0: Operation timed out
No more output streams to write to, finishing.5kbits/s speed=0.216x    

ffmpeg stderr says: size=      40kB time=00:00:02.82 bitrate= 116.5kbits/s speed=0.216x    
video:0kB audio:40kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.229492%
Input file #0 (pipe:0):
  Input stream #0:0 (audio): 128 packets read (20480 bytes); 128 frames decoded (20480 samples); 
  Total: 128 packets (20480 bytes) demuxed
Output file #0 (foo.wav):
  Output stream #0:0 (audio): 128 frames encoded (20480 samples); 128 packets muxed (40960 bytes); 
  Total: 128 packets (40960 bytes) muxed
128 frames successfully decoded, 0 decoding errors

ffmpeg stderr says: [AVIOContext @ 0x7ff9f3417f80] Statistics: 4 seeks, 131 writeouts

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

ffmpeg exited with 0




More information about the ffmpeg-user mailing list