I have problem with creating playable uncomplete MP4 file created from FFMPEG. In my case I have some infinite RTSP stream (h.264) from IP camera.
My target is record this stream to MP4 files for playback. If i use FFMPEG mp4 muxer, work correctly.
/usr/bin/ffmpeg -progress pipe:5 -use_wallclock_as_timestamps 1 -analyzeduration 10000000 -probesize 10000000 -fflags +igndts -rtsp_transport tcp -hwaccel auto -loglevel warning -i rtsp://****:****@*******:****/ -y -an -vcodec copy -strict experimental -movflags frag_keyframe+empty_moov -f segment -segment_format mp4 -segment_format_options movflags=+faststart -segment_atclocktime 1 -reset_timestamps 1 -strftime 1 -segment_time 15 /Shinobi/videos/bWkwjTWdRt/Rm67cYyq50/test-%S.mp4
FFMPEG will create one MP4 file which still increasing its size. If I try copy or simply open this (uncomplete, still increased ... of course :) ) file, it's correcly play. But it's still only one file ... still bigger and bigger. For long-term recording cam (few weeks) it's not good.
I want segment this stream to multiple smaller MP4 files (as you knows from another typical NVR systems). For example: segment for 30minutes.
I used "segment" muxer.
/usr/bin/ffmpeg -progress pipe:5 -use_wallclock_as_timestamps 1 -analyzeduration 10000000 -probesize 10000000 -fflags +igndts -rtsp_transport tcp -hwaccel auto -loglevel warning -i rtsp://*****:****@*********:****/ -y -an -vcodec copy -strict -2 -movflags frag_keyframe+empty_moov -f mp4 -segment_atclocktime 1 -reset_timestamps 1 -strftime 1 -segment_list pipe:8 -segment_time 15 /Shinobi/videos/bWkwjTWdRt/Rm67cYyq50/test-%S.mp4
It looks like work correctly. New file with defined mask is created every 30 minutes. If I try copy or simply open(and play) anyone "completed 30min segment file" it"s works correctly. Problem is with last file (more precisely: newest, still uncompleted last segment file) - it's not playable (moov atom not found).
I Googled my problem many time with another keywords. I was try many my wonders. I readed FFMPEG documentation maybe 5times.
Problem is with second passthroug which "segment muxer" do (which do -movflags +faststart .. for example). It's logicaly, second passthroug not be did in last(newest) file yet.
Is there way to make it work? If I want see time for 2-3 mins ago it's no possible wait up to 30minutes for "complete segment" ... and at the same time it is not possible to have a billion files with 2-3sec segments.
How did other NVR systems solve this? Synology, Hikvision and more has in their file system recorded MP4 soubory which one of them is still uncompleted, still growing, but normaly PLAYABLE.
A few last days I tried this with no success. I'am absolutely angry and sad. I hope that my text is understandable
Thank you
This options has no effect in my case (tried):
-movflags frag_keyframe+empty_moov
-movflags faststart
-movflags separate_moof
-fragsize *** / -fragtime ***
-strict -2 / -strict experimental
question from:
https://stackoverflow.com/questions/66063797/ffmpeg-playable-mp4-segmented-video-from-rtsp 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…