# Cut and save stream from H.264



## mutte (Apr 4, 2012)

Hi,

I have a*n* IP-based videocamera with RTSP-stream H.264 30fps 1080p stream, Axis P1346. The quality of video is great and I want to use it in a project. I want to use Mencoder/FFMPEG or other free software to create 10 second clips from stream. I want an accurate video with a resolution of at least 500ms, and the camera has a key-fram every 500ms. I want to save the stream on disk and name the file after date and time. No re-encoding, just cutting (on a*n* ATOM-based platform).

The Mencoder/FFMPEG should use a loop because I want to use a prebuffer of 2 seconds. When a video is created I want to use 2 + 8 seconds. Two seconds before the event and eight seconds after the event. I know this function is implemented in the Axis P1346 but I want to be able to use this function e.g. 10 times during one minute (cut video should share from other cut videos). The loop is not a requirement because the disk is a 24/7-disk and MTBF is great for this application. Not a live requirement, five minutes after video and cutting is active is not a problem.

It is possible with these programs?

I have tested Mencoder and it works pretty great but there are some limits:
- No posibility to add time into frames
- Hard to merge two videos to one with no lag if I want to use a video based on two videos. Between these videos Mencoder is creating a lag of 1-3 seconds because Mencoder is restarting.

Does anybody have a solution for this?

Example with a 10 second clip created with mencoder:

[cmd=]mencoder -ss 00:00:00 -endpos 00:00:10 -oac pcm -ovc copy rtsp://192.168.1.5/axis-media/media.amp \
-info name="HD Video" -info comment="Video Created of me" -o /home/user/video.avi[/cmd]


----------

