futzu / SCTE-35_HLS_x9k3

HLS and SCTE-35 x9k3 is a HLS Segmenter with SCTE 35, and Live Streaming from Non-Live Soures and Looping.
67 stars 17 forks source link

Transmission dropping #33

Closed LuizStSantos closed 7 months ago

LuizStSantos commented 8 months ago

I'm using x9K3 to insert SCTE 35 data and I'm using index.m3u8 to transmit but it suddenly stops and doesn't continue transmission

OS: Debian 12 Comand: sudo x9k3 -i /usr/share/ffplayout/public/live/stream.m3u8 -s sidecar.txt -l

futzu commented 8 months ago

Why are you using sudo? Show me the output from x9k3 I need a link to the stream you are segmenting.

LuizStSantos commented 8 months ago

Why are you using sudo? Show me the output from x9k3 I need a link to the stream you are segmenting.

Stream: http://canalsolofertil.live:8787/live/stream.m3u8 This is my normal output stream, I use it internally /usr/share/ffplayout/public/live/stream.m3u8, x9k3 -i /usr/share/ffplayout/public/live/stream.m3u8 -s sidecar.txt -l Captura de tela 2024-01-08 152200 Captura de tela 2024-01-08 152258 It is not generating segments beyond these

My transmission output

Details

-c:v h264_nvenc -aspect 16:9 -r:v 30 -b:v 3200k -maxrate 3700k -bufsize 3800k -profile:v main -preset p4 -level 41 -delay 0 -ar 48000 -b:a 128k -c:a aac -colorspace:v bt709 -color_primaries:v bt709 -color_trc:v bt709 -color_range:v tv -f hls -hls_time 6 -hls_list_size 10 -g 60 -keyint_min 60 -hls_flags iframes_only+append_list+omit_endlist+delete_segments+program_date_time+split_by_time+append_list+round_durations -hls_segment_filename /usr/share/ffplayout/public/live/stream-%d.ts /usr/share/ffplayout/public/live/stream.m3u8

futzu commented 8 months ago

First off use https, nothing plays http anymore

Your looping is jacked up. ffmpeg is not doing your looping of the video, and it's at the end of the loop where it freezes on me. you are also skipping segments, your pts jumps from time to time .

deleted fu/seg13.ts
fu/seg18.ts:   start: 33.500000   end: 35.500000   duration: 2.000000
throttling 1.96
Verifying fu/seg19.ts time of 20.0     <---- This is either missing segments or a pts jump
Setting fu/seg19.ts time to 1.861333
deleted fu/seg14.ts
fu/seg19.ts:   start: 35.500000   end: 55.500000   duration: 1.861333
throttling 1.83
deleted fu/seg15.ts

I suspect your problem is how you're doing the looping .

x9k3 will loop a video for you. your best bet would be to pass x9k3 the mpegts file and let it segment it and loop it for you.

x9k3 -i video.ts -t 6 -r  
futzu commented 8 months ago

I'll be honest with you though, I am not sure exactly why it's stopping. It should be able to handle it.

futzu commented 8 months ago

It's working now, did you change something?

LuizStSantos commented 8 months ago

I'll be honest with you though, I am not sure exactly why it's stopping. It should be able to handle it.

I think I just discovered that I'm using ffplayout which has the effect of repeating the background stream when there is no material in the playlist, thus causing the stream to drop, deactivate it and it became normal

futzu commented 8 months ago

what does ffplayout do for you, I'm not familiar with it.

futzu commented 8 months ago

make sure you have the latest x9k3 too. I just added some stuff to handle pts jumps and such.

LuizStSantos commented 8 months ago

what does ffplayout do for you, I'm not familiar with it.

I use it to make a playlist of TV programming and may have a page for lay users "ME"

LuizStSantos commented 8 months ago

make sure you have the latest x9k3 too. I just added some stuff to handle pts jumps and such.

Wow thank you very much

futzu commented 8 months ago

you know x9k3 has a --continue_m3u8 option, you can do your own playlist do one short video , just to give it something to continue from ( I need to fix this)

x9k3 -i first.ts -o fufu 

then do a loop in the shell

for i in `ls *.ts`; do x9k3 -i ${i} -c -o fufu -l; done
futzu commented 8 months ago

I still had x9k3 running from before you made the change, it was just sitting there, then it start parsing when you made the change.

I think I just discovered that I'm using ffplayout which has the effect of repeating the background stream when there is no material in the playlist, thus causing the stream to drop, deactivate it and it became normal

You would think ffplayout would just start over at the top of the playlist.

Thanks for telling me, because I would have spent a lot of time trying to figure that one out.

futzu commented 8 months ago

https://github.com/futzu/x9k3/blob/main/README.md#playlist-support--boom-goes-the-dynamite playlist support

LuizStSantos commented 7 months ago

@futzu I tried several things and I noticed that even when a playlist file ffplayout cuts from one to another, it's just strange that cooliobr uses ffplayout too and he told me that he doesn't have this problem, I even made another machine and tried again by reinstalling all I'll leave this stream on for you to test http://canalsolofertil.live:8787/live/n/stream.m3u8

