Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specify timestamp in ffmpeg video segment command

Tags:

ffmpeg

I have a continuous RTSP stream coming from a camera over the network. I want to dump the stream but in video files of length 1 min each.

I an using the following command

ffmpeg -i "rtsp://user:[email protected]"  -f mp4 -r 12 -s 640x480 -ar 44100 \
-ac 1 -segment_time 60 -segment_format mp4 "out%03d.mp4"

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

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

If it is mandatory to provide a serial number for the segment, is it possible to get something like 09-30-001.mp4, 09-31-002.mp4 ?

like image 243
Soumya Avatar asked Feb 19 '15 09:02

Soumya


People also ask

How do I set video duration in FFmpeg?

Use the -t option to specify a time limit: `-t duration' Restrict the transcoded/captured video sequence to the duration specified in seconds. hh:mm:ss[. xxx] syntax is also supported.

What is FFmpeg command?

FFmpeg MOV to MP4 (Convert Video/Audio to Another Format) FFmpeg is extremely useful to convert your video file to another format. For example, to convert MOV to MP4 with FFmpeg, run the command below. ffmpeg -i input.mov output.mp4. Similarly, you can transcode audio files with FFmpeg by specifying the output format.


1 Answers

Appears you need to add the "-f segment" parameter. Here's an example with strftime as well:

 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"

For me this created files with names like this:

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

like image 162
rogerdpack Avatar answered Oct 10 '22 00:10

rogerdpack