Discussion:
Using GStreamer to Convert WAV -> RTP Results in Low-Quality RTP Stream
Josh Dickson
2017-05-12 04:43:54 UTC
Permalink
Hi,

I am sorry in advance if this is not the correct place to ask a question


I am trying to convert a high-quality WAV file to RTP stream. I am successfully streaming with:

gst-launch-1.0 -m filesrc location=myfile.wav ! wavparse ! audioconvert ! audioresample ! alawenc ! rtppcmapay ! udpsink host=127.0.0.1 port=12000

I can then check the RTP stream from ffmpeg, which shows that is is 64 kb/s, pct_alaw, 8000 Hz, 1 channel, s16.

My WAV file is much higher quality than this (it is a sample of music at CD quality). I thought that the problem was with audioresample, but I have tried a number of changes and I cannot get any of them to stream correctly. Ideally the stream should be as high-quality as the WAV it’s generated from.

I would greatly appreciate a pointer on how I might be able to do this. Thank you!

Josh
Jan Schmidt
2017-05-12 05:39:28 UTC
Permalink
Hi,
Post by Josh Dickson
Hi,
I am sorry in advance if this is not the correct place to ask a question

I am trying to convert a high-quality WAV file to RTP stream. I am
gst-launch-1.0 -m filesrc location=myfile.wav ! wavparse !
audioconvert ! audioresample ! alawenc ! rtppcmapay ! udpsink
host=127.0.0.1 port=12000
alaw is 8-bit @ 8khz and will generally sound awful for anything except
speech. Try rtpL16pay for 16-bit CD quality audio.

Cheers,
Jan.
Post by Josh Dickson
I can then check the RTP stream from ffmpeg, which shows that is is 64
kb/s, pct_alaw, 8000 Hz, 1 channel, s16.
My WAV file is much higher quality than this (it is a sample of music
at CD quality). I thought that the problem was with audioresample, but
I have tried a number of changes and I cannot get any of them to
stream correctly. Ideally the stream should be as high-quality as the
WAV it’s generated from.
I would greatly appreciate a pointer on how I might be able to do this. Thank you!
Josh
_______________________________________________
gstreamer-devel mailing list
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Josh Dickson
2017-05-12 17:50:24 UTC
Permalink
Hi Jan,

Thank you, that is definitely what I need. I have gotten that pipeline working successfully, but now when I play it (via ffplay), it sounds comically slow/distorted.

I am now using the pipeline:

gst-launch-1.0 -m filesrc location=myfile.wav ! wavparse ! audioconvert ! rtpL16pay ! udpsink host=127.0.0.1 port=12008

I used the -v option to produce what I thought was a correct SDP file:

v=0

o=root IN IP4 127.0.0.1

c=IN IP4 127.0.0.1

s=My Name

m=audio 12008 RTP/AVP 96

a=rtpmap:96 L16/44100

a=fmtp:96 media=audio; clock-rate=44100; encoding-name=L16; channels=2;

I am playing the sound with:

ffplay -i stream.sdp -protocol_whitelist file,udp,rtp

Ffplay does open, and the sound resembles the original song, but it is very slowed down/distorted. 

Ffplay sees:

bitrate: 705 kb/s

    Stream #0:0: Audio: pcm_s16be, 44100 Hz, 1 channels, s16, 705 kb/s

(not sure if that will help)

I have been trying to research what is wrong here but I am not sure what part of this I’ve messed up. Any help would be much appreciated. Thank you!

Josh

On Fri, May 12, 2017 at 01:39 Jan Schmidt

<
a, pre, code, a:link, body { word-wrap: break-word !important; }

Hi,

On 12/05/17 14:43, Josh Dickson wrote:

Hi,

I am sorry in advance if this is not the correct place to ask a question


I am trying to convert a high-quality WAV file to RTP stream. I am successfully streaming with:

gst-launch-1.0 -m filesrc location=myfile.wav ! wavparse ! audioconvert ! audioresample ! alawenc ! rtppcmapay ! udpsink host=127.0.0.1 port=12000

alaw is 8-bit @ 8khz and will generally sound awful for anything except speech. Try rtpL16pay for 16-bit CD quality audio.

Cheers,

Jan.

I can then check the RTP stream from ffmpeg, which shows that is is 64 kb/s, pct_alaw, 8000 Hz, 1 channel, s16.

My WAV file is much higher quality than this (it is a sample of music at CD quality). I thought that the problem was with audioresample, but I have tried a number of changes and I cannot get any of them to stream correctly. Ideally the stream should be as high-quality as the WAV it’s generated from.

I would greatly appreciate a pointer on how I might be able to do this. Thank you!

Josh

