Sorry for my english (i'm rus)
I save MJPEG stream from IP-camera with wget
wget -O 2010-01-12_01.mjpeg http://172.16.1.220:8070/video.mjpg
I need limit saving by hour (every hour is a another file - 2010-01-12_[XX])
What is the bast way to do it ? 1) starting and killing by cron ? 2) for .. do in script, how ? ...
thanks fo开发者_运维技巧r answers
You can use the timeout utility:
timeout 3600 wget -O `date +%Y-%m-%d_%T`.mjpeg http://172.16.1.220:8070/video.mjpg
I'd use something like this:
( wget ... & sleep 3600; kill %1 )
sweet as bash kludge
wget whatever &
sleep 60 && kill $$ 2>/dev/null
Just an alternate method to wget
while [ "true" ]; do
ffmpeg -t 3600 -i http://172.16.1.220:8070/video.mjpg -vcodec mjpeg /path/to/storage/$(date +%Y-%m-%d_%H).mjpg
done
try curl
with the -m
or --max-time
option
精彩评论