FFmpeg: Convert MP4 to M3U8 with SRT Subtitles, Split Files & Customize Styles
To auto transfer an MP4 file with an SRT subtitle to an M3U8 format, split the file into 5MB segments, and include subtitle word style, you can use the following FFmpeg command:\n\nbash\nffmpeg -i input.mp4 -vf \"subtitles=input.srt:force_style='Fontname=Arial,Fontsize=24,PrimaryColour=&H0000ff&'\" -c:v libx264 -c:a aac -hls_time 10 -hls_segment_size 5000000 output.m3u8\n\n\nHere's a breakdown of the command:\n\n- -i input.mp4: Specifies the input MP4 file.\n- -vf \"subtitles=input.srt:force_style='Fontname=Arial,Fontsize=24,PrimaryColour=&H0000ff&'\": Applies the SRT subtitle to the video with specified subtitle style. Replace input.srt with the path to your SRT file, and modify the force_style parameters to match your desired subtitle style.\n- -c:v libx264 -c:a aac: Sets the video codec to H.264 (libx264) and the audio codec to AAC, which are commonly used for M3U8 format.\n- -hls_time 10: Sets the segment duration to 10 seconds. Adjust this value as per your requirements.\n- -hls_segment_size 5000000: Sets the maximum segment size to 5MB (5,000,000 bytes). Adjust this value as per your requirements.\n- output.m3u8: Specifies the output M3U8 file.\n\nMake sure you have FFmpeg installed and configured on your system before running this command.
原文地址: https://www.cveoy.top/t/topic/psFP 著作权归作者所有。请勿转载和采集!