_______________________________________________ gstreamer-devel mailing list
mailto:gstreamer-***@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Ian Davidson
2017-05-16 14:33:34 UTC
Permalink
I see that you are creating a stereo output (channels=2), but it is
being played as a mono (channels=1), so each sample from the original is
being treated as 2 samples. This means that it will take twice as long
to play as it did to record.

I don't know why.

Ian
Post by Josh Dickson
Hi Jan,
Thank you, that is definitely what I need. I have gotten that pipeline
working successfully, but now when I play it (via ffplay), it sounds
comically slow/distorted.
gst-launch-1.0 -m filesrc location=myfile.wav ! wavparse !
audioconvert ! rtpL16pay ! udpsink host=127.0.0.1 port=12008
v=0
o=root IN IP4 127.0.0.1
c=IN IP4 127.0.0.1
s=My Name
m=audio 12008 RTP/AVP 96
a=rtpmap:96 L16/44100
a=fmtp:96 media=audio; clock-rate=44100; encoding-name=L16; channels=2;
ffplay -i stream.sdp -protocol_whitelist file,udp,rtp
Ffplay does open, and the sound resembles the original song, but it is
very slowed down/distorted.
bitrate: 705 kb/s
Stream #0:0: Audio: pcm_s16be, 44100 Hz, 1 channels, s16, 705 kb/s
(not sure if that will help)
I have been trying to research what is wrong here but I am not sure
what part of this I’ve messed up. Any help would be much appreciated.
Thank you!
Josh
Peter Maersk-Moller
2017-05-16 17:01:01 UTC
Permalink
You could try setting the correct payload type for 2 channels 44100Hz L16.
I might work
See RFC3551. Or see IANAs list of allocated payload types
https://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml#rtp-parameters-1

I could suggest payload type 10. Set for rtpL16pay (and for the sdp file)

Regards
Peter
Post by Josh Dickson
Hi Jan,
Thank you, that is definitely what I need. I have gotten that pipeline
working successfully, but now when I play it (via ffplay), it sounds
comically slow/distorted.
gst-launch-1.0 -m filesrc location=myfile.wav ! wavparse ! audioconvert !
rtpL16pay ! udpsink host=127.0.0.1 port=12008
v=0
o=root IN IP4 127.0.0.1
c=IN IP4 127.0.0.1
s=My Name
m=audio 12008 RTP/AVP 96
a=rtpmap:96 L16/44100
a=fmtp:96 media=audio; clock-rate=44100; encoding-name=L16; channels=2;
ffplay -i stream.sdp -protocol_whitelist file,udp,rtp
Ffplay does open, and the sound resembles the original song, but it is
very slowed down/distorted.
bitrate: 705 kb/s
Stream #0:0: Audio: pcm_s16be, 44100 Hz, 1 channels, s16, 705 kb/s
(not sure if that will help)
I have been trying to research what is wrong here but I am not sure what
part of this I’ve messed up. Any help would be much appreciated. Thank you!
Josh
On Fri, May 12, 2017 at 01:39 Jan Schmidt <Jan Schmidt
Hi,
Hi,
I am sorry in advance if this is not the correct place to ask a question

I am trying to convert a high-quality WAV file to RTP stream. I am
gst-launch-1.0 -m filesrc location=myfile.wav ! wavparse ! audioconvert !
audioresample ! alawenc ! rtppcmapay ! udpsink host=127.0.0.1 port=12000
speech. Try rtpL16pay for 16-bit CD quality audio.
Cheers,
Jan.
I can then check the RTP stream from ffmpeg, which shows that is is 64
kb/s, pct_alaw, 8000 Hz, 1 channel, s16.
My WAV file is much higher quality than this (it is a sample of music at
CD quality). I thought that the problem was with audioresample, but I have
tried a number of changes and I cannot get any of them to stream correctly.
Ideally the stream should be as high-quality as the WAV it’s generated from.
I would greatly appreciate a pointer on how I might be able to do this. Thank you!
Josh
_______________________________________________
_______________________________________________
gstreamer-devel mailing list
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Nicolas Dufresne
2017-05-16 19:23:21 UTC
Permalink
Post by Peter Maersk-Moller
You could try setting the correct payload type for 2 channels 44100Hz
L16. I might work
See RFC3551. Or see IANAs list of allocated payload types
https://www.iana.org/assignments/rtp-parameters/rtp-
parameters.xhtml#rtp-parameters-1
Though allocated payload types should be usable.
Post by Peter Maersk-Moller
Post by Josh Dickson
v=0
o=root IN IP4 127.0.0.1
c=IN IP4 127.0.0.1
s=My Name
m=audio 12008 RTP/AVP 96
a=rtpmap:96 L16/44100
You should use "a=rtpmap:96 L16/44100/2" to signal that you have 2
channels.

regards,
Nicolas

Loading...