This is a simple node js code to create live streaming on YouTube 24/7 hours with ffempg
Just Need To Install Modules ffmpeg and enjoy with simple command :
Npmjs : https://www.npmjs.com/package/youtube-live-streaming
Firts one :
sudo apt update
sudo apt install ffmpeg
Step 2 :
Install Node js
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - && sudo apt-get install -y nodejs
Create file index.mjs
And Install module using this In terminal :
npm i youtube-live-streaming
And Paste This Simple Code to your File index.mjs
:
import youtube from "youtube-live-streaming";
const api = "jwze-rrs-tmwd-pwaz-a5m5"; //change with your streamkey
const video = "hajilok.mov"; //change with your video file name or video link
const audio = "https://stream.zeno.fm/ez4m4918n98uv"; //change with your mp3 link or audio file name
youtube(api, video, audio);
or
import youtube from "youtube-live-streaming";
const data = {
api: "jwze-rrs-tmwd-pwaz-a5m5",
video: "hajilok.mov",
audio: "https://stream.zeno.fm/ez4m4918n98uv",
}
youtube(data.api, data.video, data.audio);
Save You file and run in terminal with node index.mjs
Note : if not working or show any error plz ignore , check in youtube for your livestreaming is working or not because is module need any developetment , you can contribute with me
plz install express js and ffmpeg in your sistem if need using this module
Link Github : https://github.com/hajilok/youtube-live-streaming
Is proof Live streaming with this Project with render hosting and run 24 hours nonstop if my render is not suck π
Link Live Youtube for result of this project and listening music ncs : https://www.youtube.com/live/PfrvJBagIUc?si=LnTiU2CAAoo8LonV
Tutorial How To Use and Deploy To Render Hosting :
Clichttps://www.youtube.com/live/PfrvJBagIUc?si=LnTiU2CAAoo8LonVhttps://www.youtube.com/live/PfrvJBagIUc?si=LnTiU2CAAoo8LonVk Link This :
https://www.youtube.com/watch?v=0oz94rCzf7A
If Need Depploy to render or any hosting using main.js file and edit on line 7 for your video art content like lofi girl and plz add your .env if you need to deploy on render or any hosting
Example
streamkey = " " your screet key live in youtube
In This You can get Stream Key On Youtube
in this repository , you dont not need audio lofi because me have add in default with link audio lofi if you need livestream with content 24/7 hours nonstop lofi hiphop
update command ffmpeg in vaiabel " command " with your command ffmpeg for better result and any content live streaming never working
This A simple , Just Need too Fork this project and Copy this Yaml File and paste : :
version: 2.1
jobs:
build:
machine:
image: ubuntu-2204:2023.10.1
steps:
- checkout
- run: sudo apt-get update -y && sudo apt-get install nodejs -y
- run:
name: cloning github
command: git clone https://github.com/hajilok/youtube-live-streaming && cd youtube-live-streaming
- run:
name: Install Node.js dependencies
command: npm install
# Store .env file
- run:
name: Store .env file
command: echo 'streamkey=jtze-r9se-tm7d-p8yez-a5m5' > .env
# Run your Node.js app
- run:
name: Run Your Node.js App
command: node main.js # Replace with your Node.js application's entry point
workflows:
version: 2
build-deploy:
jobs:
- build
Note : jtze-r9se-tm7d-p8yez-a5m5
Replace With your key streaming in Youtube
This A simple , Fork My Gitlab Repository and Copy This Yaml File and Paste to Editor Pipeline
Links Gitlab Repository : https://gitlab.com/yukikatodo/youtube-live-streaming
stages:
- build
variables:
STREAM_KEY: jwze-r5ss-tm8d-p0az-a5d3
before_script:
- apt-get update -y
- apt-get install -y ffmpeg
- apt-get install -y nodejs
- apt-get install -y npm
- npm install
build:
stage: build
script:
- echo "streamkey=$STREAM_KEY" > .env
- node main.js
In Variabels Stream Key Replace with Your streamkey in youtube
Link Bitbucket : https://bitbucket.org/gohashindi/youtube-live-streaming
Simple You Need To Fork This Link Bitbucket And Edit In Pipelines Yaml With This :
# Template NodeJS build
# This template allows you to validate your NodeJS code.
# The workflow allows running tests and code linting on the default branch.
image: ubuntu
pipelines:
default:
- parallel:
- step:
name: Build and Test
deployment: production
caches:
- node
script:
- apt-get update -y
- apt-get install ffmpeg -y
- apt-get install nodejs npm -y
- echo "streamkey=jwze-r5ss-tm8d-p0az-a5d3" > .env
- npm install
- node main.js
Replace This jwze-r5ss-tm8d-p0az-a5d3
Your Stream Key in youtube
ffmpeg
node js with new version
How To Install :
Note : On build command on render or any hosting site using node main.js
sudo su -
apt install ffmpeg ( install if you dont have ffmpeg in your system or you using codespace in github you need to install with this command on terminal with user root )
npm install ( to install any package required on node js in codespace auto installing )
node main.js or node index.js