nginx-rtmp-module icon indicating copy to clipboard operation
nginx-rtmp-module copied to clipboard

hls stops working: force fragment split

Open vvidic opened this issue 10 years ago • 15 comments

Any idea why this configuration stops working after a few days:

worker_processes 4;
pid /run/nginx.pid;
#error_log  /var/log/nginx/debug.log debug;

events {
     worker_connections 1024;
     multi_accept on;
 }

 rtmp_auto_push on;
 rtmp {
    server {
        listen 1935;

        application student {
            live on;

            hls on;
            hls_path /run/shm/hls-student;

            dash on;
            dash_path /run/shm/dash-student;

            # pull to start hls export
            pull rtmp://lb.av.carnet.hr/student name=one static;
         }
}
2015/01/23 09:22:45 [error] 16433#0: *1 hls: force fragment split: 682283.103 sec, , client: lb.av.carnet.hr/student, server: ngx-relay
2015/01/23 09:22:45 [error] 16433#0: *1 hls: force fragment split: -682275.068 sec, , client: lb.av.carnet.hr/student, server: ngx-relay
2015/01/23 09:22:53 [error] 16433#0: *1 hls: force fragment split: 682275.068 sec, , client: lb.av.carnet.hr/student, server: ngx-relay
2015/01/23 09:22:53 [error] 16433#0: *1 hls: force fragment split: -682267.034 sec, , client: lb.av.carnet.hr/student, server: ngx-relay
2015/01/23 09:23:01 [error] 16433#0: *1 hls: force fragment split: 682267.034 sec, , client: lb.av.carnet.hr/student, server: ngx-relay
2015/01/23 09:23:01 [error] 16433#0: *1 hls: force fragment split: -682259.000 sec, , client: lb.av.carnet.hr/student, server: ngx-relay
2015/01/23 09:23:09 [error] 16433#0: *1 hls: force fragment split: 682259.000 sec, , client: lb.av.carnet.hr/student, server: ngx-relay
2015/01/23 09:23:09 [error] 16433#0: *1 hls: force fragment split: -682250.943 sec, , client: lb.av.carnet.hr/student, server: ngx-relay
2015/01/23 09:23:17 [error] 16433#0: *1 hls: force fragment split: 682250.943 sec, , client: lb.av.carnet.hr/student, server: ngx-relay
2015/01/23 09:23:17 [error] 16433#0: *1 hls: force fragment split: -682242.909 sec, , client: lb.av.carnet.hr/student, server: ngx-relay

vvidic avatar Jan 23 '15 08:01 vvidic

I believe this is the same issue @ https://github.com/arut/nginx-rtmp-module/issues/346

mknwebsolutions avatar Jan 24 '15 21:01 mknwebsolutions

On Sat, Jan 24, 2015 at 01:42:56PM -0800, Michael Mikhjian wrote:

I believe this is the same issue @ https://github.com/arut/nginx-rtmp-module/issues/346

It could be, however I'm using the latest git version (7a35372). Restarting nginx doesn't help as the errors start appearing right away. I have to restart the upstream RTMP server to get HLS working again but this is not very practical for live streams. I have a capture of the failing RTMP stream so maybe you can use this to figure out why the HLS generator stops working.

Valentin

vvidic avatar Jan 25 '15 12:01 vvidic

I have it problem too and nginx create more small files about 300-15000 bytes size.

2016/02/14 14:05:53 [error] 952#0: *18459 hls: force fragment split: -78.252 sec, , client: 127.0.0.1, server: 0.0.0.0:1935 2016/02/14 14:05:53 [error] 952#0: *18460 hls: force fragment split: 78.391 sec, , client: 127.0.0.1, server: 0.0.0.0:1935

It work only in this config: hls on; hls_path /usr/local/nginx/html/video; hls_fragment 10s; hls_playlist_length 60s; hls_continuous on; hls_fragment_naming timestamp; dash off; dash_path /usr/local/nginx/html/dash; dash_fragment 15s; dash_playlist_length 60s;

dash off and dash* present If I comment or remove dash* in config I have this errors.

Sometimes I have nest errors in ffmpeg logs:

Error while decoding stream #0:1: Invalid data found when processing input [mpegts @ 0x3868740] PES packet size mismatchme=00:21:51.90 bitrate= 828.8kbits/s speed=0.933x [mpeg2video @ 0x38db0a0] 00 motion_type at 3 32 [mpeg2video @ 0x38db0a0] 00 motion_type at 6 24 [mpeg2video @ 0x38db0a0] 00 motion_type at 5 25 [mpeg2video @ 0x38db0a0] mb incr damaged [mpeg2video @ 0x38db0a0] 00 motion_type at 12 27 [mpeg2video @ 0x38db0a0] 00 motion_type at 12 33 [mpeg2video @ 0x38db0a0] 00 motion_type at 4 28 [mpeg2video @ 0x38db0a0] 00 motion_type at 25 34 [mpeg2video @ 0x38db0a0] 00 motion_type at 5 16 [mpeg2video @ 0x38db0a0] 00 motion_type at 26 35 [mpeg2video @ 0x38db0a0] ac-tex damaged at 29 20 [mpeg2video @ 0x38db0a0] 00 motion_type at 4 21 [mpeg2video @ 0x38db0a0] invalid mb type in P Frame at 21 22 [mpeg2video @ 0x38db0a0] 00 motion_type at 2 23 [mpeg2video @ 0x38db0a0] 00 motion_type at 5 8 [mpeg2video @ 0x38db0a0] mb incr damaged [mpeg2video @ 0x38db0a0] 00 motion_type at 18 9 [mpeg2video @ 0x38db0a0] 00 motion_type at 1 13 [mpeg2video @ 0x38db0a0] 00 motion_type at 15 10 [mpeg2video @ 0x38db0a0] 00 motion_type at 9 14 [mpeg2video @ 0x38db0a0] 00 motion_type at 9 11 [mpeg2video @ 0x38db0a0] 00 motion_type at 2 15 [mpeg2video @ 0x38db0a0] 00 motion_type at 11 7 [mpeg2video @ 0x38db0a0] 00 motion_type at 7 1 [mpeg2video @ 0x38db0a0] mb incr damaged [mpeg2video @ 0x38db0a0] 00 motion_type at 8 3 [mpeg2video @ 0x38db0a0] 00 motion_type at 1 4 [mpeg2video @ 0x38db0a0] invalid cbp -1 at 2 5 [mpeg2video @ 0x38db0a0] 00 motion_type at 10 6 [mpeg2video @ 0x38db0a0] invalid cbp -1 at 9 7 [mpeg2video @ 0x38db0a0] 00 motion_type at 6 29 [mpeg2video @ 0x38db0a0] ac-tex damaged at 5 30 [mpeg2video @ 0x38db0a0] ac-tex damaged at 9 17 [mpeg2video @ 0x38db0a0] 00 motion_type at 13 31 [mpeg2video @ 0x38db0a0] invalid cbp -1 at 9 19 [mpeg2video @ 0x38db0a0] 00 motion_type at 12 19 [mpeg2video @ 0x38db0a0] Warning MVs not available [mpeg2video @ 0x38db0a0] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame [mp2 @ 0x386ad60] Header missing Error while decoding stream #0:1: Invalid data found when processing input

ffmpeg get mpeg2 stream via http.

Sometimes I have next message: [libfdk_aac @ 0x388f220] Queue input is backward in time [flv @ 0x38d2880] Non-monotonous DTS in output stream 0:1; previous: 1437181, current: 1437173; changing to 1437181. This may result in incorrect timestamps in the output file.

but it does not lead to error

nginx 1.9.9 ffmpeg version N-78299-gf021030 - compiling from sources

I use script when monitoring folder and do next: stop nginx remove *.ts files with small size start nginx

dburianov avatar Apr 08 '16 15:04 dburianov

@dburianov I also have this problem. Have you solved it?

guoyi8 avatar Aug 14 '16 06:08 guoyi8

I'm having this problem as well, but only when streaming from Larix Broadcaster on iOS. Streaming from OBS on my Mac works fine.

aaronpk avatar Nov 16 '16 22:11 aaronpk

i have the same problem. And i have NO IDEA!

alphacentauri82 avatar Jun 13 '17 14:06 alphacentauri82

It problem your based on audiocodec Sometimes it been repaired with change audiocodec or in serials encoding(as enc only video and audio copy and next video copy and audio to aac)

dburianov avatar Jun 13 '17 15:06 dburianov

How do i fix it?. That's the question. I can see the stream just fine but it's jumpy and delayed at times.

alphacentauri82 avatar Jun 13 '17 15:06 alphacentauri82

I'm seeing this issue too. Has anyone found a solution?

milesegan avatar Feb 27 '18 07:02 milesegan

i have this while using an rtmp application that push the original stream toward several servers. starts creating thousands or mini segments

f6aa9ac39d5d0a8340d583c8d91548ed

campones avatar Aug 12 '18 10:08 campones

Now I use build ffmpeg from source code and do not have this problem ffmpeg 3.4.2 ./configure
--prefix="/usr/ffmpeg_build"
--pkg-config-flags="--static"
--extra-cflags="-I/usr/ffmpeg_build/include"
--extra-ldflags="-L/usr/ffmpeg_build/lib"
--extra-libs="-lpthread -lm"
--bindir="/usr/bin"
--enable-gpl
--enable-libass
--enable-libfdk-aac
--enable-libfreetype
--enable-libmp3lame
--enable-libopus
--enable-libtheora
--enable-libvorbis
--enable-libvpx
--enable-libx264
--enable-libx265
--enable-nonfree
--enable-filter=movie --enable-filter=drawtext --enable-libfreetype --enable-filter=overlay --enable-filter=yadif

dburianov avatar Aug 13 '18 07:08 dburianov

Having the same problem here. @dburianov, do you have an idea about what has changed from your distribution version to your own ffmpeg compilation? I'm using ffmpeg 4.0.4 from Fedora 29.

What happens to me looks like a (I know I'm not using the appropriate words) "desync" with the chunk size or something like that: 2019/05/04 15:25:05 [error] 969#0: *101 hls: force fragment split: 10.007 sec, , client: 127.0.0.1, server: 0.0.0.0:1935 2019/05/04 15:25:15 [error] 969#0: *101 hls: force fragment split: 10.008 sec, , client: 127.0.0.1, server: 0.0.0.0:1935 2019/05/04 15:25:25 [error] 969#0: *101 hls: force fragment split: 10.008 sec, , client: 127.0.0.1, server: 0.0.0.0:1935

hgshoggins avatar May 04 '19 15:05 hgshoggins

The issue is happening when the audio and video timestamps are starting from the different start timestamp. This is valid, however the nginx-rtmp library hls splitter does not account for this, taking dts for timestamp and assumes that they have the same start in audio and video.

To fix it I used -vf "setpts=PTS-STARTPTS" -af "asetpts=PTS-STARTPTS" as ffmpeg options.

Note: the nginx-rtmp interleave and sync options may mess around with timestamps even further.

mkrn avatar Oct 30 '20 12:10 mkrn

image

I am facing the same issue. Is there any updated solution to this error?

lve4code avatar May 13 '21 12:05 lve4code

Now I use build ffmpeg from source code and do not have this problem ffmpeg 3.4.2 ./configure --prefix="/usr/ffmpeg_build" --pkg-config-flags="--static" --extra-cflags="-I/usr/ffmpeg_build/include" --extra-ldflags="-L/usr/ffmpeg_build/lib" --extra-libs="-lpthread -lm" --bindir="/usr/bin" --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-filter=movie --enable-filter=drawtext --enable-libfreetype --enable-filter=overlay --enable-filter=yadif

You are using ffmpeg fron source, but how, where?

IgorDePaula avatar Oct 17 '22 13:10 IgorDePaula