how to make a timelapse with continuous recording, after the fact

Spirch

Getting the hang of it
Joined
Dec 7, 2018
Messages
129
Reaction score
60
Location
Canada
so I wanted to do timelapse for my own benefit and while searching i found out that it wasn't that easy.

I made this powershell script that prepare everything for you, you need ffmpeg (search for it)

if you have any question, let me know. step by step in the header of the file
if you see any mistake, let me know.
if you have any idea on how to improve this, let me know.

(this script should work for anything, not only hikvision)

example: 4 days of video in 11 minutes, 78 video file (mp4) from the cameras




Code:
###
### not tested with space in folder / file name
###
### 0. configure below
### 1. run this script
### 2. run _batch.bat, go sleep
### 3. when done run _concat.bat
### 4. enjoy your _final.mp4 video
###

###config begin

$path = $PSScriptRoot #path where the video are
$factor = "0.005" #this is how you can figure out; total video in second * factor = time of final video in second. 0.005 = 7m30s for 24h
$parallelRun = 2 #how many ffmpeg do you want to run in parallel, it peak at 3-4 gig of per run for me
$ffmpegPath = "D:\Download\ffmpeg-20200209-5ad1c1a-win64-static\bin\ffmpeg.exe" #where is ffpmeg
$fileExt = "*.mp4" #extension of the videos

###config end

$files = Get-ChildItem $path  -File -filter $fileExt
$count = $files.Count
$filePerBatch = ([Math]::Ceiling($count / $parallelRun))

$i=1

$PSDefaultParameterValues=@{'out-file:encoding'='ascii'}

$videoList = Join-Path $path "_videolist.txt"
foreach ($file in $files)
{
    $videoIn = Join-Path $path $file
    $videoOut = Join-Path $path "__out-$(($i++).ToString('00000')).mp4"
    $batchFile = Join-Path $path "_Batch$([Math]::Ceiling($i / $filePerBatch)).bat"
   
    Write-Output "file '$($videoOut)' " >> $videoList
    Write-Output "start /low /wait /b $($ffmpegPath) -i $($videoIn) -filter:v ""setpts=$($factor)*PTS"" -an $($videoOut)" >> $batchFile
}

$concatFile = Join-Path $path "_concat.bat"
Write-Output "start /low /wait /b $($ffmpegPath) -safe 0 -f concat -i $($videoList) -c copy _final.mp4" >> $concatFile

$batchFiles =  Join-Path $path "_batch.bat"
For ($i=1; $i -le $parallelRun; $i++)
{
    $batchFile = Join-Path $path "_Batch$($i).bat"
    Write-Output "start $($batchFile)" >> $batchFiles
}
 

OICU2

BIT Beta Team
Joined
Jan 12, 2016
Messages
821
Reaction score
1,330
Location
USofA
I used to make time lapses in Windows Movie Maker, it would allow you to drag and drop all the videos into a timeline and then you could speed it up by choosing a speed from a drop down.
 

Spirch

Getting the hang of it
Joined
Dec 7, 2018
Messages
129
Reaction score
60
Location
Canada
I used to make time lapses in Windows Movie Maker, it would allow you to drag and drop all the videos into a timeline and then you could speed it up by choosing a speed from a drop down.
i think microsoft killed that product :(
 

Spirch

Getting the hang of it
Joined
Dec 7, 2018
Messages
129
Reaction score
60
Location
Canada
windows movie maker might work but online documentation show that it seem to be supporting up to 1080 resolution, my solution work with higher resolution (you can see the video linked as an example)

also ffmpeg, work on windows / linux / macos, the script above should generate command line that should easily be adapted to other OS
 

Purduephotog

Getting the hang of it
Joined
Oct 30, 2016
Messages
204
Reaction score
77
For the critters, nothing that a .30 break barrel air rifle won't fix...

I'd love to have done this in Buffalo a couple of years back. Of course, it would have been 0' snow, then 7' snow, in 4 hours....
 

awahl101

Young grasshopper
Joined
Sep 21, 2017
Messages
66
Reaction score
15
just wondering why you are doing videos for the timelapse vs a picture etc every x minutes etc? its fine of you are doing short eriods but once you do extended periods your file size will be huge.

I do a few for long term construction projects we are at and they add up after time. I had used movie maker in the past to join all the images with a .1 second delay, making the file uses a good amount of pc memory however.

Sent from my LM-V405 using Tapatalk
 
Top