I have a device that recording the video using the webcam with ffmpeg. It is working great, when the recording is started I am getting the USR1 signal. And after stoping the recording we receive the USR2 signal.

But I want to stop the recording after 1 hour recording time.

I don't know but I think I have to pass the USR2 signal to the device after 1 hour.

So how can I do this...!!!

Thanks in advance.


Use the -t option. From man ffmpeg:

-t duration (input/output)

When used as an input option (before -i), limit the duration of data read from the input file.

When used as an output option (before an output filename), stop writing the output after its duration reaches duration.

duration must be a time duration specification, see the Time duration section in the ffmpeg-utils(1) manual.

-to and -t are mutually exclusive and -t has priority.


ffmpeg -f v4l2 -i /dev/video0 -t 01:00:00 output

If you're running ffmpeg or avconv from the command line, you could use the timeout command:

timeout 3600 avconv -f video4linux2 -r 25 -i /dev/video0  -vcodec mpeg4 -y out.mp4

If you know in advance the timeout you should definetely use the methods given, however, if you really want to send a signal to the process you can use the kill command (despite being used 90% for TERM or KILL, can send ANY signal - kill -s USR2 pid)

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.