[FFmpeg-user] Scaling down resolution, reduce framerate and record video from IP camera

Tom Evans tevans.uk at googlemail.com
Mon Feb 18 12:58:23 CET 2013


On Sun, Feb 17, 2013 at 10:38 AM, Chris <chris at vp44.net> wrote:
> Hi all.
>
> I have a question for you guys: I have recently installed a Ubiquity Aircam and
> I would like to record a daily video. The camera streams via rtsp at 720p
> resolution with 30fps and I obviously don't want to record it that way.
> I would like to reduce the resolution by half to 640x360 and cut the framerate
> to let's say 1-2 fps.
> I'm already using ffmpeg to grab a frame every minute (it's a public weather
> cam) but it's full size and I can't just do that every second:
>
> /home/manager/ffmpeg/ffmpeg -i rtsp://aircam/live/ch00_0 -y -f image2 -ss 8
> -sameq -t 0.001 /var/www/webcam/aircam-full.jpg
>
> Is there any way to setup ffmpeg to capture the stream with the settings I
> require?
>
> Thanks
> -Chris
>

Use the scale filter to resize - half the iw (input width) and scale
height appropriately - and the select filter to pull out a single
frame each second from the source and set the frame rate on the
output:

ffmpeg -i rtsp://... -vf "select='not(mod(n,25)),scale=iw/2:-1'" -r 1
-c:v libx264 -an out.ts

This will produce 1 hour of 1 fps footage for every hour of footage
shot, ie it is snapshots in real time. If you were instead hoping for
a sped up timeshift effect, then something like this should work:

ffmpeg -i rtsp://... -vf
"select='not(mod(n,25)),scale=iw/2:-1,setpts=0.04*PTS" -c:v libx264
-an out.ts

This works by dropping 24 out of the 25 frames each second, and
speeding up the result 25 times. You may need to different
calculations if your source is not PAL, or if that is too fast a
speedup.

For added bonus, you could use segmenter to also chop up the video
automatically into appropriate day/hour sized chunks!

Cheers

Tom

PS: The select filter is probably not strictly necessary in either
case, but will avoid frame drops being reported, since you are
explicitly dropping them!


More information about the ffmpeg-user mailing list