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