Specify timestamp in ffmpeg video segment command
23,350
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
Author by
Soumya
Updated on July 09, 2022Comments
-
Soumya almost 2 years
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 ? -
Soumya over 9 yearsGiving an error : Invalid segment filename template 'out%Y-%m-%d_%H-%M-%S.mp4'. Ffmpeg version: N-68694-g7c210c4 Copyright (c) 2000-2014 the FFmpeg developers built on Dec 25 2014 22:02:33 with gcc 4.9.2 (GCC) Machine: Windows 7. Feeling the 'strftime' is not working. Do I need to install anything ?
-
basin about 9 yearswith
strftime
segment names are based on current machine time, not stream time -
rogerdpack about 9 years@basin maybe file an ffmpeg feature request for it on its trac? Tell them to consider adding pts and frame_num variables (eval style) @ Sourmya maybe use a more up to date ffmpeg?
-
Tenaciousd93 over 7 years@Soumya, I have the same issue on my macbook with ffmpeg 2.6: seems that for timestamp need and extra component to ffmpeg. I figure it out by using a static build of ffmpeg (I used linux version), and it works.
-
AJ H almost 7 years@Tenaciousd93 How could you run the linux version of ffmpeg static build on a macbook? I just ran into the same issue, could you explain your solution in details?
-
AJ H almost 7 years@Tenaciousd93 I found that I just forgot to add "-strftime 1" into parameters. After adding that, it works now!