I'm using ffmpeg to segment a video stream and I would like ffmpeg to name the segment files with a created date/timestamp.

Is this possible?

Let's say I have segments of 30sec video each: 0000.flv, 0001.flv, 0002.flv, etc

When I do ffprobe of each video segment I "correctly" get 30 seconds, which is nice.

However, each file has a "last modified time"/"created time" that I can read, and when I subtract 0001.flv (modified time) - 0000.flv (modified time) I get a result of 29 seconds.

The video duration is 30 seconds, but the time between either date created or last modified is 29 seconds!

If the segment time is 600 seconds then the time between either date created or last modified is 591 seconds! So it's missing 9 seconds according to the file system but the video is indeed 600 seconds.

This is a huge problem -- can someone please help?

This is my commandline:

    ffmpeg = spawn('ffmpeg', [
        '-loglevel', 'quiet',
        '-r', '20',
        '-i', 'pipe:0',
        '-vcodec', 'copy',
        '-f', 'segment',
        '-segment_time', '30',
        dataDir + '/' + '%04d.flv'

Also, when ffmpeg writes the segment the files have no "birth time" and the "created" & "modified" time is always the same.. so i really can never know when the file was actually created unless i use a "debugfs" (in sudo mode) to dig deeper....

all i want is ffmpeg to put a timestamp in the filename when it creates the segment, why is this not seen as useful? i think its very useful when capturing time from a live source...

and i am NOT encoding-- stop thinking that this is encoding please... i know that transcoding take longer and cause delays in time...

From my observation, doing a codec copy, the "last modified" time between segments is only 591 seconds when i have my video duration at 600 seconds... so i am actually losing time...

But i know this is not a reliable timestamp-- so i am asking for a way to get a more reliable timestamp from ffmpeg other than having to use the "stat" command which is not giving me reliable timestamps...

And yes-- my camera is producing at 20 fps :)

  • 2
    Why should the file creation time be exactly the same as the duration? And why is this a requirement? Normally, encoding time would be longer than duration. Also, please provide your input command and uncut console output. – Rajib Nov 18 '14 at 14:01
  • I am in agreement, why do you expect encoding time to match duration of video? – dstob Nov 18 '14 at 21:49
  • Think of it this way, each segment "represents" a place in time. If i look at a file segment, how can i place it in a timeline? The segment need to provide me a reference point in time. The segment is 600 seconds long, how else can you map each segment to a period in time? – g00dnatur3 Nov 18 '14 at 22:59
  • I am segmenting a live camera stream to hard disk for playback later-- think of a video surveillance system-- you need to play back what happened x minutes ago.. etc.. each segment must correctly map into a place in time.. now i am ok with margin of error of lets say 1-2 seconds, but when my segment is 600 seconds long i get an error (by looking at file create/modify timestamps) of 9 seconds-- this is way too much missing time.. i know the video is capturing the time correctly cause the duration is correct but i am not able to map it into a timeline cause i do not have correct timestamps. – g00dnatur3 Nov 18 '14 at 23:08
  • Also, i am not encoding here-- just a codec copy.. – g00dnatur3 Nov 18 '14 at 23:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.