futzu commented 7 months ago

Huh? x9k3 playlists or ffplayout playlists? If x9k3, get the version I just uploaded 0.2.53 If ffplayout, I really don't know it, I've never used it. The only time x9k3 is going to just sit there is when it's waiting for data. If x9k3 has problem that it can't resolve it will fail.

I think your biggest problem is that your stream is HUGE and your server is slow. "Do the simplest thing that can possibly work" that's where you start. do the video 640x480 and see if that doesn't help. x9k3 is working for me but it's really slow. ffplay can't just barely play the stream but it's macro blocking and stuttering .

futzu commented 7 months ago

try this for your hls command

ffmpeg -re -i input.ts -flags +cgop -vcodec libx264 -preset faster -filter:v:0 scale=640:480 -g 30 -acodec aac -ab 64k -hls_list_size 0 -hls_time 2 stream.m3u8

See if that doesn't work better for you.

futzu commented 7 months ago

Even better, don't segment the stream, pass x9k3 an mpegts file.

Do you have ipforwarding turned on? sysctl -w net.ipv4.ip_forward=1

futzu commented 7 months ago

root@fu:~# tcpdump -i any src canalsolofertil.live and port 8787 -A

tcpdump: data link type LINUX_SLL2
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes
00:25:25.814157 wlp3s0 In  IP tbn-120-36.tbntelecom.com.br.8787 > fu.lan.44934: Flags [.], ack 3625796679, win 508, options [nop,nop,TS val 537296428 ecr 4113986094], length 0
E..4.5@.".-.-.x$...."S...Cx ..DG...........
 .~,.6r.
00:25:25.819474 wlp3s0 In  IP tbn-120-36.tbntelecom.com.br.8787 > fu.lan.45744: Flags [S.], seq 3382601239, ack 2880941674, win 65160, options [mss 1396,sackOK,TS val 537296432 ecr 4113986097,nop,wscale 7], length 0
E..<.5@.".,.-.x$...."S....f....j....q~.....t...
 .~0.6r1....
00:25:26.009681 wlp3s0 In  IP tbn-120-36.tbntelecom.com.br.8787 > fu.lan.45744: Flags [.], ack 145, win 508, options [nop,nop,TS val 537296622 ecr 4113986286], length 0
E..4.5@.".*.-.x$...."S....f................
 .~..6r.
00:25:26.011458 wlp3s0 In  IP tbn-120-36.tbntelecom.com.br.8787 > fu.lan.45744: Flags [P.], seq 1:156, ack 145, win 508, options [nop,nop,TS val 537296623 ecr 4113986286], length 155
E....5@.".)F-.x$...."S....f................
 .~..6r.HTTP/1.1 204 No Content
connection: close
content-type: application/json
date: Thu, 11 Jan 2024 05:25:25 GMT
cooliobr commented 7 months ago

Luiz, bom dia, você está fazendo muita confusão, mas muita mesmo! primeiro tente ter bastante conhecimento em um software, depois pelo para outro, para usar o x9k3 precisa ter o mínimo de experiencia com linux e alguma base de programação. Se você está tando problemas com o ffplayout que eu acredito que é isso, estude bem ele, não querendo te desanimar, mas tanto o tempo do Adrian quanto os outros que ajudam no projeto são tempos caros para perder com a solução de um problema que não faz parte do x9k3.

futzu commented 7 months ago

Here's what you should do, make sure each piece is working.

  1. Run the ffmpeg command ffmpeg -re -i input.ts -flags +cgop -vcodec libx264 -preset faster -filter:v:0 scale=640:480 -g 30 -acodec aac -ab 64k -hls_list_size 0 -hls_time 2 stream.m3u8
  2. run x9k3 x9k3 -i stream.m3u8

See if that works correctly for you , and then add ffplayout.

LuizStSantos commented 7 months ago

Here's what you should do, make sure each piece is working.

  1. Run the ffmpeg command ffmpeg -re -i input.ts -flags +cgop -vcodec libx264 -preset faster -filter:v:0 scale=640:480 -g 30 -acodec aac -ab 64k -hls_list_size 0 -hls_time 2 stream.m3u8
  2. run x9k3 x9k3 -i stream.m3u8

See if that works correctly for you , and then add ffplayout.

I just did a test here and what I did worked. went from ffplayout to ffmpeg

ffmpeg -re -i http://10.0.0.4:8787/live/stream.m3u8 -flags +cgop -vcodec libx264 -preset faster -filter:v:0 scale=640:480 -g 30 -acodec aac -ab 64k -hls_list_size 0 -hls_time 2 stream.m3u8

and from ffmpeg go to x9k3

x9k3 -i stream.m3u8 -l -d -n --output_dir /usr/share/ffplayout/public/live

and it worked without stopping, it just has a huge delay but I'm going to change the settings to see if I can reduce it assim

LuizStSantos commented 7 months ago

estou cehgando ao algun lugar After some testing I'm running it in 1080p now my problem is when it jumps from one clip to another using ffplayout it stops and freezes