使用单个ffmpeg实例将多个RTSP流转码为HLS-不起作用 [英] Using a single ffmpeg instance to transcode multiple RTSP streams to HLS - not working
问题描述
我正在尝试使用ffmpeg
的单个实例将多个RTSP流转换为HLS.我正在使用的命令是这样的:(我将其分解为多行,因此更易于阅读)
I am trying to use a single instance of ffmpeg
to convert multiple RTSP streams to HLS. The command I am using is this: (I've broken it up into multiple lines so its easier to read)
我面临的问题是当我查看生成的ts文件时,ffmpeg正在将相同的视频流(url1)写入目录m1和m2.我究竟做错了什么? url1和url2均有效.如果我将命令分解为两个不同的ffmpeg
进程,则可以正常工作.
The problem I am facing is that ffmpeg is writing the same video stream (url1) to both directories m1 and m2 when I look at the generated ts files. What am I doing wrong? Both url1 and url2 are valid. If I break up the command to two different ffmpeg
processes it works just fine.
谢谢.
/usr/local/bin/ffmpeg -i rtsp://url1 -fflags flush_packets
-max_delay 2 -flags -global_header -hls_time 2 -hls_list_size 3
-hls_segment_filename m1/video%03d.ts -hls_flags delete_segments
-vcodec copy -y m1/video1.m3u8
-i rtsp://url2 -fflags flush_packets
-max_delay 2 -flags -global_header -hls_time 2 -hls_list_size 3
-hls_segment_filename m2/video%03d.ts -hls_flags delete_segments
-vcodec copy -y m2/video2.m3u8
推荐答案
ffmpeg需要以下格式的语法
ffmpeg requires a syntax of the form
ffmpeg -i input1 -i input2 ... -i inputn output1 output2 ... outputn
设置了-map
选项以指示输入到输出的路由.
with -map
options set to indicate routing of inputs to outputs.
所以
-i rtsp://url1 -i rtsp://url2
-map 0 -fflags flush_packets -max_delay 2 -flags -global_header
-hls_time 2 -hls_list_size 3 -hls_segment_filename m1/video%03d.ts
-hls_flags delete_segments -vcodec copy -y m1/video1.m3u8
-map 1 -fflags flush_packets -max_delay 2 -flags -global_header
-hls_time 2 -hls_list_size 3 -hls_segment_filename m2/video%03d.ts
-hls_flags delete_segments -vcodec copy -y m2/video1.m3u8
这篇关于使用单个ffmpeg实例将多个RTSP流转码为HLS-不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!