how to ffmpeg auto transfer from mp4 with srt file subtitle to m3u8 and split file to 5mb and with subtitle Chinese word style
To automatically convert an MP4 file with an SRT subtitle file to an M3U8 format, split the file into 5MB chunks, and apply Chinese word-style subtitles, you can use the following FFmpeg command:
ffmpeg -i input.mp4 -vf "subtitles=input.srt:force_style='FontName=Arial,FontSize=24,PrimaryColour=&H00FFFF&,OutlineColour=&H000000FF,BorderStyle=3,Outline=2,Shadow=1'" -c:v libx264 -c:a aac -hls_time 10 -hls_segment_size 5M -hls_flags independent_segments -hls_playlist_type vod output.m3u8
Here's an explanation of the command options used:
-i input.mp4: Specifies the input MP4 file.-vf "subtitles=input.srt:force_style='FontName=Arial,FontSize=24,PrimaryColour=&H00FFFF&,OutlineColour=&H000000FF,BorderStyle=3,Outline=2,Shadow=1'": Applies the SRT subtitle file with specified Chinese word-style settings. You can modify the style options as per your preference.-c:v libx264 -c:a aac: Sets the video and audio codecs for encoding.-hls_time 10: Sets the duration of each segment to 10 seconds. You can adjust this value as needed.-hls_segment_size 5M: Specifies the maximum size for each segment to 5MB. You can change this value as per your requirements.-hls_flags independent_segments: Enables independent segment files for improved playback.-hls_playlist_type vod: Sets the playlist type to video-on-demand (VOD).output.m3u8: Specifies the output M3U8 playlist file.
Make sure to replace input.mp4 with the path to your input MP4 file and input.srt with the path to your SRT subtitle file. Adjust the output filename and path as per your preference.
Note: Ensure you have FFmpeg installed on your system before running the command
原文地址: https://www.cveoy.top/t/topic/hJBL 著作权归作者所有。请勿转载和采集!