Friday, November 1, 2024

ffmpeg to hls convert

FRIST LETS CREATE AN MUTIPLE AUDIO TRACKS TO USING THTAT COMMAND



"C:\ffmpeg\bin\ffmpeg.exe" -i "//path your mkv video" -c:a aac -b:a 96k -ac 2 -ar 48000 -map 0:a:0 -f hls -hls_time 6 -hls_playlist_type vod -hls_segment_filename "path of you video floder \audio1\audio1_hindi_%03d.ts" "path of you video floder \output\audio1\audio1_hindi.m3u8"

change audio1 folder when you have multiple audio track
like this audio2\audio2_english.m3u8

create the folders like audio1 audio2 on the correct path to initiate the progress
*******************************************************************

"C:\ffmpeg\bin\ffmpeg.exe" path of your ffmpeg 
How To Find It 
1. open command prompt
2. type command where is my ffmpeg
3. you can find the path C:\ffmpeg\bin\ like this (its not same in your case the Path can be changed)
4. for using ffmpeg you can use C:\ffmpeg\bin\ffmpeg (C:\ffmpeg\bin\ is your path of ffmpeg just type the ffmpeg to use it)


******************************************************************

USE 0:a:0 ----- 0 is you audio track number like if you have 3 audio tacks in your .mkv video file 
Then You Have To use that command for 3 times 
 
#NOTE = you have to change 0:a:0 for first audio track
                                                 0:a:1 for second audio track
                                                 0:a:2 for third audio track


*********************************************************************


this is the master.m3u8 file 

#EXTM3U
#EXT-X-VERSION:3

# Hindi Streams
#EXT-X-STREAM-INF:BANDWIDTH=800000,RESOLUTION=360p
360p/360p_hindi.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1400000,RESOLUTION=480p
480p/480p_hindi.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2500000,RESOLUTION=720p
720p/720p_hindi.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=4500000,RESOLUTION=1080p
1080p/1080p_hindi.m3u8

# English Streams
#EXT-X-STREAM-INF:BANDWIDTH=800000,RESOLUTION=360p
360p/360p_english.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1400000,RESOLUTION=480p
480p/480p_english.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2500000,RESOLUTION=720p
720p/720p_english.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=4500000,RESOLUTION=1080p
1080p/1080p_english.m3u8

# Audio Tracks
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="Audio Track 1",DEFAULT=YES,AUTOSELECT=YES,URI="D:/Demon Slayer/Season 5/output/audio1/audio1.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="Audio Track 2",DEFAULT=NO,AUTOSELECT=YES,URI="D:/Demon Slayer/Season 5/output/audio2/audio2.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="Audio Track 3",DEFAULT=NO,AUTOSELECT=YES,URI="D:/Demon Slayer/Season 5/output/audio3/audio3.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="Audio Track 4",DEFAULT=NO,AUTOSELECT=YES,URI="D:/Demon Slayer/Season 5/output/audio4/audio4.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="Audio Track 5",DEFAULT=NO,AUTOSELECT=YES,URI="D:/Demon Slayer/Season 5/output/audio5/audio5.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="Audio Track 6",DEFAULT=NO,AUTOSELECT=YES,URI="D:/Demon Slayer/Season 5/output/audio6/audio6.m3u8"




***********************************************************************

html jw video player 

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/x-icon" href="./assets/img/favicon.png" />
    <script> document.title = "Video Player";</script>

    <!-- JS Files -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
    <script src="https://ssl.p.jwpcdn.com/player/v/8.8.6/jwplayer.js"></script>

    <!-- CSS Files -->
    <link rel="stylesheet" type="text/css" href="./assets/player_style.css">
    <link rel="stylesheet" type="text/css" href="./assets/codenine_skin.css">

    <!-- JWPlayer License -->
    <script type="text/javascript">
        jwplayer.key = "YOUR_JWPLAYER_KEY"; // Replace with your JWPlayer key
    </script>
</head>
<body>

    <!-- Video Player Container -->
    <div id="codenine_player"></div>

    <script>
        jwplayer('codenine_player').setup({
            file: './master.m3u8',  // Pointing to your master.m3u8 file
            autostart: false,
            stretching: "uniform",
            aspectratio: "16:9",
            image: "./assets/img/sintel.jpg", // Optional poster image
            playbackRateControls: true,
            hlsjsdefault: true  // Use HLS.js for playback
        });
    </script>

    <script>
        // Loader script - fade-out animation
        $(document).ready(function() {
            $("#loader").delay(1000).fadeOut("slow");
            $("#loader-wrapper").delay(1500).fadeOut("slow");
        });
    </script>

    <!-- Optional Loader HTML Structure -->
    <div id="loader-wrapper">
        <div id="loader"></div>
        <div class="circle-line">
            <div class="circle-blue"></div>
            <div class="circle-red"></div>
            <div class="circle-green"></div>
            <div class="circle-yellow"></div>
        </div>
    </div>
    
</body>
</html>


**************************************************************************

To convert an MKV video file to HLS format with different video qualities (360p, 480p, 720p, and 1080p) without including any audio tracks, you can use the following `ffmpeg` commands. Each command will create HLS streams for the specified resolution and generate the necessary `.m3u8` playlists and `.ts` segment files.

### ffmpeg Commands for Each Video Resolution

#### 1. Convert to 360p


"C:\ffmpeg\bin\ffmpeg.exe" -i "D:\Demon Slayer\Season 5\Demon Slayer Kimetsu no Yaiba - S04E02 [1080p].mkv" -vf "scale=-2:360" -c:v h264 -b:v 800k -f hls -hls_time 6 -hls_playlist_type vod -hls_segment_filename "D:\Demon Slayer\Season 5\output\360p\360p_%03d.ts" "D:\Demon Slayer\Season 5\output\360p\360p.m3u8"


#### 2. Convert to 480p


"C:\ffmpeg\bin\ffmpeg.exe" -i "D:\Demon Slayer\Season 5\Demon Slayer Kimetsu no Yaiba - S04E02 [1080p].mkv" -vf "scale=-2:480" -c:v h264 -b:v 1400k -f hls -hls_time 6 -hls_playlist_type vod -hls_segment_filename "D:\Demon Slayer\Season 5\output\480p\480p_%03d.ts" "D:\Demon Slayer\Season 5\output\480p\480p.m3u8"


#### 3. Convert to 720p

"C:\ffmpeg\bin\ffmpeg.exe" -i "D:\Demon Slayer\Season 5\Demon Slayer Kimetsu no Yaiba - S04E02 [1080p].mkv" -vf "scale=-2:720" -c:v h264 -b:v 2500k -f hls -hls_time 6 -hls_playlist_type vod -hls_segment_filename "D:\Demon Slayer\Season 5\output\720p\720p_%03d.ts" "D:\Demon Slayer\Season 5\output\720p\720p.m3u8"


#### 4. Convert to 1080p


"C:\ffmpeg\bin\ffmpeg.exe" -i "D:\Demon Slayer\Season 5\Demon Slayer Kimetsu no Yaiba - S04E02 [1080p].mkv" -vf "scale=-2:1080" -c:v h264 -b:v 4500k -f hls -hls_time 6 -hls_playlist_type vod -hls_segment_filename "D:\Demon Slayer\Season 5\output\1080p\1080p_%03d.ts" "D:\Demon Slayer\Season 5\output\1080p\1080p.m3u8"



0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home