如何将多个 .VTT 片段转换为单个 .VTT 文件或字幕文件?

如何将多个 .VTT 片段转换为单个 .VTT 文件或字幕文件?

我有一个来自一堆 URL 的 .VTT 段列表,这些段用于如下所示的流(段的总数要高得多):

https://drod24s.akamaized.net/all/clear/none/d9/5e625421a95a611504451ed9/00922001400/subtitles/Foreign_HardOfHearing-17241006-627dc540-cc6e-44dc-a003-09ea95deff85/segment_3.vtt
https://drod24s.akamaized.net/all/clear/none/d9/5e625421a95a611504451ed9/00922001400/subtitles/Foreign_HardOfHearing-17241006-627dc540-cc6e-44dc-a003-09ea95deff85/segment_2.vtt
https://drod24s.akamaized.net/all/clear/none/d9/5e625421a95a611504451ed9/00922001400/subtitles/Foreign_HardOfHearing-17241006-627dc540-cc6e-44dc-a003-09ea95deff85/segment_1.vtt
https://drod24s.akamaized.net/all/clear/none/d9/5e625421a95a611504451ed9/00922001400/subtitles/Foreign_HardOfHearing-17241006-627dc540-cc6e-44dc-a003-09ea95deff85/segment_0.vtt

有没有办法可以自动将所有片段转换为一个文本文件,而无需手动执行?

答案1

我们可能会创造playlist.m3u8 HLSS播放列表文件,并将其作为输入传递给 ffmpeg:

创建playlist.m3u8包含 URL 段的文本文件:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:0
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:1,
https://drod24s.akamaized.net/all/clear/none/d9/5e625421a95a611504451ed9/00922001400/subtitles/Foreign_HardOfHearing-17241006-627dc540-cc6e-44dc-a003-09ea95deff85/segment_0.vtt
#EXTINF:1,
https://drod24s.akamaized.net/all/clear/none/d9/5e625421a95a611504451ed9/00922001400/subtitles/Foreign_HardOfHearing-17241006-627dc540-cc6e-44dc-a003-09ea95deff85/segment_1.vtt
#EXTINF:1,
https://drod24s.akamaized.net/all/clear/none/d9/5e625421a95a611504451ed9/00922001400/subtitles/Foreign_HardOfHearing-17241006-627dc540-cc6e-44dc-a003-09ea95deff85/segment_2.vtt
#EXTINF:1,
https://drod24s.akamaized.net/all/clear/none/d9/5e625421a95a611504451ed9/00922001400/subtitles/Foreign_HardOfHearing-17241006-627dc540-cc6e-44dc-a003-09ea95deff85/segment_3.vtt
#EXT-X-ENDLIST

执行以下 FFmpeg 命令下载并合并 VVT 段:

ffmpeg -y -protocol_whitelist file,http,https,tcp,tls,crypto -allowed_extensions ALL -i playlist.m3u8 -c copy -f webvtt merged_segments.vvt


注意:该解决方案已在 Windows 10 中
进行了测试。ffmpeg version 5.1.2-full_build-www.gyan.dev

相关内容