Skip to content

Commit a15d751

Browse files
committed
v2.0.0 Final Release
1 parent b710b02 commit a15d751

File tree

4 files changed

+87
-65
lines changed

4 files changed

+87
-65
lines changed

README.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,27 @@ Are you a content creator looking to engage with your audience around the clock?
1919
## Customization:
2020
The following elements are customizable to fit your needs:
2121

22-
1. **Video Source:** set any video you want to stream.
2322

24-
2. **Resolution:** Set video resolution of your choice.
23+
- Video File: Set the path to your video file (e.g., `.mp4`).
2524

26-
3. **Frames per Second:** Set the desired FPS (30, 50, 60).
25+
- Audio File: Set the path to your audio file (e.g., `.mp3`).
2726

28-
4. **Bitrate:** Adjust video and audio bitrates for desired quality.
27+
- Audio Bitrate: Choose the audio bitrate (e.g., `64k`, `128k`, `320k`).
2928

30-
5. **Audio Channels:** Mono or Stereo audio options.
29+
- FPS: Set the desired FPS (e.g., `30`, `60`).
3130

32-
6. **Sample Rate:** Select the sample rate for audio.
31+
- Video Quality: Select video quality options (e.g., `2160p`, `1440p`, `1080p`, `720p`, `480p`, `360p`, `144p`).
3332

34-
7. **Thread Count:** Set the number of threads for processing based on your CPU core count.
33+
- Resolution: Automatically set based on the selected video quality (e.g., `3840x2160` for `2160p`).
3534

36-
8. **RTMP URL:** Customize the streaming destination URL (for services like YouTube).
35+
- Bitrate: Video bitrate automatically adjusts based on video quality selection.
3736

38-
To apply these changes, simply edit the `live.sh` file and adjust the parameters to your preferences.
37+
- Error Handling: The script checks for missing files and invalid input (FPS and video quality).
38+
39+
- FFmpeg Command: Automatically starts streaming to the specified RTMP URL.
40+
41+
How to Apply Changes:
42+
Edit the `live.sh` file and adjust the parameters to your preferences.
3943

4044
## Video Tutorial:
4145

filelist.txt

-1
This file was deleted.

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ app.get('/', (req, res) => {
77
})
88

99
app.listen(port, () => {
10-
console.log(`Your Live Stream Is Running..`)
10+
console.log(`Sending data to live stream!`)
1111
})
1212

1313
const { exec } = require('child_process');

live.sh

