How to construct the pipeline for hls videos (AES encrypted or not)

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

How to construct the pipeline for hls videos (AES encrypted or not)

Xinheng
I'm new to gstreamer. I want to realize an iOS app to play hls videos by gstreamer. I use the version 1.6.4. I followed some tutorials on the internet so I got the following pipeline:

souphttpsrc location=some_m3u8_url ! hlsdemux ! tsdemux name=mux  mux. ! queue ! h264parse ! avdec_h264 ! autovideosink  mux. ! queue ! aacparse ! faad ! autoaudiosink

I found some hls video urls to test but strangely, it partially worked.
Sometimes it plays the video during several seconds and then it stops and it gives: Error received from element hlsdemux0: Internal data stream error.
Sometimes it dose not play the video but just shows the first frame of this video.

I also tried playbin, decodebin and uridecodebin (like: uridecodebin uri=some_m3u8-url buffer-size=10000000 name=u  u. ! videoconvert ! autovideosink  u. ! audioconvert ! audioresample ! autoaudiosink), but they didn't work. Error message like:
Buffering 4%
Buffering 8%
Error received from element hlsdemux0: GStreamer encountered a general stream error.
OR
Buffering 40%
Buffering 90%
PLAYING
PAUSED
Error received from element hlsdemux0: Internal data stream error.
In Xcode, error message: GLib (gthread-posix.c): Unexpected error from C library during 'pthread_mutex_lock': Invalid argument.  Aborting.

These kinds of error made me upset for weeks and I could not find any help. Further more, what I need is to also play the encrypted video, but I have no idea if this function is integrated or not.

Hope someone can help me or give me some suggestions. Thanks a lot!

PS: Dev environment: Xcode 7.3, iOS 9.3.1 (ipad).
Reply | Threaded
Open this post in threaded view
|

Re: How to construct the pipeline for hls videos (AES encrypted or not)

Duncan Palmer-2
Hi Silver,

Using uridecodebin is the correct approach here, as you'll need to deal with dynamic pipeline reconfiguration on bitrate changes, and decodebin will handle that for you.

Could you run with the GST_DEBUG environment variable set to '*:2,hlsdemux:7', and post the logs?

Dunk

On 17 May 2016 at 19:17, silver <[hidden email]> wrote:
I'm new to gstreamer. I want to realize an iOS app to play hls videos by
gstreamer. I use the version 1.6.4. I followed some tutorials on the
internet so I got the following pipeline:

souphttpsrc location=some_m3u8_url ! hlsdemux ! tsdemux name=mux  mux. !
queue ! h264parse ! avdec_h264 ! autovideosink  mux. ! queue ! aacparse !
faad ! autoaudiosink

I found some hls video urls to test but strangely, it partially worked.
Sometimes it plays the video during several seconds and then it stops and it
gives: Error received from element hlsdemux0: Internal data stream error.
Sometimes it dose not play the video but just shows the first frame of this
video.

I also tried playbin, decodebin and uridecodebin (like: uridecodebin
uri=some_m3u8-url buffer-size=10000000 name=u  u. ! videoconvert !
autovideosink  u. ! audioconvert ! audioresample ! autoaudiosink), but they
didn't work. Error message like:
Buffering 4%
Buffering 8%
Error received from element hlsdemux0: GStreamer encountered a general
stream error.
OR
Buffering 40%
Buffering 90%
PLAYING
PAUSED
Error received from element hlsdemux0: Internal data stream error.
In Xcode, error message: GLib (gthread-posix.c): Unexpected error from C
library during 'pthread_mutex_lock': Invalid argument.  Aborting.

These kinds of error made me upset for weeks and I could not find any help.
Further more, what I need is to also play the encrypted video, but I have no
idea if this function is integrated or not.

Hope someone can help me or give me some suggestions. Thanks a lot!

PS: Dev environment: Xcode 7.3, iOS 9.3.1 (ipad).



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/How-to-construct-the-pipeline-for-hls-videos-AES-encrypted-or-not-tp4677603.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
|

Re: How to construct the pipeline for hls videos (AES encrypted or not)

Tim Müller
On Wed, 2016-05-18 at 14:13 +1000, Duncan Palmer wrote:

Hi,

> > Using uridecodebin is the correct approach here, as you'll need to
> > deal with dynamic pipeline reconfiguration on bitrate changes, and
> > decodebin will handle that for you.

