WWBN / AVideo-Encoder

Encoder Server for AVideo Platform Open-Source
https://platform.avideo.com
GNU Affero General Public License v3.0
152 stars 189 forks source link

[FFMPEG] command optimization #540

Open gbrn opened 2 months ago

gbrn commented 2 months ago

@DanielnetoDotCom Danny, analyzing the ffmpeg HLS command in the encoder, I found that some commands can be inserted to optimize. I ask that you take into consideration and test the following commands:

[30] Dynamic HLS: -c:v h264 -vf scale=-2:{$resolution} -r 24 -g 48 -keyint_min 48 -sc_threshold 0 -bf 3 -b_strategy 2 -minrate {$minrate}k -crf 23 -maxrate {$maxrate}k -bufsize {$bufsize}k -c:a aac -b:a {$audioBitrate}k -f hls -hls_time 6 -hls_list_size 0 -hls_key_info_file {$destinationFile}keyinfo {$destinationFile}res{$resolution}/index.m3u8

. Use -movflags +faststart (If HLS is for VOD) If you are creating HLS files for video on demand (VOD), it may be useful to enable +faststart. This moves the video file's metadata to the beginning, which speeds up the start of playback when the file is progressively downloaded.

-movflags +faststart

. Improve HLS Segmentation The current segmentation value (-hls_time 6) is set to 6 seconds, which is a good practice in terms of latency for live streaming. However, depending on the network or target device, adjustments can be made: Add -hls_playlist_type vod: Specify vod (Video on Demand), which can improve how players process the playlist: -hls_playlist_type vod