繁体   English   中英

ffmpeg HLS分割音视频文件

[英]ffmpeg HLS segmentation audio and video files

我想执行 HLS 分段,并在带有音频的 .mp4 视频的每个分段的单独文件中获取音频和视频。 不需要调整比特率,因为那会导致额外的延迟。

我试着用

ffmpeg -i videoInput.mp4 -c:v copy –c:a copy -hls_segment_type mpegts –map a:0 –map v:0 -hls_time 1 out.m3u8 audio.ts

它完美地生成了视频文件,但只有一个音频文件。

谢谢你。

从 FFmpeg 文档我了解到:

       When there are two or more variant streams, the output filename
       pattern must contain the string "%v", this string specifies the
       position of variant stream index in the output media playlist
       filenames. The string "%v" may be present in the filename or in the
       last directory name containing the file. If the string is present
       in the directory name, then sub-directories are created after
       expanding the directory name pattern. This enables creation of
       variant streams in subdirectories.

'''

对我来说:

ffmpeg -hide_banner  -t 5:00 -i "$IN" -c copy -map a:0 -map v:0  -hls_segment_type mpegts -hls_time 1 -f hls   -var_stream_map "a:0 v:0"    v_%v/file.m3u8

在 v_0 和 v_1 中创建两个流。

我不知道确切的解决方案,但作为一种解决方法,您可以先提取音频:

ffmpeg -i video.mp4 -c:a copy -vn audio.aac 

然后分别对视频和音频文件应用分段

声音的:

 ffmpeg -i audio.aac -c:a copy -hls_segment_type mpegts -map a:0 -hls_time 1 out_aud.m3u8

视频:

ffmpeg -i video.mp4 -c:v copy -hls_segment_type mpegts -map v:0 -hls_time 1 out_vid.m3u8

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM