automatic resolution & framerate downgrade if footage is older than some threshhold

fiban

n3wb
May 31, 2024
4
1
earth
Hey there! as you may guess, I am pretty new to surveillance stuff, and I didn't find any resources online, and god forbid I even asked chatgpt.

So here's what i'm trying to do:
  • Save the footage from about 6 cameras at 4k 30FPS (yes, I know this is probably way overkill) on some storage device. I don't know what storage device i'm gonna use, since I don't really care.
  • Downgrade all footage that is older than 6 hours to 4k, 30fps
  • Downgrade all footage that is older than a day to 1080p, 30fps
  • Downgrade all footage that is older than a week to 480p, 30fps
  • Downgrade all footage that is older than a month to 144p, 15fps.

I have no idea how to do this. I would probably have to write some kind of code that will do this. but as far as I know, you cant really run your own code on an NVR or any storage device except a PC. and I think most storage devices are kinda terrible at video rescaling since they use old ass CPUs.

Any help is appreciated, and if you could just direct me to some resource that talks about this, is good enough!
 
  • Like
Reactions: mat200
I do not have the ability to use it but I would be VERY surprised if someone well-versed on FFMPEG could not accomplish what you are asking for. :cool:
 
  • Like
Reactions: mat200
I don't think anyone has built software to manage progressively increasing the compression of video as it ages. At least nothing consumer-ready.

Although that is a nice sounding concept, it is not practical. Consider that in order to achieve your goals, you would need a system that is capable of realtime transcoding:

4k30 to 4k30 (presumably at a lower bit rate)
4k30 to 1080p30
1080p30 to 480p30
480p30 to 144p15

Multiplied by 6 cameras.

That works out to a video decoding workload of 3433 megapixels per second, and simultaneous encoding workload of 1947 megapixels per second. That is an absolute shitload of video transcoding. It would be very technically challenging to do efficiently and reliably, and a solution today would likely require either custom hardware or multiple general purpose computers (one for each 1-2 cameras). And at that point you might as well have just bought more and bigger hard drives and used regular NVR software that is already built and mature.
 
And add even more hardware if the clips have been saved in h265 format.

I recently edited some h265 footage from a dash cam, 2 2 minute clips which I joined, trimmed and converted to mp4, let’s just say it wasn’t instant.
 
  • Like
Reactions: mat200
I don't think anyone has built software to manage progressively increasing the compression of video as it ages. At least nothing consumer-ready.

Although that is a nice sounding concept, it is not practical. Consider that in order to achieve your goals, you would need a system that is capable of realtime transcoding:

4k30 to 4k30 (presumably at a lower bit rate)
4k30 to 1080p30
1080p30 to 480p30
480p30 to 144p15

Multiplied by 6 cameras.

That works out to a video decoding workload of 3433 megapixels per second, and simultaneous encoding workload of 1947 megapixels per second. That is an absolute shitload of video transcoding. It would be very technically challenging to do efficiently and reliably, and a solution today would likely require either custom hardware or multiple general purpose computers (one for each 1-2 cameras). And at that point you might as well have just bought more and bigger hard drives and used regular NVR software that is already built and mature.

Thank you for replying!

How much is ~3400 megapixels / second? I'm sure not every computer can do something like that. But surely a high end GPU could do that? the RTX 4090 should be able to handle 8 4k, 60fps streams at once (apparently), so Ican only assume it achieves those numbers quite easily?

I don't know a lot about security stuff, but I am pretty familiar with computers, so I hope I'm not just spewing out nonsense.
Please correct me if I'm wrong!
 
It really depends on the exact capabilities of the video processing hardware and also the efficiency of the transcoding pipeline. If the GPU can ingest compressed video and output compressed video, never needing to output and re-ingest the uncompressed images through its PCIe link, then there's definitely a chance that one modern GPU could handle the load if it is indeed said to handle 8 4K 60 FPS streams at once. If my math is correct, 8 4k60 streams is 3981 megapixels per second.

Granted you'd probably want a GPU and/or driver that is not limited to 1 or 2 simultaneous video encoding streams. But since the encodes don't technically have to happen concurrently, that limitation could be worked around in software if the GPU can transcode fast enough to keep up with the huge amount of incoming work.

This is something you could test for yourself to get a better idea of the feasibility. It would be relatively trivial to obtain 6 4K@30FPS video files recorded from IP cameras using whatever recording software you like. Then use ffmpeg to transcode those to each of your other sizes (maybe 4K@30 @ 6 Mbps, 1080p@30 @ 2 Mbps, and 480p@30 @ 0.5 Mbps). Then have some script start 24 ffmpeg instances all at the same time, one or two at a time, or whatever is necessary, to transwcode each of your 24 source video files to the next step down in quality. If all 24 transcodes manage to complete within 1 hour, then you'd have pretty strong evidence that the concept could be built out into real software. Of course this is all academic unless you have the motivation to build the video management software yourself or fund its development.
 
  • Like
