0

I have tried to transcode a radio stream with ffmpeg to g722. I get the stream to work and im able to listen to the stream. The problem is that the output stream have faster speed than the input stream. so the result is not good. I have tried to slow down the speed with atempo without any luck.

like:

size=     241kB time=00:00:28.67 bitrate=  68.8kbits/s speed= 1.4x

this varies from 1.x to 15.x

Console output:

c:\ffmpeg\bin>ffmpeg -i http://lyd.nrk.no/nrk_radio_mp3_mp3_l -ac 1 -acodec g722 -f rtp -ab 64k -ar 16k rtp://192.168.0.99:555
ffmpeg version N-85750-ga75ef15 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 6.3.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib
  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. 88.100 /  6. 88.100
  libswscale      4.  7.101 /  4.  7.101
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
Input #0, mp3, from 'http://lyd.nrk.no/nrk_radio_mp3_mp3_l':
  Metadata:
    icy-name        : NRK mP3
    icy-pub         : 1
  Duration: N/A, start: 0.000000, bitrate: 96 kb/s
    Stream #0:0: Audio: mp3, 48000 Hz, stereo, s16p, 96 kb/s
[udp @ 000000000244bec0] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[udp @ 00000000024781a0] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
Stream mapping:
  Stream #0:0 -> #0:0 (mp3 (native) -> adpcm_g722 (g722))
Press [q] to stop, [?] for help
Output #0, rtp, to 'rtp://192.168.0.99:555':
  Metadata:
    icy-name        : NRK mP3
    icy-pub         : 1
    encoder         : Lavf57.72.101
    Stream #0:0: Audio: adpcm_g722 (g722), 16000 Hz, mono, s16, 64 kb/s
    Metadata:
      encoder         : Lavc57.93.100 g722
SDP:
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 192.168.0.99
t=0 0
a=tool:libavformat 57.72.101
m=audio 555 RTP/AVP 9
b=AS:64

size=     413kB time=00:00:49.17 bitrate=  68.8kbits/s speed=1.43x

Does anyone know what im doing wrong? Thanks

p3tter
  • 15
  • 1
  • 7

1 Answers1

0

The problem is that the output stream have faster speed than the input stream

Are you sure about this? If so, the issue comes down to sample rate. The playback side (after FFmpeg) is playing back at a higher sample rate than what you're outputting from FFmpeg.

I suspect this isn't really happening though based on this comment:

this varies from 1.x to 15.x

When you connect to an internet radio stream, a large buffer is going to be flushed to you as fast as possible. This enables fast starts for players. For your FFmpeg command, it means that when you first connect, FFmpeg is also going to process this data as fast as possible and send it over. This is generally fine, provided that the end playback device is buffering data. If it isn't, you'll have to force FFmpeg to buffer data.

You can do that by specifying the -re parameter before the input. This will force the input to run in real time against a software-defined clock.

Brad
  • 159,648
  • 54
  • 349
  • 530