title: ffmpeg Save incoming RTP audio only stream to file
body: <p>I have setup kurento media server, which streams RTP audio (<strong>only audio</strong>). Now I am trying to test the received RTP stream. For that, I am saving the incoming RTP stream to file converting them to mp3. I am using the following command.</p>
  
  <pre><code>sudo ffmpeg -loglevel debug -protocol_whitelist file,crypto,udp,rtp -reorder_queue_size 100 -acodec opus -i mySdpOffer.sdp -acodec mp3 -y -f segment -segment_atclocktime 1 -segment_time 900 -reset_timestamps 1 -strftime 1 out-%Y%m%dT%H%M.mp3
  </code></pre>
  
  <p>SDP offer:</p>
  
  <pre><code>v=0
  t=0 0
  m=audio 8978 RTP/AVP 98
  c=IN IP4 127.0.0.1
  a=recvonly
  a=rtpmap:98 opus/48000/2
  a=fmtp:98 stereo=0; sprop-stereo=0; useinbandfec=1
  </code></pre>
  
  <p>I am getting the output mp3 file, but when I play it in VLC, there is no audio and while I stream for approximately 1 minute, the mp3 output file shows time 7 min long audio.</p>
  
  <p>There are no errors from ffmpeg. Am I missing something here?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Adding ffmpeg logs, </p>
  
  <p>Initials logs, before it starts capturing/decoding/writing to file</p>
  
  <pre><code>Splitting the commandline.
  Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
  Reading option '-protocol_whitelist' ... matched as AVOption 'protocol_whitelist' with argument 'file,crypto,udp,rtp'.
  Reading option '-reorder_queue_size' ... matched as AVOption 'reorder_queue_size' with argument '100'.
  Reading option '-acodec' ... matched as option 'acodec' (force audio codec ('copy' to copy stream)) with argument 'opus'.
  Reading option '-i' ... matched as input url with argument '/home/ubuntu/Documents/inputAudio.sdp'.
  Reading option '-acodec' ... matched as option 'acodec' (force audio codec ('copy' to copy stream)) with argument 'mp3'.
  Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
  Reading option '-f' ... matched as option 'f' (force format) with argument 'segment'.
  Reading option '-segment_atclocktime' ... matched as AVOption 'segment_atclocktime' with argument '1'.
  Reading option '-segment_time' ... matched as AVOption 'segment_time' with argument '900'.
  Reading option '-reset_timestamps' ... matched as AVOption 'reset_timestamps' with argument '1'.
  Reading option '-strftime' ... matched as AVOption 'strftime' with argument '1'.
  Reading option 'out-%Y%m%dT%H%M.mp3' ... 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 /home/ubuntu/Documents/inputAudio.sdp.
  Applying option acodec (force audio codec ('copy' to copy stream)) with argument opus.
  Successfully parsed a group of options.
  Opening an input file: /home/ubuntu/Documents/inputAudio.sdp.
  [NULL @ 0x55e09081d440] Opening '/home/ubuntu/Documents/inputAudio.sdp' for reading
  [sdp @ 0x55e09081d440] Format sdp probed with size=2048 and score=50
  [sdp @ 0x55e09081d440] audio codec set to: opus
  [sdp @ 0x55e09081d440] audio samplerate set to: 48000
  [sdp @ 0x55e09081d440] audio channels set to: 2
  [udp @ 0x55e090825200] end receive buffer size reported is 131072
  [udp @ 0x55e090824ec0] end receive buffer size reported is 131072
  [sdp @ 0x55e09081d440] setting jitter buffer size to 100
  [sdp @ 0x55e09081d440] Before avformat_find_stream_info() pos: 141 bytes read:141 seeks:0 nb_streams:1
  [sdp @ 0x55e09081d440] All info found
  [sdp @ 0x55e09081d440] After avformat_find_stream_info() pos: 141 bytes read:141 seeks:0 frames:1
  Input #0, sdp, from '/home/ubuntu/Documents/inputAudio.sdp':
    Duration: N/A, start: 0.000000, bitrate: N/A
      Stream #0:0, 1, 1/48000: Audio: opus, 48000 Hz, stereo, fltp
  Successfully opened the file.
  Parsing a group of options: output url out-%Y%m%dT%H%M.mp3.
  Applying option acodec (force audio codec ('copy' to copy stream)) with argument mp3.
  Applying option f (force format) with argument segment.
  Successfully parsed a group of options.
  Opening an output file: out-%Y%m%dT%H%M.mp3.
  Matched encoder 'libmp3lame' for codec 'mp3'.
  Successfully opened the file.
  Stream mapping:
    Stream #0:0 -&gt; #0:0 (opus (native) -&gt; mp3 (libmp3lame))
  Press [q] to stop, [?] for help
  cur_dts is invalid (this is harmless if it occurs once at the start per stream)
  detected 2 logical cores
  [graph_0_in_0_0 @ 0x55e0908a2240] Setting 'time_base' to value '1/48000'
  [graph_0_in_0_0 @ 0x55e0908a2240] Setting 'sample_rate' to value '48000'
  [graph_0_in_0_0 @ 0x55e0908a2240] Setting 'sample_fmt' to value 'fltp'
  [graph_0_in_0_0 @ 0x55e0908a2240] Setting 'channel_layout' to value '0x3'
  [graph_0_in_0_0 @ 0x55e0908a2240] tb:1/48000 samplefmt:fltp samplerate:48000 chlayout:0x3
  [format_out_0_0 @ 0x55e0908875c0] Setting 'sample_fmts' to value 's32p|fltp|s16p'
  [format_out_0_0 @ 0x55e0908875c0] Setting 'sample_rates' to value '44100|48000|32000|22050|24000|16000|11025|12000|8000'
  [format_out_0_0 @ 0x55e0908875c0] Setting 'channel_layouts' to value '0x4|0x3'
  [AVFilterGraph @ 0x55e0908a1400] query_formats: 4 queried, 9 merged, 0 already done, 0 delayed
  [segment @ 0x55e09081f7c0] Selected stream id:0 type:audio
  [segment @ 0x55e09081f7c0] Opening 'out-20191105T1707.mp3' for writing
  [file @ 0x55e0908a2bc0] Setting default whitelist 'file,crypto'
  Output #0, segment, to 'out-%Y%m%dT%H%M.mp3':
    Metadata:
      encoder         : Lavf58.20.100
      Stream #0:0, 0, 1/48000: Audio: mp3 (libmp3lame), 48000 Hz, stereo, fltp, delay 1105
      Metadata:
        encoder         : Lavc58.35.100 libmp3lame
  cur_dts is invalid (this is harmless if it occurs once at the start per stream)
      Last message repeated 3 times
  [segment @ 0x55e09081f7c0] segment:'out-20191105T1707.mp3' starts with packet stream:0 pts:0 pts_time:0 frame:0
  [segment @ 0x55e09081f7c0] stream:0 start_pts_time:0 pts:0 pts_time:0 dts:0 dts_time:0 -&gt; pts:0 pts_time:0 dts:0 dts_time:0
  [segment @ 0x55e09081f7c0] stream:0 start_pts_time:0 pts:1152 pts_time:0.024 dts:1152 dts_time:0.024 -&gt; pts:1152 pts_time:0.024 dts:1152 dts_time:0.024
  [segment @ 0x55e09081f7c0] stream:0 start_pts_time:0 pts:179904 pts_time:3.748 dts:179904 dts_time:3.748 -&gt; pts:179904 pts_time:3.748 dts:179904 dts_time:3.748
  [segment @ 0x55e09081f7c0] stream:0 start_pts_time:0 pts:181056 pts_time:3.772 dts:181056 dts_time:3.772 -&gt; pts:181056 pts_time:3.772 dts:181056 dts_time:3.772
  </code></pre>
  
  <p>last few lines. </p>
  
  <pre><code>[segment @ 0x5613ffd7f7c0] stream:0 start_pts_time:0 pts:137124480 pts_time:2856.76 dts:137124480 dts_time:2856.76 -&gt; pts:137124480 pts_time:2856.76 dts:137124480 dts_time:2856.76
  [segment @ 0x5613ffd7f7c0] stream:0 start_pts_time:0 pts:137130912 pts_time:2856.89 dts:137130912 dts_time:2856.89 -&gt; pts:137130912 pts_time:2856.89 dts:137130912 dts_time:2856.89
  [segment @ 0x5613ffd7f7c0] stream:0 start_pts_time:0 pts:137132064 pts_time:2856.92 dts:137132064 dts_time:2856.92 -&gt; pts:137132064 pts_time:2856.92 dts:137132064 dts_time:2856.92
  [segment @ 0x5613ffd7f7c0] stream:0 start_pts_time:0 pts:137133216 pts_time:2856.94 dts:137133216 dts_time:2856.94 -&gt; pts:137133216 pts_time:2856.94 dts:137133216 dts_time:2856.94
  [segment @ 0x5613ffd7f7c0] stream:0 start_pts_time:0 pts:137134368 pts_time:2856.97 dts:137134368 dts_time:2856.97 -&gt; pts:137134368 pts_time:2856.97 dts:137134368 dts_time:2856.97
  [segment @ 0x5613ffd7f7c0] stream:0 start_pts_time:0 pts:137135520 pts_time:2856.99 dts:137135520 dts_time:2856.99 -&gt; pts:137135520 pts_time:2856.99 dts:137135520 dts_time:2856.99
  [segment @ 0x5613ffd7f7c0] stream:0 start_pts_time:0 pts:137136672 pts_time:2857.01 dts:137136672 dts_time:2857.01 -&gt; pts:137136672 pts_time:2857.01 dts:137136672 dts_time:2857.01
  [segment @ 0x5613ffd7f7c0] stream:0 start_pts_time:0 pts:137137824 pts_time:2857.04 dts:137137824 dts_time:2857.04 -&gt; pts:137137824 pts_time:2857.04 dts:137137824 dts_time:2857.04
  [libmp3lame @ 0x5613ffd81900] Trying to remove 47 more samples than there are in the queue
  [segment @ 0x5613ffd7f7c0] stream:0 start_pts_time:0 pts:137138976 pts_time:2857.06 dts:137138976 dts_time:2857.06 -&gt; pts:137138976 pts_time:2857.06 dts:137138976 dts_time:2857.06
  [segment @ 0x5613ffd7f7c0] segment:'out-20191105T1651.mp3' count:0 ended
  [AVIOContext @ 0x5613ffe02a00] Statistics: 1 seeks, 24 writeouts
  size=N/A time=00:47:37.06 bitrate=N/A speed= 236x    
  video:0kB audio:5803kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
  Input file #0 (/home/ubuntu/Documents/bz-squawk-sdpoffer/inputAudio.sdp):
    Input stream #0:0 (audio): 18568 packets read (2970880 bytes); 18568 frames decoded (17825280 samples); 
    Total: 18568 packets (2970880 bytes) demuxed
  Output file #0 (out-%Y%m%dT%H%M.mp3):
    Output stream #0:0 (audio): 15473 frames encoded (17824896 samples); 15474 packets muxed (5942016 bytes); 
    Total: 15474 packets (5942016 bytes) muxed
  18568 frames successfully decoded, 0 decoding errors
  [AVIOContext @ 0x5613ffd86000] Statistics: 141 bytes read, 0 seeks
  Exiting normally, received signal 2.
  </code></pre>