Failed to publish a HLS stream via the nginx HTTPS server with ffmpeg.

Hongyi Zhao hongyi.zhao at gmail.com
Thu Feb 4 02:25:08 UTC 2021


On Thu, Feb 4, 2021 at 10:03 AM Maxim Dounin <mdounin at mdounin.ru> wrote:
>
> Hello!
>
> On Thu, Feb 04, 2021 at 09:17:47AM +0800, Hongyi Zhao wrote:
>
> > As for watching the stream, I tried to use ffplay with http and https
> > protocal respectively, but the former can
> > successfully play the stream, the latter failed. The used commands
> > are shown below:
> >
> > $ ffplay http://localhost:8000/live/surveillance.m3u8
> > $ ffplay https://localhost:8000/live/surveillance.m3u8
>
> [...]
>
> > Any hints/notes/comments for solving this problem are highly appreciated.
>
> You are using the same port for both http and https.  This is not
> certainly not going to work.

Thanks for pointing this out, I've exposed the 443 port from container
and mapping it onto host's 8443 now as shown here:
<https://github.com/hongyi-zhao/docker-nginx-rtmp/blob/8c7f1e107cf8f46885df239748659a72fad9a1dd/Dockerfile#L216>

Then I do the following testings:

# Start the container:
$ docker run -it -p 1935:1935 -p 8000:80 -p 8443:443 --rm nginx-rtmp

# Verify the https sever's status:
$ curl -I -k https://localhost:8443/stats
HTTP/1.1 200 OK
Server: nginx/1.18.0
Date: Thu, 04 Feb 2021 02:17:04 GMT
Content-Type: text/xml
Content-Length: 5568
Connection: keep-alive

# Publish the stream:
$ ffmpeg -f pulse -i default -f v4l2 -r 30 -s 1920x1080 -i /dev/video0
-c:v libx264 -preset veryfast -b:v 3000k -maxrate 3000k -bufsize 3000k
-vf "scale=1280:-1,format=yuv420p" -g 60 -c:a aac -b:a 128k -ar 44100
-force_key_frames "expr:gte(t,n_forced*4)"  -f flv
"rtmp://localhost:1935/stream/surveillance"
# Watch the stream:
# http:
$ ffplay http://localhost:8000/live/surveillance.m3u8
# https:
$ ffplay https://localhost:8443/live/surveillance.m3u8

But I still failed to watch the stream with HTTP or HTTPS protocol
using VLC player as shown below:

$ cvlc https://localhost:8443/live/surveillance.m3u8
VLC media player 3.0.9.2 Vetinari (revision 3.0.9.2-0-gd4c1aefe4d)
[0000557a9a005210] dummy interface: using the dummy interface module...
[00007f55a40024b0] gnutls tls client error: Certificate verification
failure: The certificate is NOT trusted. The certificate issuer is
unknown. The certificate chain uses expired certificate. The name in
the certificate does not match the expected.
[00007f55a40024b0] main tls client error: TLS session handshake error
[00007f55a40024b0] main tls client error: connection error: Resource
temporarily unavailable
[00007f55a4001610] access stream error: HTTP connection failure
[00007f55b0000c80] main input error: Your input can't be opened
[00007f55b0000c80] main input error: VLC is unable to open the MRL
'https://localhost:8443/live/surveillance.m3u8'. Check the log for
details.

$ cvlc http://localhost:8000/live/surveillance.m3u8
VLC media player 3.0.9.2 Vetinari (revision 3.0.9.2-0-gd4c1aefe4d)
[00005645acdbefc0] dummy interface: using the dummy interface module...
[00007fd7e8001610] http stream error: cannot resolve localhost: Name
or service not known
[00007fd7e8001610] access stream error: HTTP connection failure
[00007fd7e8001610] main stream error: cannot resolve localhost port
844000 : Name or service not known
[00007fd7e8001610] http stream error: cannot connect to localhost:844000
[00007fd7f4000c80] main input error: Your input can't be opened
[00007fd7f4000c80] main input error: VLC is unable to open the MRL
'http://localhost:844000/live/surveillance.m3u8'. Check the log for
details.

Any hints for this problem?

Regards
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao at gmail.com>
Theory and Simulation of Materials
Hebei Polytechnic University of Science and Technology engineering
NO. 552 North Gangtie Road, Xingtai, China


More information about the nginx mailing list