Why not use playbin? It should handle everything for you automatically.
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: How to construct the pipeline for hls videos (AES encrypted or not)

Xinheng
In reply to this post by Duncan Palmer-2
Hey Dunk,

Thanks for your response. Later I tried other pipelines, and I found one which worked.

souphttpsrc location=url ! hlsdemux ! decodebin name=u  u. ! queue ! autovideosink  u. ! queue ! autoaudiosink

I cannot tell the difference but it did work for non-encrypted streams. However, here's another problem, that is, I cannot play an encrypted stream. Error message: Could not determine type of stream.

I checked on the internet but haven't found anything helpful. I saw that hlsdemux supports openssl and AES decryption in this link: https://lists.freedesktop.org/archives/gstreamer-commits/2014-August/081573.html. But I have no idea how it works.

Silver
Reply | Threaded
Open this post in threaded view
|

Re: How to construct the pipeline for hls videos (AES encrypted or not)

Sebastian Dröge-3
In reply to this post by Duncan Palmer-2
On Mi, 2016-05-18 at 14:13 +1000, Duncan Palmer wrote:
> Hi Silver,
>
> Using uridecodebin is the correct approach here, as you'll need to
> deal with dynamic pipeline reconfiguration on bitrate changes, and
> decodebin will handle that for you.
>
> Could you run with the GST_DEBUG environment variable set to
> '*:2,hlsdemux:7', and post the logs?

Actually uridecodebin won't help much here either, you need full
playbin to handle this properly. Or implement the reconfiguration
handling yourself.

What will happen with HLS (DASH, etc) is that whenever the stream
configuration changes too much, it will remove all pads from the
demuxer and add new ones. Which then have to be linked again and used
in place of the others. playbin would do this for you but you could of
course also implement that independent of playbin

--
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 (968 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to construct the pipeline for hls videos (AES encrypted or not)

Xinheng
In reply to this post by Tim Müller
Hi,

Tim Müller wrote
On Wed, 2016-05-18 at 14:13 +1000, Duncan Palmer wrote:

Hi,

> > Using uridecodebin is the correct approach here, as you'll need to
> > deal with dynamic pipeline reconfiguration on bitrate changes, and
> > decodebin will handle that for you.

Why not use playbin? It should handle everything for you automatically.
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
Off course I tried playbin like: playbin uri=some_uri, but strangely, it cannot play the video. Error message is always like: Error received from element hlsdemux, Gstreamer encountered a general stream error. Due to this, I then tried to make independent pipelines.

Silver
Reply | Threaded
Open this post in threaded view
|

Re: How to construct the pipeline for hls videos (AES encrypted or not)

Tim Müller
On Wed, 2016-05-18 at 05:50 -0700, silver wrote:

> Off course I tried playbin like: playbin uri=some_uri, but strangely,
> it cannot play the video. Error message is always like: Error
> received from element hlsdemux, Gstreamer encountered a general
> stream error. Due to this, I then tried to make independent
> pipelines.

Ok, I think you should start debugging this then. Playbin should work,
and not using playbin is going to be very complicated and is unlikely
to make it work. You really want to use playbin :)

Perhaps you could make a GST_DEBUG=*:6 log, compress it, and upload it
somewhere. If you file a bug in bugzilla (bugzilla.gnome.org) you can
attach it there.

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: How to construct the pipeline for hls videos (AES encrypted or not)

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

Sebastian Dröge-3 wrote
On Mi, 2016-05-18 at 14:13 +1000, Duncan Palmer wrote:
> Hi Silver,
>
> Using uridecodebin is the correct approach here, as you'll need to
> deal with dynamic pipeline reconfiguration on bitrate changes, and
> decodebin will handle that for you.
>
> Could you run with the GST_DEBUG environment variable set to
> '*:2,hlsdemux:7', and post the logs?

Actually uridecodebin won't help much here either, you need full
playbin to handle this properly. Or implement the reconfiguration
handling yourself.

What will happen with HLS (DASH, etc) is that whenever the stream
configuration changes too much, it will remove all pads from the
demuxer and add new ones. Which then have to be linked again and used
in place of the others. playbin would do this for you but you could of
course also implement that independent of playbin

