Specify a timestamp in the ffmpeg video segment command

I have a continuous RTSP stream coming from the camera over the network. I want to reset the stream, but in the video files 1 minute long.

I use the following command

ffmpeg -i "rtsp://user: pass@example.com " -f mp4 -r 12 -s 640x480 -ar 44100 \ -ac 1 -segment_time 60 -segment_format mp4 "out%03d.mp4" 

The name of the created files has the form out001.mp4 , out002.mp4 , etc.

I want to include a timestamp (hour and minute) in the name of the file segments, for example. 09-30.mp4 , 09-31.mp4 etc.

If a segment must have a serial number, is it possible to get something like 09-30-001.mp4 , 09-31-002 .mp4?

+5
source share
1 answer

It appears that you need to add the "-f segment" parameter. Here is an example with strftime:

  ffmpeg -i your_input -f segment -strftime 1 -segment_time 60 -segment_format mp4 out%Y-%m-%d_%H-%M-%S.mp4 

segment_time 60 means 60 seconds, strftime 1 means "enable strftime names"

Files are created for me with the following names:

out2015-03-05_10-27-43.mp4

+6
source

Source: https://habr.com/ru/post/1213683/


All Articles