+73-54
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,73 @@
1-
#!/bin/bash
2-
3-
file_list="filelist.txt"
4-
rm -f "$file_list"
5-
for f in songs/*.mp3; do
6-
echo "file '$PWD/$f'" >> "$file_list"
7-
done
8-
9-
video_file="video.mp4" # Name of your video file
10-
quality="854:480" # Set video resolution (e.g., 1280:720 for 720p, 1920:1080 for 1080p, 3840:2160 for 4K)
11-
# Resolution Options:
12-
# 480p -> "854:480" (Low quality, for small screens or low bandwidth)
13-
# 720p -> "1280:720" (Standard HD, good for most purposes)
14-
# 1080p -> "1920:1080" (Full HD, widely used for higher quality)
15-
# 1440p -> "2560:1440" (Quad HD, better quality than Full HD)
16-
# 4K -> "3840:2160" (Ultra HD, very high quality for large displays)
17-
fps=30 # Set frames per second (e.g., 30, 50, 60)
18-
# Recommended: 30 for standard, 50 or 60 for smooth motion
19-
bitrate="1500" # Set video bitrate (e.g., 1500k, 5000k, 10000k)
20-
# Video Bitrate Recommendations:
21-
# 480p -> 1500k
22-
# 720p -> 2500k-3500k
23-
# 1080p -> 5000k-10000k
24-
# 1440p -> 10000k-15000k
25-
# 4K -> 20000k-50000k or higher for ultra-high quality
26-
audio_bitrate="320k" # Set audio bitrate (e.g., 64k, 128k, 320k)
27-
# Audio Bitrate Recommendations:
28-
# 64k -> Low quality audio (for voice streams, e.g., podcasts)
29-
# 128k -> Good audio quality (stereo, standard quality)
30-
# 320k -> High quality audio (for music, good fidelity)
31-
audio_channels=2 # Set audio channels (1 for mono, 2 for stereo)
32-
# Audio Channels:
33-
# 1 -> Mono (single channel, lower quality)
34-
# 2 -> Stereo (dual channel, standard for most streams)
35-
sample_rate=44100 # Set audio sample rate (e.g., 44100, 48000)
36-
# Recommended: 44100 for most use cases, 48000 for professional audio
37-
threads=4 # Number of threads to use (depends on CPU cores)
38-
# Recommended: Match your CPU core count
39-
stream_url="rtmp://a.rtmp.youtube.com/live2/sch2-1qmh-zgam-x7za-4z9c" # Streaming destination URL
40-
# Replace with your platform's RTMP URL and stream key
41-
42-
43-
# FFmpeg Command
44-
ffmpeg -stream_loop -1 -re -i "$video_file" -f concat -safe 0 -i "$file_list" \
45-
-vcodec libx264 -preset ultrafast -pix_fmt yuv420p -r "$fps" -g "$((fps * 2))" -keyint_min "$((fps * 2))" \
46-
-b:v "$bitrate"k -maxrate "$bitrate"k -bufsize "$((2 * bitrate))k" \
47-
-c:a aac -b:a "$audio_bitrate" -ar "$sample_rate" -ac "$audio_channels" -movflags +faststart \
48-
-vf "scale=$quality" \
49-
-f flv "$stream_url" \
50-
-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 2 -threads "$threads" -y
51-
52-
53-
54-
rm -f "$file_list"
1+
#-------------------------------------------------------------------------------------------------------------
2+
# Customization Section
3+
Video_File="/workspaces/Livestream-24-7/video.mp4" # Change the path according to your system
4+
Audio_File="/workspaces/Livestream-24-7/songs/Polvo Rodante.mp3" # Change the path according to your system
5+
Audio_Bitrate="128k" # Options: "64k" , "128k" , "320k"
6+
FPS=30 # Options: "60" , "50", "30"
7+
Video_Quality="1440p" # Options: "2160p", "1440p", "1080p", "720p", "480p", "360p", "144p"
8+
Stream_Key="qfcd-v3wp-hcqb-kjs1-1eqc" # Replace with your actual stream key
9+
RTMP_URL="rtmp://a.rtmp.youtube.com/live2" # Replace with your platform's RTMP URL (for YouTube, use the default URL)
10+
#-------------------------------------------------------------------------------------------------------------
11+
12+
if [ ! -f "$Video_File" ]; then
13+
echo "Error: Video file not found at $Video_File!"
14+
exit 1
15+
fi
16+
17+
if [ ! -f "$Audio_File" ]; then
18+
echo "Error: Audio file not found at $Audio_File!"
19+
exit 1
20+
fi
21+
22+
if ! echo "$Audio_Bitrate" | grep -qE '^(64k|128k|320k)$'; then
23+
echo "Error: Invalid audio bitrate $Audio_Bitrate! Valid options are '64k', '128k', or '320k'."
24+
exit 1
25+
fi
26+
27+
if ! echo "$FPS" | grep -qE '^(30|50|60)$'; then
28+
echo "Error: Invalid FPS value $FPS! Valid options are '30', '50', or '60'."
29+
exit 1
30+
fi
31+
32+
if [ -z "$Stream_Key" ]; then
33+
echo "Error: Stream key is missing. Please provide a valid stream key."
34+
exit 1
35+
fi
36+
37+
if [ -z "$RTMP_URL" ]; then
38+
echo "Error: RTMP URL is missing. Please provide a valid RTMP server URL."
39+
exit 1
40+
fi
41+
42+
if ! echo "$Video_Quality" | grep -qE '^(2160p|1440p|1080p|720p|480p|360p|144p)$'; then
43+
echo "Error: Invalid video quality $Video_Quality! Valid options are '2160p', '1440p', '1080p', '720p', '480p', '360p', or '144p'."
44+
exit 1
45+
fi
46+
47+
if [ "$Video_Quality" = "2160p" ]; then
48+
Resolution="3840x2160"
49+
Video_Bitrate="5000k"
50+
elif [ "$Video_Quality" = "1440p" ]; then
51+
Resolution="2560x1440"
52+
Video_Bitrate="4000k"
53+
elif [ "$Video_Quality" = "1080p" ]; then
54+
Resolution="1920x1080"
55+
Video_Bitrate="3000k"
56+
elif [ "$Video_Quality" = "720p" ]; then
57+
Resolution="1280x720"
58+
Video_Bitrate="1500k"
59+
elif [ "$Video_Quality" = "480p" ]; then
60+
Resolution="854x480"
61+
Video_Bitrate="1000k"
62+
elif [ "$Video_Quality" = "360p" ]; then
63+
Resolution="640x360"
64+
Video_Bitrate="750k"
65+
elif [ "$Video_Quality" = "144p" ]; then
66+
Resolution="256x144"
67+
Video_Bitrate="400k"
68+
else
69+
Resolution="1920x1080"
70+
Video_Bitrate="3000k"
71+
fi
72+
73+
ffmpeg -stream_loop -1 -re -i "$Video_File" -stream_loop -1 -re -i "$Audio_File" -vcodec libx264 -pix_fmt yuvj420p -maxrate 20048k -preset veryfast -r $FPS -framerate 30 -g 50 -c:a aac -b:a $Audio_Bitrate -ar 44100 -strict experimental -video_track_timescale 1000 -b:v $Video_Bitrate -s $Resolution -f flv "$RTMP_URL/$Stream_Key"

0 commit comments

Comments
 (0)