Skip to content
This repository has been archived by the owner on Mar 1, 2022. It is now read-only.

Stream cut for a few seconds #104

Open
northerndub opened this issue Nov 6, 2018 · 19 comments
Open

Stream cut for a few seconds #104

northerndub opened this issue Nov 6, 2018 · 19 comments

Comments

@northerndub
Copy link

I'm on Windows and streaming to youtube, after every song the stream is down for like 1-2 seconds. Is there any way to fix this or is my setup to slow to get the next song going without a cut?

@LauraWebdev
Copy link
Collaborator

In theory, this is how this project works. It streams one song and then streams the next (unlike apps like obs who always have an open stream and just add sources on an open channel).

YouTube should usually keep up with that, if your stream is lagging try to check if your system is powerful enough to keep the stream up and not drop frames or try to play around with the bufsize config variable.

@torch2424
Copy link
Owner

Yup perfect response! I want to work on a "single video" mode at somepoint, so this doesn't happen, but that would be way far down the line :)

@northerndub
Copy link
Author

thx for the responses, the stream runs fine besides when it jumps to the next song. I will look into it again.

@northerndub
Copy link
Author

I played around with the config file but none of the changes affected the cut in any way.

More side Information, it's a virtual Server with Windows Server 2016 and with the stream running it peaks not over a 30% load.

@torch2424
Copy link
Owner

Are you using gifs by any chance? MP4s load better. But yes, no matter what, there will be cuts in the stream. Perhaps I can make it configurable to make the cuts have empty audio before and after? 😄

@LauraWebdev
Copy link
Collaborator

You can also try to disable the latency-free mode on youtube's dashboard to get a 30 seconds delay as a buffer.

@northerndub
Copy link
Author

I did try mp4 and gifs and the difference is not significant. The delay only delays the cut.

@torch2424
Copy link
Owner

I would try what @andreasWebDev I personally use that on my Youtube streams in the past, and had no issues 😮

@LauraWebdev
Copy link
Collaborator

LauraWebdev commented Nov 9, 2018

Yeah my DigitalOcean droplet always catches up the second of delay.. could you post the config file (without your stream key) in here? @northerndub

@northerndub
Copy link
Author

northerndub commented Nov 9, 2018

{
  "stream_url": "rtmp://a.rtmp.youtube.com/live2/$stream_key",
  "stream_key": "",
  "ffmpeg_path": "",
  "video_codec": "libx264",
  "audio_codec": "aac",
  "audio_bit_rate": "128k",
  "audio_sample_rate": "44100",
  "normalize_audio": true,
  "video_height": "480",
  "video_width": "854",
  "video_bit_rate": "500k",
  "video_fps": "12",
  "bufsize": "512k",
  "crf": "28",
  "preset": "veryfast",
  "threads": 6,
  "max_gif_size": "720",
  "api": {
    "host": "localhost",
    "port": "8000",
    "key": "super-secret-api-key",
    "number_of_history_items": 100
  },
  "radio": {
    "audio_directory": "./audio",
    "video_directory": "./video",
    "overlay": {
      "enabled": true,
      "font_path": "./fonts/Lato-Regular.ttf",
      "title": {
        "enabled": true,
        "text": "placeholder",
        "font_color": "#FFFFFF",
        "font_border": "#000000",
        "font_size": "10",
        "enable_scroll": true,
        "font_scroll_speed": "20",
        "position_x": "0",
        "position_y": "5"
      },
      "artist": {
        "enabled": true,
        "label": "Artist: ",
        "font_color": "#FFFFFF",
        "font_border": "#000000",
        "font_size": "10",
        "position_x": "2",
        "position_y": "15"
      },
      "album": {
        "enabled": false,
        "label": "Album: ",
        "font_color": "#FFFFFF",
        "font_border": "#000000",
        "font_size": "10",
        "position_x": "2",
        "position_y": "25"
      },
      "song": {
        "enabled": true,
        "label": "Song: ",
        "font_color": "#FFFFFF",
        "font_border": "#000000",
        "font_size": "10",
        "position_x": "2",
        "position_y": "25"
      },
      "image": {
        "enabled": false,
        "image_path": "./live-stream-radio-overlay-image.png",
        "position_x": 0,
        "position_y": 0
      }
    }
  },
  "interlude": {
    "enabled": false,
    "frequency": "0.2",
    "audio_directory": "./interludes/audio",
    "video_directory": "./interludes/video",
    "overlay": {
      "enabled": false,
      "font_path": "./fonts/Lato-Regular.ttf",
      "title": {
        "enabled": false,
        "text": "Please wait, music shall resume shortly...",
        "font_color": "#FFFFFF",
        "font_border": "#000000",
        "font_size": "10",
        "position_x": "2",
        "position_y": "5"
      },
      "image": {
        "enabled": false,
        "image_path": "./live-stream-radio-overlay-image.png",
        "position_x": 0,
        "position_y": 0
      }
    }
  }
}

@torch2424
Copy link
Owner

@andreasWebDev the config looks fine, and isn't using any high performance values.

@northerndub Yeah, honestly, this is how live-stream-radio works. I tried looking into how to keep it continuous, but I could not find a way to have an ffmpeg process switch inputs on the fly. I'll keep this open, and feel free to suggest any solutions to this in the code.

@LauraWebdev
Copy link
Collaborator

I've also tried researching it, in the end, programs like OBS can do it as well, so there is got to be a way (though they might have an active video stream that they can manipulate internally)

@torch2424
Copy link
Owner

I think what OBS does is take in VLC as an input. And VLC manages that for them?

I can definitely look into that, though, I wouldn't want to add VLC as a dependency

@northerndub
Copy link
Author

northerndub commented Nov 13, 2018

My other method was using VLC, I would feed a continuous ffmpeg stream with the desktop audio and playing the music through VLC, a little program "snip" grabs the title and writes it in a file and ffmpeg writes the content of the file on the stream. Very crude setup and really hoped it would work but I have weird audio cracks when using it. I think its because I must use a virtual audio card :/
I didn't found anything if you could feed ffmpeg directly VLC besides dshow.

I also have very little knowledge so everything was try and error :D

OBS is unfortunately very demanding and also breaks at some time, so not really good for 24/7

@StoneCypher
Copy link
Contributor

Here are some approaches to switching ffmpeg inputs on the fly, which is the correct solution layer.

Hot junction .3gp

Use HTTP Live Streaming

Multiplex through mpeg-ts

@StoneCypher
Copy link
Contributor

You can also do it manually with streamselect but that's pretty difficult

@torch2424
Copy link
Owner

@StoneCypher Woah! Dude I've been looking for a solution for this for like forever, I am soooo stoked you found these!

Keeping it real, I have been super busy in other projects involving WebAssembly. Thus, I'd honestly try these out because they seem like they would work. Particularly, the HLS looks the easiest / simplest to do. But I doubt I'd have the time until I get some vacation days from my new job that I just started like a month ago 😂

@StoneCypher could you open a PR for this? If so, I'd totally take the time to try it out and merge it 😄

Also, I saw on your Github profile you're based out of SF? I'll be living out here for a couple more weeks. If you want to chat about the project, we can grab coffee some time! Just hit me up on Twitter or something 😂

@beamercola
Copy link

I'm streaming this through Ant media server and playing it on iOS. It seems to issue a stop command on AVPlayer while it's changing tracks. This library is so incredible btw.

@torch2424
Copy link
Owner

@beamercola Thanks for the feedback! I super appreciate it! 😄 👍

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

No branches or pull requests

5 participants