Reply
New Member
pfish
Posts: 27
Registered: ‎12-22-2011
Posts: 27
Kudos: 6
Registered: 12-22-2011

PHP: On-demand full resolution screenshot

I had a need for a 3rd party system to pull sceenshots from our AirCams when certain events were triggered. I came up with a very simple PHP script to pull the current image from a camera, save it, then display it. Every time the page is refreshed, the image is updated.

No authentication needed since we're using the RTSP credentials (if any) to pull the capture.

example.php



system("ffmpeg -i rtsp://username:password@10.0.0.1/live/ch00_0 -y -f image2 -sameq -t 0.001 /path/to/warehouse.jpg");

header( "Content-type: image/jpeg" );
@readfile("/path/to/warehouse.jpg");
?>
Regular Member
ripv
Posts: 734
Registered: ‎07-17-2011
Posts: 734
Kudos: 189
Solutions: 3
Registered: 07-17-2011

Re: PHP: On-demand full resolution screenshot

Nice script, looks like the warehoused image is overwritten each time?
If so it would be nice to include a date and time stamp in the image name, that way each capture could be stored for future reference.
New Member
g57
Posts: 15
Registered: ‎10-06-2010
Posts: 15
Registered: 10-06-2010

Re: PHP: On-demand full resolution screenshot

ubuntu not work
New Member
pfish
Posts: 27
Registered: ‎12-22-2011
Posts: 27
Kudos: 6
Registered: 12-22-2011

Re: PHP: On-demand full resolution screenshot

Nice script, looks like the warehoused image is overwritten each time?
If so it would be nice to include a date and time stamp in the image name, that way each capture could be stored for future reference.


Definitely. You can define a variable at the beginning of the script and append that to the filename so you have an archive as well. Since I also run the NVR and have recordings, I didn't need to save them here as well.
New Member
pfish
Posts: 27
Registered: ‎12-22-2011
Posts: 27
Kudos: 6
Registered: 12-22-2011

Re: PHP: On-demand full resolution screenshot

ubuntu not work


Check to make sure you can run ffmpeg outside of Apache - you may need a version compiled with H.264 support. That file also needs to be writable by your web server user. Be sure to change the path to fit your environment as well.
Established Member
bp2008
Posts: 857
Registered: ‎11-12-2009
Posts: 857
Kudos: 146
Solutions: 5
Registered: 11-12-2009

Re: PHP: On-demand full resolution screenshot

That is indeed nice and simple. The only problem is that method will open a new ffmpeg process for every image frame you want to capture. This is fine if the image doesn't get requested very often (you probably want them to be, at minimum, a few seconds apart).

BlueIris on Windows will host native resolution jpeg images with great efficiency and as quickly as you can request them.

I think Zoneminder on Linux might do the same thing, but I don't run Linux on any of my systems so I couldn't say for sure.
Newbie
maslak
Posts: 2
Registered: ‎05-14-2012
Posts: 2
Registered: 05-14-2012

Re: PHP: On-demand full resolution screenshot

It's really nice sollution, but I cannot acheive full image - your script all the time grabs grey image with some compression on it... I cannot grab full image, becouse everytime this script starts it opens new stream to ffmpeg and I think what Im getting is stream beginning (same effect as in vlc.. - first fev seconds are messed up and highly compressed)
Reply