Streaming in stereo in OPUS

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Streaming in stereo in OPUS

TouchOfDestiny
Hi all,

I'm a total newbie here, and I was just wondering how you can stream in stereo with the opus encoding. I've done this:

gst-launch-1.0 alsasrc device=hw:1,0 ! audioconvert ! opusenc bitrate=128000 ! rtpopuspay pt=98 ! udpsink host=127.0.0.1 port=8002 videotestsrc ! vp8enc ! rtpvp8pay ! udpsink host=127.0.0.1 port=8004
(in Raspberry with Debian)

But it seems that no stereo is produced. Only mono.

Do you have any idea?

Thank you very much.
David
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Streaming in stereo in OPUS

Sebastian Dröge-3
On Tue, 2017-07-18 at 08:41 -0700, TouchOfDestiny wrote:

> Hi all,
>
> I'm a total newbie here, and I was just wondering how you can stream in
> stereo with the opus encoding. I've done this:
>
> gst-launch-1.0 alsasrc device=hw:1,0 ! audioconvert ! opusenc bitrate=128000
> ! rtpopuspay pt=98 ! udpsink host=127.0.0.1 port=8002 videotestsrc ! vp8enc
> ! rtpvp8pay ! udpsink host=127.0.0.1 port=8004
> (in Raspberry with Debian)
>
> But it seems that no stereo is produced. Only mono.
What does your receiver pipeline look like, and is alsasrc capturing
stereo?

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (981 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Streaming in stereo in OPUS

Peter Maersk-Moller-2
In reply to this post by TouchOfDestiny
Use the verbose flag to see what is produced

        gst-launch-1.0 -v ....

then you can see if you produce stereo at all.

Raspberry Pi does not have audio input so you added an external audio capture device I assume. Does it offer stereo?
Even if it does not offer stereo, audioconvert can change channels from something to stereo if you specify it. The module opusenc will take from 1-8 channels so if your alsasrc is mono, it will take that. You need to specify that opusenc should ask for stereo.

To force opusenc to encode in stereo, add a format string after audioconvert.

        gst-launch-1.0 -v audiotestsrc is-live=1 ! audioconvert ! audio/x-raw,channels=2 ! opusenc ! fakesink

If you wan to ensure your source captures in stereo add a format string before audioconvert

        gst-launch-1.0 -v audiotestsrc is-live=1 ! audio/x-raw,channels=2 ! audioconvert ! opusenc ! fakesink

You may want to add rate to format as well. Not all rates are supported by opusenc (like 44100) is not supported.
Obviously, you need to replace audiotestsrc with alsasink.

Regards
Peter


On Tue, Jul 18, 2017 at 5:41 PM, TouchOfDestiny <[hidden email]> wrote:
Hi all,

I'm a total newbie here, and I was just wondering how you can stream in
stereo with the opus encoding. I've done this:

gst-launch-1.0 alsasrc device=hw:1,0 ! audioconvert ! opusenc bitrate=128000
! rtpopuspay pt=98 ! udpsink host=127.0.0.1 port=8002 videotestsrc ! vp8enc
! rtpvp8pay ! udpsink host=127.0.0.1 port=8004
(in Raspberry with Debian)

But it seems that no stereo is produced. Only mono.

Do you have any idea?

Thank you very much.
David




--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Streaming-in-stereo-in-OPUS-tp4683854.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Streaming in stereo in OPUS

TouchOfDestiny
Hi,

thank you very much for your replies.
This is what I have with the "-v" option. i slightly modify the command line parameters, since I don't need any video, only OPUS audio:

gst-launch-1.0 -v alsasrc ! audio/x-raw,channels=2,rate=48000 ! audioconvert dithering=0 ! opusenc bitrate=256000 ! rtpopuspay  ! udpsink host=127.0.0.1 port=8002 &

And this is the result (I'm sorry, but I don't understand very well what this all means):

Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstAudioSrcClock
/GstPipeline:pipeline0/GstAlsaSrc:alsasrc0: actual-buffer-time = 200000
/GstPipeline:pipeline0/GstAlsaSrc:alsasrc0: actual-latency-time = 10000
/GstPipeline:pipeline0/GstAlsaSrc:alsasrc0.GstPad:src: caps = "audio/x-raw\,\ format\=\(string\)S16LE\,\ layout\=\(string\)interleaved\,\ rate\=\(int\)48000\,\ channels\=\(int\)2\,\ channel-mask\=\(bitmask\)0x0000000000000003"
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = "audio/x-raw\,\ format\=\(string\)S16LE\,\ layout\=\(string\)interleaved\,\ rate\=\(int\)48000\,\ channels\=\(int\)2\,\ channel-mask\=\(bitmask\)0x0000000000000003"
/GstPipeline:pipeline0/GstAudioConvert:audioconvert0.GstPad:src: caps = "audio/x-raw\,\ format\=\(string\)S16LE\,\ layout\=\(string\)interleaved\,\ rate\=\(int\)48000\,\ channels\=\(int\)2\,\ channel-mask\=\(bitmask\)0x0000000000000003"
/GstPipeline:pipeline0/GstOpusEnc:opusenc0.GstPad:sink: caps = "audio/x-raw\,\ format\=\(string\)S16LE\,\ layout\=\(string\)interleaved\,\ rate\=\(int\)48000\,\ channels\=\(int\)2\,\ channel-mask\=\(bitmask\)0x0000000000000003"
/GstPipeline:pipeline0/GstAudioConvert:audioconvert0.GstPad:sink: caps = "audio/x-raw\,\ format\=\(string\)S16LE\,\ layout\=\(string\)interleaved\,\ rate\=\(int\)48000\,\ channels\=\(int\)2\,\ channel-mask\=\(bitmask\)0x0000000000000003"
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps = "audio/x-raw\,\ format\=\(string\)S16LE\,\ layout\=\(string\)interleaved\,\ rate\=\(int\)48000\,\ channels\=\(int\)2\,\ channel-mask\=\(bitmask\)0x0000000000000003"
Redistribute latency...
/GstPipeline:pipeline0/GstOpusEnc:opusenc0.GstPad:src: caps = "audio/x-opus\,\ multistream\=\(boolean\)false\,\ streamheader\=\(buffer\)\<\ 4f707573486561640102000080bb0000000000\,\ 4f707573546167731e000000456e636f6465642077697468204753747265616d6572204f707573656e630000000001\ \>"
/GstPipeline:pipeline0/GstRtpOPUSPay:rtpopuspay0.GstPad:src: caps = "application/x-rtp\,\ media\=\(string\)audio\,\ clock-rate\=\(int\)48000\,\ encoding-name\=\(string\)X-GST-OPUS-DRAFT-SPITTKA-00\,\ payload\=\(int\)96\,\ ssrc\=\(uint\)2976569488\,\ timestamp-offset\=\(uint\)3934898579\,\ seqnum-offset\=\(uint\)2879"
/GstPipeline:pipeline0/GstUDPSink:udpsink0.GstPad:sink: caps = "application/x-rtp\,\ media\=\(string\)audio\,\ clock-rate\=\(int\)48000\,\ encoding-name\=\(string\)X-GST-OPUS-DRAFT-SPITTKA-00\,\ payload\=\(int\)96\,\ ssrc\=\(uint\)2976569488\,\ timestamp-offset\=\(uint\)3934898579\,\ seqnum-offset\=\(uint\)2879"
/GstPipeline:pipeline0/GstRtpOPUSPay:rtpopuspay0.GstPad:sink: caps = "audio/x-opus\,\ multistream\=\(boolean\)false\,\ streamheader\=\(buffer\)\<\ 4f707573486561640102000080bb0000000000\,\ 4f707573546167731e000000456e636f6465642077697468204753747265616d6572204f707573656e630000000001\ \>"
/GstPipeline:pipeline0/GstRtpOPUSPay:rtpopuspay0: timestamp = 3934898579
/GstPipeline:pipeline0/GstRtpOPUSPay:rtpopuspay0: seqnum = 2879
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Streaming in stereo in OPUS

TouchOfDestiny
Sorry, I forgot to mention:

yes, I have a USB audio card and yes it supports stereo 48000Hz.

Thanks again!
David
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Streaming in stereo in OPUS

Peter Maersk-Moller-2
In reply to this post by TouchOfDestiny
It means you are streaming sterao audio as an opus encoded and RTP encapsulated stream.

On Wed, Jul 19, 2017 at 10:54 PM, TouchOfDestiny <[hidden email]> wrote:
Hi,

thank you very much for your replies.
This is what I have with the "-v" option. i slightly modify the command line
parameters, since I don't need any video, only OPUS audio:

/gst-launch-1.0 -v alsasrc ! audio/x-raw,channels=2,rate=48000 !
audioconvert dithering=0 ! opusenc bitrate=256000 ! rtpopuspay  ! udpsink
host=127.0.0.1 port=8002 &/

And this is the result (I'm sorry, but I don't understand very well what
this all means):

/Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstAudioSrcClock
/GstPipeline:pipeline0/GstAlsaSrc:alsasrc0: actual-buffer-time = 200000
/GstPipeline:pipeline0/GstAlsaSrc:alsasrc0: actual-latency-time = 10000
/GstPipeline:pipeline0/GstAlsaSrc:alsasrc0.GstPad:src: caps =
"audio/x-raw\,\ format\=\(string\)S16LE\,\ layout\=\(string\)interleaved\,\
rate\=\(int\)48000\,\ channels\=\(int\)2\,\
channel-mask\=\(bitmask\)0x0000000000000003"
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps =
"audio/x-raw\,\ format\=\(string\)S16LE\,\ layout\=\(string\)interleaved\,\
rate\=\(int\)48000\,\ channels\=\(int\)2\,\
channel-mask\=\(bitmask\)0x0000000000000003"
/GstPipeline:pipeline0/GstAudioConvert:audioconvert0.GstPad:src: caps =
"audio/x-raw\,\ format\=\(string\)S16LE\,\ layout\=\(string\)interleaved\,\
rate\=\(int\)48000\,\ channels\=\(int\)2\,\
channel-mask\=\(bitmask\)0x0000000000000003"
/GstPipeline:pipeline0/GstOpusEnc:opusenc0.GstPad:sink: caps =
"audio/x-raw\,\ format\=\(string\)S16LE\,\ layout\=\(string\)interleaved\,\
rate\=\(int\)48000\,\ channels\=\(int\)2\,\
channel-mask\=\(bitmask\)0x0000000000000003"
/GstPipeline:pipeline0/GstAudioConvert:audioconvert0.GstPad:sink: caps =
"audio/x-raw\,\ format\=\(string\)S16LE\,\ layout\=\(string\)interleaved\,\
rate\=\(int\)48000\,\ channels\=\(int\)2\,\
channel-mask\=\(bitmask\)0x0000000000000003"
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps =
"audio/x-raw\,\ format\=\(string\)S16LE\,\ layout\=\(string\)interleaved\,\
rate\=\(int\)48000\,\ channels\=\(int\)2\,\
channel-mask\=\(bitmask\)0x0000000000000003"
Redistribute latency...
/GstPipeline:pipeline0/GstOpusEnc:opusenc0.GstPad:src: caps =
"audio/x-opus\,\ multistream\=\(boolean\)false\,\
streamheader\=\(buffer\)\<\ 4f707573486561640102000080bb0000000000\,\
4f707573546167731e000000456e636f6465642077697468204753747265616d6572204f707573656e630000000001\
\>"
/GstPipeline:pipeline0/GstRtpOPUSPay:rtpopuspay0.GstPad:src: caps =
"application/x-rtp\,\ media\=\(string\)audio\,\ clock-rate\=\(int\)48000\,\
encoding-name\=\(string\)X-GST-OPUS-DRAFT-SPITTKA-00\,\
payload\=\(int\)96\,\ ssrc\=\(uint\)2976569488\,\
timestamp-offset\=\(uint\)3934898579\,\ seqnum-offset\=\(uint\)2879"
/GstPipeline:pipeline0/GstUDPSink:udpsink0.GstPad:sink: caps =
"application/x-rtp\,\ media\=\(string\)audio\,\ clock-rate\=\(int\)48000\,\
encoding-name\=\(string\)X-GST-OPUS-DRAFT-SPITTKA-00\,\
payload\=\(int\)96\,\ ssrc\=\(uint\)2976569488\,\
timestamp-offset\=\(uint\)3934898579\,\ seqnum-offset\=\(uint\)2879"
/GstPipeline:pipeline0/GstRtpOPUSPay:rtpopuspay0.GstPad:sink: caps =
"audio/x-opus\,\ multistream\=\(boolean\)false\,\
streamheader\=\(buffer\)\<\ 4f707573486561640102000080bb0000000000\,\
4f707573546167731e000000456e636f6465642077697468204753747265616d6572204f707573656e630000000001\
\>"
/GstPipeline:pipeline0/GstRtpOPUSPay:rtpopuspay0: timestamp = 3934898579
/GstPipeline:pipeline0/GstRtpOPUSPay:rtpopuspay0: seqnum = 2879
/



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Streaming-in-stereo-in-OPUS-tp4683854p4683868.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Streaming in stereo in OPUS

Sebastian Dröge-3
In reply to this post by TouchOfDestiny
On Wed, 2017-07-19 at 13:54 -0700, TouchOfDestiny wrote:
>
> /GstPipeline:pipeline0/GstRtpOPUSPay:rtpopuspay0.GstPad:sink: caps =
> "audio/x-opus\,\ multistream\=\(boolean\)false\,\
> streamheader\=\(buffer\)\<\ 4f707573486561640102000080bb0000000000\,\
> 4f707573546167731e000000456e636f6465642077697468204753747265616d65722
> 04f707573656e630000000001\
> \>"

You seem to be using an old version of GStreamer. A new version would
print:

/GstPipeline:pipeline0/GstRtpOPUSPay:rtpopuspay0.GstPad:sink: caps =
audio/x-opus, rate=(int)48000, channels=(int)2, channel-mapping-
family=(int)0, stream-count=(int)1, coupled-count=(int)1,
streamheader=(buffer)< 4f707573486561640102380180bb0000000000,
4f707573546167731e000000456e636f6465642077697468204753747265616d6572206
f707573656e63010000001a0000004445534352495054494f4e3d617564696f74657374
207761766501 >

The channels and other fields in the caps are relevant here, and are
exactly why I was asking you for your receiver pipeline. streamheader
is not required, but the others should be provided on the receiver
pipeline. It should default to stereo without that, but not sure if
that's also the case with the old GStreamer version you're using.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (981 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Streaming in stereo in OPUS

TouchOfDestiny
Hi Sebastian,

the "reciever" is a janus-webRTC application. I stream with gstreamer to a mountpoint and then with the application I listen to the stream. The quality is almost perfect, except for the fact that somewhere the stereo signal becomes mono.

Is there a way to create a sort of "loop" with gStreamer? I mean: I stream with gStreamer and I listen back with gstreamer from the same audiocard? Or maybe stream to a file, so that I can hear the result without involving webRTC?

I don't know if it's clear what I mean...  

Thanks in advance,
David
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Streaming in stereo in OPUS

TouchOfDestiny
In reply to this post by Sebastian Dröge-3
Hi Sebastian,

I installed an updated version of GStreamer (1.12). Here's what I have now:

Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstAudioSrcClock
/GstPipeline:pipeline0/GstAlsaSrc:alsasrc0: actual-buffer-time = 200000
/GstPipeline:pipeline0/GstAlsaSrc:alsasrc0: actual-latency-time = 10000
Redistribute latency...
/GstPipeline:pipeline0/GstAlsaSrc:alsasrc0.GstPad:src: caps = audio/x-raw, forma                                                                                                             t=(string)S16LE, layout=(string)interleaved, rate=(int)48000, channels=(int)2, c                                                                                                             hannel-mask=(bitmask)0x0000000000000003
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = audio/x-raw,                                                                                                              format=(string)S16LE, layout=(string)interleaved, rate=(int)48000, channels=(in                                                                                                             t)2, channel-mask=(bitmask)0x0000000000000003
/GstPipeline:pipeline0/GstOpusEnc:opusenc0.GstPad:sink: caps = audio/x-raw, form                                                                                                             at=(string)S16LE, layout=(string)interleaved, rate=(int)48000, channels=(int)2,                                                                                                              channel-mask=(bitmask)0x0000000000000003
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps = audio/x-raw                                                                                                             , format=(string)S16LE, layout=(string)interleaved, rate=(int)48000, channels=(i                                                                                                             nt)2, channel-mask=(bitmask)0x0000000000000003
Redistribute latency...
/GstPipeline:pipeline0/GstOpusEnc:opusenc0.GstPad:src: caps = audio/x-opus, rate                                                                                                             =(int)48000, channels=(int)2, channel-mapping-family=(int)0, stream-count=(int)1                                                                                                             , coupled-count=(int)1, streamheader=(buffer)< 4f707573486561640102380180bb00000                                                                                                             00000, 4f707573546167731e000000456e636f6465642077697468204753747265616d6572206f7                                                                                                             07573656e630000000001 >
/GstPipeline:pipeline0/GstRtpOPUSPay:rtpopuspay0.GstPad:src: caps = application/                                                                                                             x-rtp, media=(string)audio, clock-rate=(int)48000, encoding-name=(string)OPUS, s                                                                                                             prop-maxcapturerate=(string)48000, sprop-stereo=(string)1, payload=(int)96, enco                                                                                                             ding-params=(string)2, ssrc=(uint)2917675584, timestamp-offset=(uint)3734919745,                                                                                                              seqnum-offset=(uint)12697
/GstPipeline:pipeline0/GstUDPSink:udpsink0.GstPad:sink: caps = application/x-rtp                                                                                                             , media=(string)audio, clock-rate=(int)48000, encoding-name=(string)OPUS, sprop-                                                                                                             maxcapturerate=(string)48000, sprop-stereo=(string)1, payload=(int)96, encoding-                                                                                                             params=(string)2, ssrc=(uint)2917675584, timestamp-offset=(uint)3734919745, seqn                                                                                                             um-offset=(uint)12697
/GstPipeline:pipeline0/GstRtpOPUSPay:rtpopuspay0.GstPad:sink: caps = audio/x-opu                                                                                                             s, rate=(int)48000, channels=(int)2, channel-mapping-family=(int)0, stream-count                                                                                                             =(int)1, coupled-count=(int)1, streamheader=(buffer)< 4f707573486561640102380180                                                                                                             bb0000000000, 4f707573546167731e000000456e636f6465642077697468204753747265616d65                                                                                                             72206f707573656e630000000001 >
/GstPipeline:pipeline0/GstRtpOPUSPay:rtpopuspay0: timestamp = 3734919745
/GstPipeline:pipeline0/GstRtpOPUSPay:rtpopuspay0: seqnum = 12697
[gstreamer-sample] New audio stream! (ssrc=2917675584)

Is this correct?

Thanks in advance.
David
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Streaming in stereo in OPUS

TouchOfDestiny
As a "sink" I used a file and listened to it. The stereo is there, so I'm pretty sure that the problem is after "opusenc". Is there a way to use gstreamer both as a streamer and as a reciever?. I would like to listen what goes out after the "rtpopuspay". Do you have any idea?
Loading...