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

Streams interrupted and restarted during recording #166

Open
revunix opened this issue Sep 16, 2024 · 6 comments
Open

Streams interrupted and restarted during recording #166

revunix opened this issue Sep 16, 2024 · 6 comments

Comments

@revunix
Copy link

revunix commented Sep 16, 2024

Hi,

I’ve noticed that streams are being interrupted and restarted periodically when recording with streamdvr. This issue does not occur when recording the same streams directly with streamlink or using streamdvr. The interruptions seem inconsistent—sometimes the recording lasts for 4 hours, sometimes for only 1 hour, and occasionally there are no interruptions at all. I checked the logs, but there’s nothing indicating why this is happening.

I'm using the following configuration:

name: TWITCH
plugin: ./lib/plugins/basic
siteUrl: https://www.twitch.tv/
urlback: ""
enable: true
m3u8fetch: scripts/m3u8_streamlink.sh
m3u8fetch_args: ["--twitch-proxy-playlist=https://as.luminous.dev/,https://twitch.zzls.xyz"]
recorder: scripts/record_streamlink.sh
recorder_args: ["--twitch-proxy-playlist=https://as.luminous.dev/,https://twitch.zzls.xyz"]
scanInterval: 300
batchSize: 5
noTerminateOffline: false
streamers:
  - - montanablack88
  - - papaplatte
  - - therealknossi
  - - hsu_live
  - - thiseguysessions
    - unpaused

config.yaml

enable:
  daemon: false
recording:
  autoConvertType: mp4
  captureDirectory: "/media/twitch/capturing"
  completeDirectory: "/media/twitch/captured"
  postprocess: "scripts/postprocess_ffmpeg.sh"
  dateFormat: "YYYYMMDD_HHmmss"
  fileNameFormat: "%n_%s_%d"
  includeSiteInDir: false
  streamerSubdir: true
  siteSubdir: true
  keepTsFile: false
  minSize: 0
  maxSize: 0
postprocess: ""
log:
  enable: true
  append: true
tui:
  enable: true
  allowUnicode: true
colors:
  name: magenta
  state: yellow
  offline: blue
  prompt: blue
  file: green
  time: grey
  site: green
  cmd: grey
  debug: yellow
  error: red
proxy:
  enable: false
  server:
debug:
  log: true
  recorder: true
  errortrace: true

Do you have any idea what might be causing this issue? Is there perhaps a difference in how streamdvr processes streams?

Thanks for the help!

@revunix
Copy link
Author

revunix commented Sep 17, 2024

Push

@jrudess
Copy link
Owner

jrudess commented Sep 18, 2024

There are two reason this happens.

  • The m3u8fetch script continues to periodically poll if the streamer is offline. There have been many cases where the streamer terminates their broadcast, but both streamlink and ffmpeg captures do not detect this and keep running forever. So when the polling gets back a result saying that the streamer is offline, then any capture process is terminated with SIGINT. You can shut this behavior off by setting the following option in your twitch.yml.
noTerminateOffline: true
  • Sometimes the recording process just get stuck, and the streamer is still online, but the streamlink/ffmpeg process is not receiving data and the filesize of the .ts file being captured does not increase. After 3 polling loops for the m3u8fetch script, if it is observed that the filesize has not increased, then the recording process is killed with SIGINT. There is an info message that prints for this case though "recording appers to be stuck (counter=3), file size is not increasing." This behavior can not be shut off.

@revunix
Copy link
Author

revunix commented Sep 18, 2024

Thanks for the explanation! I'll test it out and see if it works as expected.

noTerminateOffline: true

@jrudess
Copy link
Owner

jrudess commented Sep 19, 2024

Thinking about this more, the 'filesize' check was added much later than the first case where streamlink/ffmpeg don't terminate when the broadcast stops. But I think the filesize check probably also solves the same problem that the 1st check was trying to solve. I may change the default to be noTerminateOffline: true.

Also there have been a couple of years of streamlink/ffmpeg releases since people were running into the hung-recording problems, and it may just not be a problem anymore.

@revunix
Copy link
Author

revunix commented Sep 19, 2024

This did not solve the problem.

noTerminateOffline: true

@revunix
Copy link
Author

revunix commented Sep 21, 2024

It was my mistake. I ran it as a systemctl, but using the --user option, and that’s where the issue was. Now everything is working perfectly! 👍

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

2 participants