Opus streaming directly from file

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Opus streaming directly from file

JoeArtAV
Hello. I'm looking to build a pipeline to stream a static audio file over
UDP, and I'd like to use the Opus codec for streaming.

- I can currently stream from an MP3 file, like so:

Sender:
*gst-launch-1.0 filesrc location=file.mp3 ! decodebin ! audioconvert !
rtpL16pay ! udpsink port=500 host=192.168.0.1 *

Receiver:
*gst-launch-1.0 udpsrc port=5000 caps="application/x-rtp,
media=(string)audio, format=(string)S32LE, layout=(string)interleaved,
clock-rate=(int)44100, channels=(int)2, payload=(int)0" ! rtpL16depay !
playsink*

- I can play back an Opus file locally like so:

*gst-launch-1.0 filesrc location="file.opus" ! decodebin ! audioconvert !
playsink
*
- And I can stream a test source via UDP with the Opus codec like so:

Sender:
*gst-launch-1.0 audiotestsrc ! audioconvert ! audioresample ! opusenc !
rtpopuspay ! udpsink host=192.168.0.1 port=5000*

Receiver:
*gst-launch-1.0 udpsrc
caps="application/x-rtp,media=(string)audio,clock-rate=(int)48000,encoding-name=(string)X-GST-OPUS-DRAFT-SPITTKA-00"
port=5000 ! rtpjitterbuffer latency=1000 mode=1 ! rtpopusdepay ! opusdec !
playsink*

Now, I would like to construct something like this for the sender:
*gst-launch-1.0 filesrc location="file.opus" ! rtpopuspay ! udpsink
host=192.168.0.1 port=5000
*
But this pipeline comes back with an error "No input format was negotiated"
etc.

Is it possible? I'd like to avoid re-encoding on the fly (e.g. from MP3 to
Opus) in order to maximise efficiency. Is it possible to stream Opus to UDP
by directly reading from a .opus file?

Thanks!



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Opus streaming directly from file

Tim Müller
On Mon, 2018-04-23 at 06:36 -0700, JoeArtAV wrote:

Hi Joe,

> Now, I would like to construct something like this for the sender:
> *gst-launch-1.0 filesrc location="file.opus" ! rtpopuspay ! udpsink
> host=192.168.0.1 port=5000
> *
> But this pipeline comes back with an error "No input format was
> negotiated"
> etc.
>
> Is it possible? I'd like to avoid re-encoding on the fly (e.g. from
> MP3 to Opus) in order to maximise efficiency. Is it possible to
> stream Opus to UDP by directly reading from a .opus file?

I was going to say have you tried

  filesrc location=.. ! opusparse ! rtpopuspay ! .. ?

but opusparse doesn't seem to do the right thing for me here in my
quick testing.

I would recommend putting the opus audio into a proper container such
as Matroska, Ogg or MPEG-TS and then you should be able to use

  filesrc location=... ! xyzdemux ! rtpopuspay ! ..

or even

  filesrc location=.. ! parsebin ! rtpopuspay ! ...

Cheers
 -Tim

--
Tim Müller, Centricular Ltd - http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Opus streaming directly from file

Tim Müller
On Mon, 2018-04-23 at 19:56 +0100, Tim Müller wrote:

> but opusparse doesn't seem to do the right thing for me here in my
> quick testing.
>
> I would recommend putting the opus audio into a proper container such
> as Matroska, Ogg or MPEG-TS and then you should be able to use

Just to clarify: unlike MP3 Opus isn't self-framed and relies on
external framing so you always need some kind of wrapper/container, you
can't just dump the raw opus data into a file or stream and expect to
play that back.

Cheers
 -Tim

--
Tim Müller, Centricular Ltd - http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Opus streaming directly from file

Marc Leeman

Some pipelines to support Tim ;-)

Generate file:
gst-launch-1.0 audiotestsrc ! opusenc ! matroskamux ! filesink location=test.mkv

Stream file:
gst-launch-1.0 filesrc location=test.mkv ! matroskademux ! rtpopuspay ! rtpsink uri=rtp://239.1.2.3:2222

Streaming (live):
gst-launch-1.0 audiotestsrc ! opusenc ! rtpopuspay ! rtpsink uri=rtp://239.1.2.3:2222

Decoding:
gst-launch-1.0 rtpsrc uri=rtp://239.1.2.3:2222?encoding-name=OPUS ! rtpopusdepay ! opusdec ! autoaudiosink

The rtp bins are
https://github.com/mleeman/gst-plugins-rtp

They hook up the RTP/RTCP pads so that (especially) audio can be decoded with fewer hickups.

They are also in bugzilla since years, but I created a stand alone project for easier maintenance and to keep them up-to-date. They should compile easily against 1.14 (probably against earlier version too, I did not test them).

On Mon, 23 Apr 2018 at 21:12 Tim Müller <[hidden email]> wrote:
On Mon, 2018-04-23 at 19:56 +0100, Tim Müller wrote:

> but opusparse doesn't seem to do the right thing for me here in my
> quick testing.
>
> I would recommend putting the opus audio into a proper container such
> as Matroska, Ogg or MPEG-TS and then you should be able to use

Just to clarify: unlike MP3 Opus isn't self-framed and relies on
external framing so you always need some kind of wrapper/container, you
can't just dump the raw opus data into a file or stream and expect to
play that back.

Cheers
 -Tim

--
Tim Müller, Centricular Ltd - http://www.centricular.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
|

Re: Opus streaming directly from file

desjare
In reply to this post by JoeArtAV
Trying to do it with rtsp client and server:

client:
 gst-launch-1.0 filesrc location=opus.opus ! opusparse ! rtspclientsink
debug=true location=rtsp://127.0.0.1:8554/test

server:
test-server rtpbin ! rtpopusdepay name=depay0 ! fakesink

Getting this on the server.

0:00:36.370641500 15727      0x8184180 ERROR              rtspmedia
rtsp-media.c:3998:default_handle_sdp: 0x7ffff0016220: Media has more or less
streams than SDP (0 /= 1)
0:00:36.370718600 15727      0x8184180 ERROR             rtspclient
rtsp-client.c:3011:handle_sdp: client 0x817ba80: could not handle SDP
0:00:36.370808500 15727      0x8184180 ERROR             rtspclient
rtsp-client.c:3190:handle_announce_request: client 0x817ba80: can't handle
SDP

Eric




--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Opus streaming directly from file

desjare
In reply to this post by JoeArtAV
Thank you all!

What is making a mux being a rtspclientsink?
How would I know that?

filesrc location=opus.opus ! opusenc ! matroskamux  ! rtspclientsink
debug=true location=rtsp://127.0.0.1:8554/testble to connect to a

Eric



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel