All posts by Oliver

Creating a Timelapse from a CCTV DVR

If you have a Dahua, QVIS or similar DVR that works with PSS software, processing the video into a timelapse isn’t easy – it has an odd file format, it is segmented by the hour (my DVR only encoded one key frame per hour too), the tools are awkward with 100+GB of video and generally timelapses are created from stills, not video. I’ve put together a brief guide on one way of doing this – in my case combining three weeks of footage from 3 cameras at 6fps and combining them into a <2 minute timelapse. You will need the following tools:

This assumes you’ve used PSS before and can download .dav files in hourly segments. Firstly, download all of the hourly segments using PSS for each camera.  Using the batch file converter, select the folder with the .dav files in and let it do its thing.

avi-batch-file-dav-to-avi-converter-screenshot

Now that you have a folder full of converted files, combine the files into more manageable groups. Using three cameras,  I organised by /camera name/dd_mm.avi and concatenated the eight hours from each day into a single file – the trick is to do this without with needing to re-encode anything (and losing quality). Avidemux does this with its Append feature (Ctrl+A shortcut).

Open the first file and repeat the Append function for each subsequent file. When finished use the save function to save the file as a .avi.  You may be able to skip this Append step and concatenate all files using a single step in Avisynth, see below, depending on the number / size of your files.

Tiling the three camera views and combining days

To tile and combine these daily streams, Avisynth is the right tool. Create a new text file putting

dir /s /b >filelist.txt

as its contents. Rename to .bat. Run a copy of this in each folder and you’ll have a file listing in a new text file. Create a new file in Notepad++ and use the search and replace to make the list match this formatting for each camera (A, B, C, D etc).

A=UnalignedSplice(AVISource("D:\timelapse\front\front_1_02.avi"),AVISource("D:\timelapse\front\front_2_04.avi"),AVISource("D:\timelapse\front\front_3_05.avi"),AVISource("D:\timelapse\front\front_4_06.avi"),AVISource("D:\timelapse\front\front_5_07.avi"),AVISource("D:\timelapse\front\front_6_08.avi"),AVISource("D:\timelapse\front\front_7_11.avi"),AVISource("D:\timelapse\front\front_8_12.avi"),AVISource("D:\timelapse\front\front_9_13.avi"),AVISource("D:\timelapse\front\front_10_14.avi"),AVISource("D:\timelapse\front\front_11_15.avi"),AVISource("D:\timelapse\front\front_12_18.avi"),AVISource("D:\timelapse\front\front_13_19.avi"),AVISource("D:\timelapse\front\front_14_20.avi"),AVISource("D:\timelapse\front\front_15_21.avi"),AVISource("D:\timelapse\front\front_16_22.avi"),AVISource("D:\timelapse\front\front_17_25.avi"),AVISource("D:\timelapse\front\front_18_26.avi")).AddBorders(4, 0, 0, 4))

There are only three feeds in my case, so I added a fourth blank image in the unused area. These four entities can now be stacked.

D=ImageSource("d:\timelapse\spare.bmp", end=2000, use_DevIL=true).AddBorders(4, 6, 0, 0).ConverttoYv12()

StackVertical(StackHorizontal(A,B),StackHorizontal(C,D))

Add the above code at the bottom of the new file and save as a file with the extension .avs. This is an Avisynth file, that will play like any normal video in Media Player Classic using Avisynth as a frameserver.

This will result in a tiled, combined, unedited stream of all of the footage with regular keyframes for editing.

Editing

The 1 hour between keyframes means it takes too long to skip to frames using Avisynth as a frameserver. This delay makes it impractical to edit the video. To eliminate this open the .avs in VirtualDub and use the frame rate control option to increase the source frame rate as appropriate (I changed it from 6 to 60fps) and speed up playback.  Using Lagariths lossless codec, export to a new file. This file was ~450GB in my case.

To quickly scan through that footage, play the resulting file in Media Player Classic using Ctrl+Up to fast forward, Space to pause and Left / Right arrow keys to step frames. Each time you find a Start or Stop point, press Ctrl+G and copy the frame number to a spreadsheet. Export as a CSV and use search / replace in Notepad++ to create a new file with the start/stop frame numbers in the following format.

AVISource("D:\timelapse\combined_four_cameras.avi").levels(0,0.900,255,0,255).autolevels()
Trim(1164,2700).FadeIn(24)+Trim(2832,3300)+Trim(4752,5028)+Trim(5233,6240).FadeOut(24)+Trim(10634,10702).FadeIn(24)+Trim(12151,14103)+Trim(14395,14533)+Trim(14992,16241)+Trim(17989,18575)+Trim(18700,18855)+Trim(19201,19225)+Trim(19703,20703)+Trim(21125,21186)+Trim(21512,21518)+Trim(21548,21562).FadeOut(24)

Open this new .avs file in VirtualDub. Using the frame rate control option again,  change both the Source rate adjustment and Frame rate conversion. Keeping ‘Convert to fps’ at 60, adjust the Source rate adjustment to a higher figure to increase the speed at which the final output will be played.

VirtualDub frame rate adjustment

Finally, change the video encoder to x264vfw in VirtualDub (Ctrl+P) and go to ‘Save as AVI’ (F7).

disclaimer: there are probably ways of doing this with fewer tools / steps. 

ncase M1

A build with the ncase M1; my first mini-ITX build without many compromises.

hdd-activity-led-fade-modification
Schematic for soft-blinking HDD load light
PART / DESCRIPTIONLINK
StarTech 45cm Rounded SATA cableslink
New Power Button -12mm vandal switch w white LEDlink
HDD LED – Any flat topped white LEDlink
LED Clip – 5mm cliplink
470uF Capacitor – I had 16ZLG470MEFC10X12.5 to handNA
Almost any diode – I had 1N5817G to handNA
Resistor between 600 – 1000 Ohms – I had a 680 Ohm to handNA
Nitrile Rubber O-Ring 12mm x 1mmlink
25mm rubber blanking pluglink
M2.5 fibre washers (these are a tight / centred fit unlike the correct M3 fibre washers)link
M3 x 6mm Socket Countersunk – case screwslink
M3 x 8mm Socket Flanged Button Screw – Motherboard and hard drive grommet screwslink
M3 x 4mm Nylon sleeve / spacer for hard drive grommetslink
M3 x 4mm Socket Button Screw – Bracket screwslink
M3 x 4mm Low Head Cap Screw – Case screwslink
Power supply cable / pins / connectors and removal toollink