1

So I have found out how to cut a video at a specific time frame by using the following command

ffmpeg -i input.wmv -ss 00:00:30.0 -c copy -t 00:00:10.0 output.wmv
ffmpeg -i input.wmv -ss 30 -c copy -t 10 output.wmv

So this works but it works on a video file output.wmv, How could I do this in real time? Basically I want a camera to be running and recording 24/7 and when I click a button it will save the last 30 seconds. So what that means is anything older then 30 seconds I no longer need. So what I want to do is essentially cut off any frames that are older then 30 seconds, from an input stream (webcam) so that I do not fill up the HDD in one day.

  • I don't see an easy way to do this, but you could record to a different file every few minutes and delete older files? Truncating a file from the start is probably difficult? – barrycarter Nov 19 '14 at 21:16
  • 2 possible issues, 1) is it possible that frames will be lost while the recording stream starts / stops? 2) Say I cut every 1 minute, if someone presses the button at 1:15, I would only have a 1 minute clip and a 15 second clip. – user391502 Nov 19 '14 at 21:18
  • 2) But if you only need 30 seconds, 1 minute and 15 seconds should be enough? 1) you could try overlapping recordings, but that may not work. – barrycarter Nov 19 '14 at 21:35
  • Sorry if post was confusing, what I mean is, the camera will be running 24/7. Then for demonstration sake you cute every 1 minute, then say at 8:00:15 you click the button, you would only have 15 seconds of film (in the foremost clip) or 1 minute in the previous clip – user391502 Nov 19 '14 at 21:37
  • Oh, so you just need the time length of the video file and then cut the last 'n' seconds as needed? – barrycarter Nov 20 '14 at 1:55
1

http://sonnati.wordpress.com/2012/07/02/ffmpeg-the-swiss-army-knife-of-internet-streaming-part-v/

"5. Record a stream endlessly rotating target file"

That handles your circular buffer.

You might have to do a little experimenting to see what works for you to get the previous 30 seconds. There are a number of ways to do that so it'll be up to the implementer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.