--
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 (968 bytes) <http://gstreamer-devel.966125.n4.nabble.com/attachment/4677647/0/signature.asc>
I believe playbin is the best way but still it works not well for me. Alternatively, I took the pipeline example here: https://github.com/ford-prefect/gst-plugins-bad/blob/master/ext/hls/gsthlsdemux.c, it worked for playing non-encrypted video.

But when I trying to play aes encrypted videos, I could always get: could not dertermine type of stream. I think perhaps it hasn't performed the decryption so it didn't know the type of video.

According to this page: https://lists.freedesktop.org/archives/gstreamer-commits/2014-August/081574.html, gstreamer well supports the aes decryption, but I could not find how to implement it on iOS.

Could you give me some hints or any advice? Thanks in advance.

Silver
Reply | Threaded
Open this post in threaded view
|

Re: How to construct the pipeline for hls videos (AES encrypted or not)

Sebastian Dröge-3
On Do, 2016-05-19 at 05:37 -0700, silver wrote:

> I believe playbin is the best way but still it works not well for me.
> Alternatively, I took the pipeline example here:
> https://github.com/ford-prefect/gst-plugins-bad/blob/master/ext/hls/gsthlsdemux.c,
> it worked for playing non-encrypted video.
>
> But when I trying to play aes encrypted videos, I could always get: could
> not dertermine type of stream. I think perhaps it hasn't performed the
> decryption so it didn't know the type of video.
>
> According to this page:
> https://lists.freedesktop.org/archives/gstreamer-commits/2014-August/081574.html,
> gstreamer well supports the aes decryption, but I could not find how to
> implement it on iOS.
>
> Could you give me some hints or any advice? Thanks in advance.
It supports AES decryption out of the box on iOS too if you use the
binaries provided by the GStreamer project. Which version are you
using?

Can you share an URL to a stream that is failing for you?

--
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 (968 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to construct the pipeline for hls videos (AES encrypted or not)

Xinheng
Sebastian Dröge-3 wrote
On Do, 2016-05-19 at 05:37 -0700, silver wrote:
> I believe playbin is the best way but still it works not well for me.
> Alternatively, I took the pipeline example here:
> https://github.com/ford-prefect/gst-plugins-bad/blob/master/ext/hls/gsthlsdemux.c,
> it worked for playing non-encrypted video.
>
> But when I trying to play aes encrypted videos, I could always get: could
> not dertermine type of stream. I think perhaps it hasn't performed the
> decryption so it didn't know the type of video.
>
> According to this page:
> https://lists.freedesktop.org/archives/gstreamer-commits/2014-August/081574.html,
> gstreamer well supports the aes decryption, but I could not find how to
> implement it on iOS.
>
> Could you give me some hints or any advice? Thanks in advance.

It supports AES decryption out of the box on iOS too if you use the
binaries provided by the GStreamer project. Which version are you
using?

Can you share an URL to a stream that is failing for you?

--
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 (968 bytes) <http://gstreamer-devel.966125.n4.nabble.com/attachment/4677690/0/signature.asc>
 
I'm using the version 1.6.4. I checked the log and I found it could not accept the ssl certificate.
Logs like:
gst_uri_downloader_set_uri:<uridownloader0> Creating source element for the URI:https://the_url_to_fetch_the_key
gst_uri_downloader_fetch_uri_with_range:<uridownloader0> Waiting to fetch the URI https://the_url_to_fetch_the_key
gst_uri_downloader_bus_handler:<uridownloader0> Received error: Secure connection setup failed.

Is there any solution?
Reply | Threaded
Open this post in threaded view
|

Re: How to construct the pipeline for hls videos (AES encrypted or not)

Sebastian Dröge-3
On Fr, 2016-05-20 at 01:16 -0700, silver wrote:
> I'm using the version 1.6.4. I checked the log and I found it could not
> accept the ssl certificate.
> Logs like:
> gst_uri_downloader_set_uri: Creating source element for
> the URI:https://the_url_to_fetch_the_key
> gst_uri_downloader_fetch_uri_with_range: Waiting to
> fetch the URI https://the_url_to_fetch_the_key
> gst_uri_downloader_bus_handler: Received error: Secure
> connection setup failed.

See https://bugzilla.gnome.org/show_bug.cgi?id=765986

For the time being, you need to ensure that the certificates are signed
by a trusted CA from the ca-certificates.crt file and ensure that this
is shipped properly with your application.

--
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 (968 bytes) Download Attachment