[英]How to repackage mov/mp4 file into HLS playlist with multiple audio streams
I'm trying to convert some videos (in the different formats, eg, mp4, mov) which contain one video stream and multiple audio streams into one HLS playlist with multiple audio streams (treated as languages) and only one video stream.我正在尝试将包含一个视频 stream和多个音频流的一些视频(不同格式,例如 mp4、mov)转换为一个具有多个音频流(被视为语言)和只有一个视频 stream 的 HLS 播放列表。
I already browsed a lot of stack threads and tried many different approaches, but I was only able to find answers for creating different HLS playlists with different audios.我已经浏览了很多堆栈线程并尝试了许多不同的方法,但我只能找到创建具有不同音频的不同 HLS 播放列表的答案。
Sample scenario which I have to handle:我必须处理的示例场景:
What I was able to achieve is to create multiple hls playlists each with different audio track.我能够实现的是创建多个 hls 播放列表,每个播放列表都有不同的音轨。
ffmpeg -i "file_name.mp4" \
-map 0:v -map 0:a -c:v copy -c:a copy -start_number 0 \
-f hls \
-hls_time 10 \
-hls_playlist_type vod \
-hls_list_size 0 \
-master_pl_name master_playlist_name.m3u8 \
-var_stream_map "v:0,agroup:groupname a:0,agroup:groupname,language:ENG a:1,agroup:groupname" file_name_%v_.m3u8
My biggest issue is that I'm having hard time understanding how -map
and -var_stream_map
options should be used in my case, or if they even should be used in this scenario.我最大的问题是我很难理解在我的情况下应该如何使用-map
和-var_stream_map
选项,或者是否应该在这种情况下使用它们。
An example of the result of ffmpeg -i
command on the original mov file which should be converted into HLS. ffmpeg -i
命令对应转换为 HLS 的原始 mov 文件的结果示例。
Stream #0:0[0x1](eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080, 8786 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
Metadata:
handler_name : Apple Video Media Handler
vendor_id : [0][0][0][0]
timecode : 00:00:56:05
Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
handler_name : SoundHandler
vendor_id : [0][0][0][0]
Stream #0:2[0x3](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s
Metadata:
handler_name : SoundHandler
vendor_id : [0][0][0][0]
I also checked this blogpost and I would like to achieve this exact effect, but with video, not with audio.我还检查了这篇博文,我想达到这个确切的效果,但是用视频而不是音频。
For example, -var_stream_map "v:0,a:0 v:1,a:0 v:2,a:0" implies that the audio stream denoted by a:0 is used in all three video renditions.例如,-var_stream_map "v:0,a:0 v:1,a:0 v:2,a:0" 意味着在所有三个视频再现中都使用了由 a:0 表示的音频 stream。
The stream_map looks fine. stream_map 看起来不错。 However the hls_muxer will not create a valid HLS playlist since it is missing the codec and bitrate information from the input stream since the audio and the video stream are copied (remember -c:v copy -c:a copy
) and not parsed / re-encoded.但是 hls_muxer 不会创建有效的 HLS 播放列表,因为它缺少来自输入 stream 的编解码器和比特率信息,因为音频和视频 stream 被复制(记住-c:v copy -c:a copy
)并且不解析/重新-编码。 To add those, use the -tag
and -b
options to specify the properties for all your video and audio streams in HLS.要添加这些,请使用-tag
和-b
选项指定 HLS 中所有视频和音频流的属性。
Example for your video stream: -tag:v:0 h264 -b:v:0 8786k
视频示例 stream: -tag:v:0 h264 -b:v:0 8786k
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.