Reactions: mat200
It really depends on the exact capabilities of the video processing hardware and also the efficiency of the transcoding pipeline. If the GPU can ingest compressed video and output compressed video, never needing to output and re-ingest the uncompressed images through its PCIe link, then there's definitely a chance that one modern GPU could handle the load if it is indeed said to handle 8 4K 60 FPS streams at once. If my math is correct, 8 4k60 streams is 3981 megapixels per second.

Granted you'd probably want a GPU and/or driver that is not limited to 1 or 2 simultaneous video encoding streams. But since the encodes don't technically have to happen concurrently, that limitation could be worked around in software if the GPU can transcode fast enough to keep up with the huge amount of incoming work.

This is something you could test for yourself to get a better idea of the feasibility. It would be relatively trivial to obtain 6 4K@30FPS video files recorded from IP cameras using whatever recording software you like. Then use ffmpeg to transcode those to each of your other sizes (maybe 4K@30 @ 6 Mbps, 1080p@30 @ 2 Mbps, and 480p@30 @ 0.5 Mbps). Then have some script start 24 ffmpeg instances all at the same time, one or two at a time, or whatever is necessary, to transwcode each of your 24 source video files to the next step down in quality. If all 24 transcodes manage to complete within 1 hour, then you'd have pretty strong evidence that the concept could be built out into real software. Of course this is all academic unless you have the motivation to build the video management software yourself or fund its development.


Again, thank you for your reply! sadly I do not have a RTX 4090 right now, but I will definitely see how much my current setup can do.

I do have one more question: Assuming I had a computer that can handle these streams easily, how would I actually connect & wire this up? I'm assuming I'd have to wire the camera to an NVR, and connect the NVR to a NAS to store everything. Then I'd have to connect my pc to the NAS in order to process the videos. Maybe there is a simpler way to do it, I don't know...
 
I'm assuming I'd have to wire the camera to an NVR, and connect the NVR to a NAS to store everything. Then I'd have to connect my pc to the NAS in order to process the videos. Maybe there is a simpler way to do it, I don't know...
No NVR needed.....a capable IP camera can stream using RTSP directly to a PC on the same network. The PC could use VLC or FFMPEG to record, store, re-encode and play the files.
 
  • Like
Reactions: mat200
No NVR needed.....a capable IP camera can stream using RTSP directly to a PC on the same network. The PC could use VLC or FFMPEG to record, store, re-encode and play the files.


RTSP works over internet, right???
The reason I don't think wireless would work well, is that internet, Wi-Fi, WLAN, whatever is very slow and sometimes cuts out completely where I live.
Is there any way to do this wired or without the need for constant internet?

again, I only did a few minutes of research about RTSP, so I might juust be spewing out nonsense.
 
RTSP works over internet, right???
Not directly and not all by itself.
The reason I don't think wireless would work well, is that internet, Wi-Fi, WLAN, whatever is very slow and sometimes cuts out completely where I live.
Who brought up wireless or Wi-Fi?
Is there any way to do this wired or without the need for constant internet?
I'm puzzled why you are mentioning wireless, Internet, etc....are you planning to do all what you mentioned in your Post #1 remotely?
again, I only did a few minutes of research about RTSP, so I might juust be spewing out nonsense.
No argument from me on that point.

I think you need to save up some cash, find a good software developer / programmer and tell him/her what you want. :cool:
 
Hey there! as you may guess, I am pretty new to surveillance stuff, and I didn't find any resources online, and god forbid I even asked chatgpt.

So here's what i'm trying to do:
  • Save the footage from about 6 cameras at 4k 30FPS (yes, I know this is probably way overkill) on some storage device. I don't know what storage device i'm gonna use, since I don't really care.
  • Downgrade all footage that is older than 6 hours to 4k, 30fps
  • Downgrade all footage that is older than a day to 1080p, 30fps
  • Downgrade all footage that is older than a week to 480p, 30fps
  • Downgrade all footage that is older than a month to 144p, 15fps.

I have no idea how to do this. I would probably have to write some kind of code that will do this. but as far as I know, you cant really run your own code on an NVR or any storage device except a PC. and I think most storage devices are kinda terrible at video rescaling since they use old ass CPUs.

Any help is appreciated, and if you could just direct me to some resource that talks about this, is good enough!

Some cameras have a main stream and a substream .. perhaps just saving the substream after X days and wiping the older full stream is a better option
 
  • Like
Reactions: Mike A.