Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Can't stream HLS) [error] hls: force fragment split #38

Open
tincho opened this issue Nov 30, 2019 · 13 comments
Open

(Can't stream HLS) [error] hls: force fragment split #38

tincho opened this issue Nov 30, 2019 · 13 comments

Comments

@tincho
Copy link

tincho commented Nov 30, 2019

Hi there

I'm streaming from OBS , it seems to be working because in the console I see:

2019/11/30 00:05:04 [info] 6#6: *50 connect: app='stream' args='' flashver='' swf_url='' tc_url='rtmp://localhost:1935/stream' page_url='' acodecs=3191 vcodecs=252 object_encoding=0, client: 127.0.0.1, server: 0.0.0.0:1935

But when I open VLC and add the url: http://mysite.com/live/test.m3u8

The logs start to show many of these:

2019/11/30 00:06:13 [error] 6#6: *57 hls: force fragment split: 50.017 sec, , client: 127.0.0.1, server: 0.0.0.0:1935
2019/11/30 00:06:13 [error] 6#6: *58 hls: force fragment split: 50.017 sec, , client: 127.0.0.1, server: 0.0.0.0:1935
2019/11/30 00:06:13 [error] 6#6: *59 hls: force fragment split: 50.017 sec, , client: 127.0.0.1, server: 0.0.0.0:1935
2019/11/30 00:06:13 [error] 6#6: *60 hls: force fragment split: 50.017 sec, , client: 127.0.0.1, server: 0.0.0.0:1935
2019/11/30 00:06:13 [error] 6#6: *61 hls: force fragment split: 50.017 sec, , client: 127.0.0.1, server: 0.0.0.0:1935
2019/11/30 00:06:17 [error] 6#6: *57 hls: force fragment split: -49.484 sec, , client: 127.0.0.1, server: 0.0.0.0:1935
2019/11/30 00:06:17 [error] 6#6: *58 hls: force fragment split: -49.484 sec, , client: 127.0.0.1, server: 0.0.0.0:1935
2019/11/30 00:06:17 [error] 6#6: *59 hls: force fragment split: -49.484 sec, , client: 127.0.0.1, server: 0.0.0.0:1935
2019/11/30 00:06:17 [error] 6#6: *60 hls: force fragment split: -49.484 sec, , client: 127.0.0.1, server: 0.0.0.0:1935
2019/11/30 00:06:17 [error] 6#6: *57 hls: force fragment split: 51.921 sec, , client: 127.0.0.1, server: 0.0.0.0:1935
2019/11/30 00:06:17 [error] 6#6: *58 hls: force fragment split: 51.921 sec, , client: 127.0.0.1, server: 0.0.0.0:1935
2019/11/30 00:06:17 [error] 6#6: *59 hls: force fragment split: 51.921 sec, , client: 127.0.0.1, server: 0.0.0.0:1935
2019/11/30 00:06:17 [error] 6#6: *60 hls: force fragment split: 51.921 sec, , client: 127.0.0.1, server: 0.0.0.0:1935
2019/11/30 00:06:17 [error] 6#6: *57 hls: force fragment split: -51.888 sec, , client: 127.0.0.1, server: 0.0.0.0:1935

And of course VLC doesnt play anything

Tried building from source and same.

Tried this solution editing Dockerfile
arut/nginx-rtmp-module#568 (comment)
but then build fails with the message: ERROR: libass not found using pkg-config

The streaming works when using RTMP anyway, altough extremely laggy, but that's probably because of my bandwith

@tincho tincho changed the title lots of "hls: force fragment split:" error messages [error] hls: force fragment split Nov 30, 2019
@tincho tincho changed the title [error] hls: force fragment split (Can't stream HLS) [error] hls: force fragment split Nov 30, 2019
@alfg
Copy link
Owner

alfg commented Dec 1, 2019

Hi @tincho, does these errors only appear after a few days as mentioned in the linked issue from nginx-rtmp-module? Or does it happen right away?

@alfg
Copy link
Owner

alfg commented Dec 1, 2019

Also, --enable-libass should already be included on this build.

@tincho
Copy link
Author

tincho commented Dec 2, 2019

Hello! thanks for your answers
They appear after a few minutes, not days.
Anyway, tried different docker images for this and the only one that currently worked was: https://hub.docker.com/r/jasonrivers/nginx-rtmp/
I wanted something that worked the most "out of the box" as possible for RTMP+HLS
Thank you anyway, regards!

@alfg
Copy link
Owner

alfg commented Dec 2, 2019

Ah, okay. I wonder what is different about that build that doesn't have the errors.

@alfg
Copy link
Owner

alfg commented Dec 14, 2019

Another suggestion is to try using an older ffmpeg version, like 3.4.2 as a user in that thread doesn't seem to see the errors using that version.

https://github.com/alfg/docker-nginx-rtmp/blob/master/Dockerfile#L3

ARG FFMPEG_VERSION=3.4.2

@alfg
Copy link
Owner

alfg commented Mar 11, 2020

Closing. Feel free to re-open if you have any additional info using the latest build. Thanks!

@alfg alfg closed this as completed Mar 11, 2020
@mkrn
Copy link

mkrn commented Oct 29, 2020

@alfg what is your ffmpeg command for transcoding?

I found this issue happens when timestamps of audio and video diverge too much. Are you using -async 1 -vsync 1 or both?

@alfg
Copy link
Owner

alfg commented Oct 29, 2020

@mkrn Using neither. The ffmpeg commands are defined here:
https://github.com/alfg/docker-nginx-rtmp/blob/master/nginx.conf#L17-L22

@mkrn
Copy link

mkrn commented Oct 30, 2020

Thanks @alfg I investigated and debugged the issue, and nailed the cause, it's happening when timestamps of video and audio packets have a different start pts. In this case dts of audio and video are too far apart and HLS algo does not account for it.
It may occur in some streams, but can be fixed with ffmpeg options such as -vf "setpts=PTS-STARTPTS" -af "asetpts=PTS-STARTPTS" that will reset timestamps and make them start from 0.
Interleave and sync options of n can mess with timestamps as well.

@alfg
Copy link
Owner

alfg commented Oct 30, 2020

Great findings @mkrn!

I can try adding those filters to ffmpeg commands. However, is there a way I can test to verify the fix? Are you seeing the errors mentioned in the original post?

@alfg alfg reopened this Oct 30, 2020
@mkrn
Copy link

mkrn commented Oct 31, 2020

@alfg In some videos (presumably with very bad internet) I get a number of audio packets in a row with no video, and then a video packet with dts and pts of many seconds behind... This can possibly happen if a buffer starts sending frames after network congestion.
The timestamps are then too diverged and it affects the hls algorithm.

I'm trying to mitigate this issue by ffmpeg settings to sync video and audio and force 30 fps (there are many settings related to it, vsync, -r, fps filter, so I'm still testing with some of them.

@fivethreeo
Copy link
Contributor

I think we need -async 1 -vsync 1 here.

@fivethreeo
Copy link
Contributor

Also ffmpeg is a bit wonky when it is low on resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants