3

Is it possible to set the -ss and -t flags in FFMPEG in frames?

I am building a simple video trimmer in PHP with FFMPEG and have been using PHP-FFMPEG to extract screen grabs etc and it works entirely in frames. Also my script requires that I add and subtract variable amounts of time to the start and end of the vid which is so much easier to do in FPS. PHP-FFMPEG tells me the fps of the vid, so I can accurately pinpoint frames as required.

Alternatively does anyone know of a nice little script for converting frames to HH:MM:SS.xx format at all? I can just use that instead. My Google attempts have been fruitless so far, and my attempt at it has got me rather stressed.

Emii Khaos
  • 9,983
  • 3
  • 34
  • 57
user825494
  • 35
  • 1
  • 3
  • OK, so the converting to HH:MM:SS.xx bit is simple enough, i've just been having a brain freeze - floor(frames / FPS) gives me the seconds, and I can work out the modulus of that too to give me the odd frames left over - I've been staring at this code for too long I think. – user825494 Jun 29 '12 at 20:57

2 Answers2

2

You don't need to convert to HH:MM:SS.xx format.

The -t and -ss flags for FFmpeg accept the number of seconds (including decimal) as well as HH:MM:SS.xx format. From the docs:

-ss position (input/output)
When used as an input option (before -i), seeks in this input file to position. When used as an output option (before an output filename), decodes but discards input until the timestamps reach position. This is slower, but more accurate.

position may be either in seconds or in hh:mm:ss[.xxx] form.

So just do frames/frames per second and you've got your input.

blahdiblah
  • 33,069
  • 21
  • 98
  • 152
1

I don't know about -ss but you can use -vframes instead of -t to specify exact number of video frames.

Jason C
  • 38,729
  • 14
  • 126
  • 182