[FFmpeg-user] How to output real frame number instead of sequentially added image numbers

Bernard bernard.vrh at gmail.com
Wed Jan 23 13:22:57 CET 2013


Hi Tracey,

in the mean time I've found one link with old code, seems not working in 
newer FFMPEG release as still a lot work should be done to adopt code to 
newest release.

the code was provide from Yuval Adam

http://ffmpeg.org/pipermail/ffmpeg-devel/2011-December/117830.html

The idea behind Yuval work is to replace %d parameter with  %t 
parameter, but this parameter is already now in use %T  or %t for log 
file creation and will probably be in collision with our intention for 
labeling Keyframes.


My idea here is to introduce descriptive names instead.

Example:

%frames   will output    12345.jpg

complete command line will be:

ffmpeg -i "C:\myfilename.avi"  -vf select="eq(pict_type\,I)" -vsync 2 -s 200x112  -f image2  "D:\myoutput_file\%frames.jpeg"


when the FFMPEG is in debug mode  (  - loglevel debug  ) all this 
information is already there:

ffmpeg   - loglevel debug  -i "C:\myfilename.avi"  -vf select="eq(pict_type\,I)" -vsync 2
-s 200x112  -f image2  "D:\myoutput_frames\%d.jpeg"

above command line produces  file named   "ffmpeg-20130123-005308.log"  (generated today) and a part of file is:

frame=    3 fps=0.0 q=0.0 size=N/A time=00:00:00.52 bitrate=N/A n:34 
pts:122400 t:1.360000 pos:180224 key:0 interlace_type:P pict_type:P 
scene:nan -> select:0.000000
frame=  319 fps=1.5 q=0.0 size=N/A time=00:02:31.80 bitrate=N/A n:3811 
pts:13719600 t:152.440000 pos:17766412 key:0 interlace_type:P 
pict_type:P scene:nan -> select:0.000000

You can find that the "frame"  is the name of  the Generated outgoing 
images  and the corresponding frame number is n: (keyframe)

D:\myoutput_frames\3.jpg and D:\myoutput_frames\319.jpg in this case.  and there is also n: parameter which is in fact the correct frame number from input file

So:
frame=  3 = n:34
frame=  319  = n:3811

interpreting n: you can produce time code image name or in your case the 
time offset from start of the input video clip.

I think this is also the solution of your problem..

What we must do is to selectively link what is generated from  - 
loglevel debug parameter and then with this information (n:) renaming 
outgoing (generated)  images.

Regards,

Bernard

On 22.1.2013 23:55, tracey jaquith wrote:
> Hi Bernard,
>
> This kind of was a maddeningly needed/wanted feature for me, too 8-)
> and actually one step further -- I wanted the actual seconds as close as
> possible from the start for each frame extracted.  (If this works for you, you
> could tailor it to taste for either frame# (easier) or seconds-from-start like
> it will do by default).  I'm nearly certain there is no option to do what you suggest
> but OTOH I love to be wrong so I don't need to code 8-)
>
> This isn't really ready for primetime (I'm hacking around by stashing some new globals to
> get information in the detection/identify part of the code) but it seems
> to work pretty nicely.  Very recently, I was using avidemux to make an .idx
> (index) file for MPEG1/MPEG2/MPEG-TS and then parsing it to find
> the timestamp of GOP for a given frame number to go from
>     "frame number" => "seconds from start"
> (but now with the updated/current patch, I get very close to the number of seconds
>   directly with the patched ffmpeg).
>
> http://archive.org/~tracey/downloads/patches/ffmpeg-thumbnails.patch
>
>
> I would second an option (and would be happy to work on a more robust unhacky
> solution/patch for consideration?) to output the #seconds or frame number
> of each output frame
>
> (My build and patch applying scripts, overall, is here, given the kinds of things
>   we do at my work (h.264 and ogv theora creation, vpx/WebM possible)):
>
> http://archive.org/~tracey/downloads/ffmpeg-README.txt
>
> hope that helps!
> -Tracey
>
>
> On Jan 22, 2013, at 12:56 AM, bernard vrh <bernard.vrh at gmail.com> wrote:
>
>> How to output real frame number instead of sequentially added image numbers
>>
>> Hello,
>>
>> I trying to generate scene change keyframes from input video file.
>>
>> Using   %d.jpeg   output a series of jpeg frames as images named in
>> sequential order.. and such labeled images (keyframes) do not
>> representing real time code or reflecting time position of keyframe
>> images in input video clip.
>>
>> the only parameter which works is %d
>>
>> My example:
>>
>> ffmpeg  -i "C:\myfilename.avi"  -vf select="eq(pict_type\,I)" -vsync 2
>> -s 200x112  -f image2  "D:\myoutput_frames\%d.jpeg"
>>
>> Please suggest which parameter should be used instead of  %d  to
>> output video time code stamp  or video frame number,  zero or one
>> based relative to input video clip.
>>
>>
>> Kind regards,
>>
>> Bernard
>> _______________________________________________
>> ffmpeg-user mailing list
>> ffmpeg-user at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user



More information about the ffmpeg-user mailing list