Stop the recording after some period of time
Solution 1
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.
Example that records for one hour:
ffmpeg -f v4l2 -i /dev/video0 -t 01:00:00 output
Or in seconds:
ffmpeg -f v4l2 -i /dev/video0 -t 3600 output
Solution 2
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
Related videos on Youtube
Prakash V Holkar
Updated on September 18, 2022Comments
-
Prakash V Holkar over 1 year
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.
-
Hengjie over 6 years
-t
uses the Time Duration syntax available here: ffmpeg.org/ffmpeg-utils.html#Time-duration