We have a surveillance camera recording taken at intervals of a month. It is necessary to remove the dark time of the day (night recordings) from the record or from the video file by deleting all frames with a black pixel ratio of more than 30%.
I perform the following steps:
- step 1 - speeding up all files attached to the directory
*.mp4
:
for %%i in (".mp4") do ffmpeg -i %%i -r 30 -filter:v "setpts=1/3600*PTC" "Output\%%i"
- step 2 - merge accelerated
*\Output
files into*.mp4
:
ffmpeg -f concat -safe 0 -i list.txt -c copy General(h_264).mp4
- step 3 - convert to H.265 codec
*.mp4
:
ffmpeg -i General(h_264).mp4 -vcodec hevc TimeLapse(h_265).mp4
- The solution came from @Gantendo - As a result, I get a *. mp4 file without 27% of frames exceeding 98% of black pixels. (I can only explain it this way):
ffmpeg -i in.mp4 -vf "blackframe=amount=0:threshold=98, metadata=select:key='lavfi.blackframe.pblack':value=27:function=less" -vsync 0 img%d.mp4