[FFmpeg-user] How to output real frame number instead of sequentially added image numbers
tracey jaquith
tracey at archive.org
Wed Jan 30 03:17:50 CET 2013
On Jan 29, 2013, at 4:20 PM, Stefano Sabatini <stefasab at gmail.com> wrote:
> On date Wednesday 2013-01-23 13:22:57 +0100, Bernard wrote:
>> 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
>
> This is ticket #1452:
> https://ffmpeg.org/trac/ffmpeg/ticket/1452
>
> Also see the recent thread:
> http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/158092
>
> [...]
Thanks, Stefano!
Does the ticket mean I'm working on it or someone else is? 8-)
--Tracey (archive.org)
More information about the ffmpeg-user
mailing list