quasarstream / PHP-FFmpeg-video-streaming

📼 Package media content for online streaming(DASH and HLS) using FFmpeg
https://www.quasarstream.com/op/php/ffmpeg-streaming?u=php-ff
MIT License
514 stars 117 forks source link

hls single file #60

Open ghost opened 4 years ago

ghost commented 4 years ago

trying to make this work:

ffmpeg -threads 0 -i test.mp4 -r 24 -g 48 -keyint_min 48 -sc_threshold 0 -c:v libx264^
 -s:v:0 1920x1080 -b:v:0 5200k -maxrate:v:0 5720k -bufsize:v:0 5200k^
 -s:v:1 1280x720 -b:v:1 3100k -maxrate:v:1 3410k -bufsize:v:1 3100k^
 -b:a 128k -ar 44100 -ac 2^
 -map 0:v -map 0:v -map 0:a^
 -f hls -var_stream_map "v:0,agroup:audio v:1,agroup:audio a:0,agroup:audio"^
 -hls_flags single_file -hls_segment_type fmp4 -hls_list_size 0 -hls_time 6  -master_pl_name master.m3u8 -y test%v.m3u8

so i edited the HLSFilter.php file:

    private function initArgs(Representation $rep): array
    {
        return [
            "-s:v", $rep->getResize(),
            "-crf", "20",
            "-r", "24",
            "-sc_threshold", "0",
            "-g", "48",
            "-keyint_min", "48",
            "-f", "hls",
            "-b:v", $rep->getKiloBitrate() . "k",
            "-maxrate", intval($rep->getKiloBitrate() * 1.2) . "k",
            "-hls_flags", "single_file",
            "-hls_segment_type", $this->hls->getHlsSegmentType(),
            "-hls_list_size", $this->hls->getHlsListSize(),
            "-hls_time", $this->hls->getHlsTime(),
            "-master_pl_name", $this->getInitFilename(),
            "-y", $this->getInitFilename()
        ];
    }

not sure if this is good or not? any other way to do that better? not sure also how to map the audios