On windows, I have a dynamically created uncompressed avi video file which grows overtime. The application which generates the video file can only write to a physical file. I can start/stop generation of video file and delete the old video file easily.
I would like to analyze the changing last frame of the growing video file to make some decision depending on the content of the current/latest image in real time. If I can achieve more than 10fps it should be enough. I would like to get uncompressed images whenever a new frame available in the video file.
As a file format I think png could be the best options in that case but I am open to alternatives. I wonder if such a thing is possible with ffmpeg or with a similar tool.
I prefer to analyze the image and make decisions by using a perl+Imager module. Tha analyisis requirements are not complicated. Basically I just need to find existence of a few small images in certain locations inside the last frame. I would also appreciate if you can suggest an efficient way to get this information in to my application from ffmpeg. For example piping directly to my code or reading from saved png files.
I know perl already has an ffmpeg interface module but as far as I understand that module can't provide the functionality I need.
First off, I hope you realize the data rate of uncompressed video! E.g., at 720x480 (plain 'ol NTSC, not HD) with 16-bit color at 10fps, you're generating 6.6 megabytes per second. You fill a 1TB hard drive in less than two days. Handling that data rate in perl should be interesting.
Getting new frames from the file should be fairly simple, since its uncompressed video.
sysread it. Continue trying until either you get the full frame (updating your requested length each time, of course), or you get an EOF (sysread returns 0).Time::HiRes will let you sleep for less than 1 second) and then try to read the rest of the frame again. sysread doesn't need an EOF indication reset; it'll try again each time you call it. Keep doing the delay/sysread cycle until you have a full frame.You may find that if you use a library to implement your computer vision, it has functions to help with this—e.g., it may be able to read frames from an AVI file. OpenCV, for example, can.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With