简体   繁体   中英

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)

Im diplaying the output below in a video tag like below

<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).

Ive tried multiple commands below and some commands work on a PC/Chrome but none of them work on a ipad/safari or 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?

The first and second command might not work because of the -hls_playlist_type vod parameter. VOD is made for a static file. Since you have a IP camera LiveStream, this might cause problems. 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. If you just want a livestream, remove the parameter.

Second, all commands copy the audio stream. Since you already do a video encoding, the audio encoding doesn't take much more CPU load. So I recommend also to re-encode the audio. This allows FFmpeg to perfectly create the HLS segments. -c:a aac -b:a 128k -ac 2 would be a good start for this.

Apple also provides tools (mediastreamvalidator and hlsreport) that verifies your HLS stream (you need a mac to run this tool). More details how to use them: https://www.martin-riedl.de/2018/09/09/hls-stream-validation/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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