I have 5 cameras each having an RTSP stream. I am converting that rtsp stream to HLS. This is the command I am using:
ffmpeg -rtsp_transport tcp -i rtsp://*:*@*:*/ -f hls -codec copy -strftime 1 -strftime_mkdir 1 -hls_time 10 -hls_list_size 360 -hls_segment_filename %Y%m%d/%H/%M%S.ts playlist.m3u8
The command gives the right output for 2 of the cameras. For the rest, the playlist files always has the incorrect duration (It is supposed to be 10 seconds):
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:5
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:5.000000,
videos/0/2/20210513/13/2632.ts
#EXTINF:5.000000,
videos/0/2/20210513/13/2642.ts
#EXTINF:5.000000,
For some reason the duration always gets written as half of the actual video duration in the playlist.
When I set hls_time to 5 seconds, the playlists for those respective cameras shows duration as 2.5 seconds even though the '.ts' is 5 seconds long.
What could be wrong?
I was using an older version of FFMPEG. The default version in the Ubuntu repository is 4.2. To get the latest version I used this link: https://johnvansickle.com/ffmpeg/
Thanks @llogan