Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I managed to encode a video using ffmpeg and to overlay each frame with the frame number using the drawtext filter.

My problem was that using the "text=%{n}" option resulted in the first frame being 0, which is not what I need.

Then I used the code "text=%{expr\:n+1}" and the first frame is now 1 as it should be but it print out 1.000000

Does anyone know a way to remove what comes after the decimal point?

share|improve this question

Does anyone know a way to remove what comes after the decimal point?

Probably not. From FFmpeg ticket #1949: Display frame number on each frame:

Try the new expansion function %{expr\:n+1} (note the double escaping), it prints a double value, no formatting control is provided.

You may add a feature request to the FFmpeg bug tracker and it may get implemented depending on developer interest and time, but of course a patch addressing this issue would be more than welcome.

share|improve this answer
Thanks for the info. I'll submit a request and hope for the best. – Kobi Versano Mar 17 '13 at 12:59

First, separate the video into individual frames, then use Multiple Image Resizer.NET to place the frame numbers into each and every frame. Then, reunite the images into a second video sequence.

share|improve this answer

Had the same problem, took me some time to find out the answer. In the docs there is

expr_int_format, eif Evaluate the expression’s value and output as formatted integer.

The first argument is the expression to be evaluated, just as for the expr function. The second argument specifies the output format. Allowed values are ‘x’, ‘X’, ‘d’ and ‘u’. They are treated exactly as in the printf function. The third parameter is optional and sets the number of positions taken by the output. It can be used to add padding with zeros from the left.

I have e.g. :text=' == %{eif\:33\:x} ==' working fine here. Note that how much escaping (how many backslashes) you need has to do with your environment

So, for your case this does the trick:

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .