我正在使用一個(gè)名為pascalbaljetmedia/laravel-ffmpeg并想要?jiǎng)?chuàng)建一個(gè)用于視頻流的 HLS 播放列表。但首先我想檢查視頻比特率或?qū)挾?高度,看看它是否是 4k、1080、720 等。那么我如何計(jì)算視頻比特率及其尺寸?...這是獲取視頻信息后我想做的事情:$video = FFMpeg::fromDisk('videos') ->open('original_video.mp4') ->exportForHLS();$resolutions = [];//check if we can make 4k versionif ( ( $bitrate >= 14000 ) || ( $width >= 3840 && $height >= 2160 ) ) { // Then it's a 4k video // We make a 4k version of HLS $resolutions[] = ['q' => 14000, 'size' => [ 'w' => 3840, 'h' => 2160]];}//check if we can make HD versionif( ( $bitrate >= 5800 ) || ( $width >= 1920 && $height >= 1080 ) ){ // Then it's a HD video // We make a HD version of HLS $resolutions[] = ['q' => 5800, 'size' => [ 'w' => 1920, 'h' => 1080]];} //Lastly we loop through and add formartsforeach($resolutions as $resolution){ $video->addFormat($resolution['q'], function($media) { $media->addFilter('scale='. $resolution['size']['w].':'. $resolution['size']['h]); });}$video->save('video_name.m3u8');有什么幫助嗎?
如何獲得視頻的最高可能比特率和尺寸?
幕布斯7119047
2023-07-08 15:45:29