Question
How to extract snapshots from camera stream to PC using FFMPEG
Answer
There are two ways to get snapshots from the camera, using an internal event that will send a snapshot to a specific location and request it using a CGI command (cgi-bin/viewer/video.jpg). But some applications require to get more than one snapshot per second, and if it uses the CGI approach it will eventually overload the camera CPU, especially when the camera is also recording and providing video feedback,
FFMPEG is a tool that can allow you to get video streams from the camera and manage them (https://ffmpeg.org/). In this guide we will teach you how to extract snapshots from your camera’s RTSP stream instead of using the CGI command (cgi-bin/viewer/video.jpg). Please follow the next steps:
Step 1. Download FFMPEG tool from the following link:
ftp://fae:fae@ftp.vivotek.com/Tool/FFMPEG.zip
Step 2. Extract the files contained in the .zip folder in your preferred location (e.g C:/)
Step 3. Open the windows console (cmd.exe) and go to the folder in where you exported the files using the following command:
Microsoft Windows [Version 10.0.19045.4170]Step 4. Use the following command to retrieve the snapshots from the camera stream:
(c) Microsoft Corporation. All rights reserved.
C:/Users> cd <Folder Path>/bin
ffmpeg -i rtsp://<Camera IP>/live.sdp -vf fps=1 -qscale:v =1 C:\<Destination>\img%03d.jpg
-i rtsp:///live.sdp camera video stream (audio + video)
-qscale:v quality of the video (1~31 with 1 being the best quality and 31 the worst quality)
-vf set the number of video frames to output
fps set the number of frames per second
C:\\img%03d.jpg download path
img%03d.jpg jpeg file name (The %03d dictates that the ordinal number of each output image will be formatted using 3 digits.)
Please note that in this example we used stream 1 (live.sdp) but you can choose any stream you want. We strongly suggest setting the stream used to JPEG in order to avoid quality loss. Additionally, if the camera has a user/password configured you will need to add it to the RTSP line as follows:
rtsp://user:password@<Camera IP>/live.sdp
For more information please check: https://trac.ffmpeg.org/wiki/Create%20a%20thumbnail%20image%20every%20X%20seconds%20of%20the%20video
Comments
0 comments
Article is closed for comments.