Compiling video clips using python.
I was having lunch with a security chief. He was complaining about the countless cctv (i.e close circuit television) he has to monitor and download on a monthly basis.
He was telling me, everyday there are recordings of cctv footages in both his security guard training facilities and the shopping malls that he is in charge of looking after.
These cctv footages in the database has a limited lifespan. Usually, after 1 month has passed, the next month will override the footage of the previous month on a daily basis. Sometimes, the shopping mall management or even the local police requires cctv footage that has been overridden. To overcome this problem, whenever there is a event such as a thief case reported in the mall, he would download the cctv footage for the day, in case the shopping mall management or the police needs these footage to review.
But this process of downloading the cctv footage just takes too much time. He would look for each individual cctv, select the time, then click download. Many times, he don’t even know what he is looking for, such as the suspected thief to track on the cctv. As such, he would have to download the cctv based on time and keep the data separately, so that it does not get automatically deleted by the system.
Is there a simpler way to download the cctv? He asked me. Oh… I buy you coffee, if this is possible. He smiled.
Hmm… it looks like a good challenge to find out how we can improve our work with technology. I have gladly accepted his request.
It turns out there is module in python that does this. It is using movie.py. For the documentation do refer to User Guide — MoviePy 1.0.2 documentation (zulko.github.io) The movie.py allows user to cut, concatenate movie clips and put them together. Also, you can add subtitles in these movie clips too. This is useful, if you have movie clips from your vacation clips that you would like to edit and compile.
However, I realised there is a problem, how do I get the graphical user interface (i.e gui)up for the user to input the cctv footage that he wants to download? He has to be able to specify the date, time and the number of cctv that he wants to download. The gui should have an option to exclude cctv cameras that he does not need to download.
I decided to ask the security chief, if he has anything in mind. He told me, he uses microsoft excel in his office computer. Can this be done on excel? He asked.
This means I have to use python in excel. Hmm… is it possible?
I looked into the microsoft excel and found it has a programming language called visual basic for applications (i.e vba). Using vba, we can write a module inside excel to trigger a python program that sits inside his computer.
With the gui in excel, users would be able to select the date, time and camera to download. Then, user just need to click on a button in excel to activate the vba program to run the python.
I have setup a simple gui as seen below
The user would key in the date and time in yellow cells. In the example above, the date is key in as 20220303 i.e yyyymmdd. The time is 142225 i.e hhmmss. The timing for the rest of the cctv camera footages can be automated to calculate the time for him to download. In fact, if he only requires certain cctv cameras, he can specify. As in the example, say he only needs 20 seconds for camera 2, he just need to specify the timing he wants to download. He can leave the timing blank for cctv footage that he does not require. The system will not download cctv footages for those with zero timing in total time column.
Once he has input the timing he requires, he will then click on the blue button to download the cctv footage.
The downloading will then progress as shown below
There is a progress bar to tell the user how much has been compiled.
Once it is done, the user just need to go to the folder where the file is downloaded to retrieve it. The file is save in mp4 format.
The cctv footage can be downloaded while you go and make coffee. I told my security chief.
A few weeks passed, since I have downloaded python with the coding I have written into his computer. It turns out, he has been using the program daily. He has been more productive in his work and even uses the cctv footage to augment his training with his security officers.
How about my coffee? I asked him recently.
Anytime, my friend, he smiled.
It does feel good to make technology to do our work better. I smiled back.
For those who like see more of these updates. Do connect me at linkedin