简体   繁体   English

FFMPEG 命令将视频 stream 复用到 HLS fMP4

[英]FFMPEG command to mux video stream into HLS fMP4

I have been trying to display my IP Cameras output onto a webpage to be viewed on a iThing (ipad or iphone)我一直在尝试将我的 IP 相机 output 显示到要在 iThing(ipad 或 iphone)上查看的网页上

Im diplaying the output below in a video tag like below我在下面的视频标签中显示下面的 output

<video id='hls-example'  class="video-js vjs-default-skin" width="400" height="300" controls>
       <source type="application/x-mpegURL" src="http://127.0.0.1/wordpress/prog_index.m3u8">
</video>

Im using ffmpeg to mux/convert (I may have my terminology wrong) the cameras http stream (not RTSP stream).我使用 ffmpeg 来复用/转换(我的术语可能有误)相机 http stream(不是 RTSP 流)。

Ive tried multiple commands below and some commands work on a PC/Chrome but none of them work on a ipad/safari or chrome.我在下面尝试了多个命令,其中一些命令可以在 PC/Chrome 上运行,但它们都不能在 ipad/safari 或 chrome 上运行。

All the files are being generated in the correct locations on the webserver to allow them to be diplayed所有文件都在网络服务器上的正确位置生成,以便显示它们

ffmpeg -i http://username:password@192.168.102.92/ISAPI/Streaming/channels/102/httpPreview  -force_key_frames "expr:gte(t,n_forced*2)" -sc_threshold 0 -s 640x480 -c:v libx264 -b:v 1536k -c:a copy -hls_time 6 -hls_playlist_type vod -hls_segment_type fmp4 -hls_segment_filename "fileSequence%d.m4s" -hls_wrap 3 prog_index.m3u8
ffmpeg -i http://username:password@192.168.102.92/ISAPI/Streaming/channels/102/httpPreview  -force_key_frames "expr:gte(t,n_forced*2)" -sc_threshold 0 -s 640x480 -c:v libx264 -b:v 1536k -c:a copy -hls_time 6 -hls_playlist_type vod -hls_segment_type fmp4 -hls_segment_filename "fileSequence%d.m4s" -hls_list_size 10 prog_index.m3u8
ffmpeg -i http://username:password@192.168.102.92/ISAPI/Streaming/channels/102/httpPreview  -force_key_frames "expr:gte(t,n_forced*2)" -sc_threshold 0 -s 640x480 -b:v 1536k -c:a copy -hls_time 6  -hls_segment_type fmp4 -hls_segment_filename "fileSequence%d.m4s" -hls_list_size 10 prog_index.m3u8
ffmpeg -i http://username:password@192.168.102.92/ISAPI/Streaming/channels/102/httpPreview -force_key_frames "expr:gte(t,n_forced*2)" -sc_threshold 0 -s 640x480 -b:v 1536k -c:a copy -hls_time 3 -hls_flags delete_segments -hls_segment_type fmp4 -hls_segment_filename "fileSequence%d.m4s" prog_index.m3u8

Can someone point out where Im going wrong, I think its the FFMPEG cmd?有人可以指出我哪里出错了,我认为是 FFMPEG cmd?

The first and second command might not work because of the -hls_playlist_type vod parameter.由于-hls_playlist_type vod参数,第一个和第二个命令可能不起作用。 VOD is made for a static file. VOD 是为 static 文件制作的。 Since you have a IP camera LiveStream, this might cause problems.由于您有 IP 摄像机 LiveStream,这可能会导致问题。 If you want the full history (start the stream at a specific point and keep the whole history until the encoding stops) you should use EVENT instead.如果您想要完整的历史记录(在特定点启动 stream 并保留整个历史记录直到编码停止),您应该改用 EVENT。 If you just want a livestream, remove the parameter.如果您只想要直播,请删除该参数。

Second, all commands copy the audio stream.其次,所有命令复制音频stream。 Since you already do a video encoding, the audio encoding doesn't take much more CPU load.由于您已经进行了视频编码,因此音频编码不会占用更多的 CPU 负载。 So I recommend also to re-encode the audio.所以我建议也重新编码音频。 This allows FFmpeg to perfectly create the HLS segments.这允许 FFmpeg 完美地创建 HLS 段。 -c:a aac -b:a 128k -ac 2 would be a good start for this. -c:a aac -b:a 128k -ac 2将是一个好的开始。

Apple also provides tools (mediastreamvalidator and hlsreport) that verifies your HLS stream (you need a mac to run this tool). Apple 还提供了验证您的 HLS stream 的工具(mediastreamvalidator 和 hlsreport)(您需要 mac 才能运行此工具)。 More details how to use them: https://www.martin-riedl.de/2018/09/09/hls-stream-validation/更多详细信息如何使用它们: https://www.martin-riedl.de/2018/09/09/hls-stream-validation/

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

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