I have this command which I use to find certain frames using an image: ffmpeg -hide_banner -i "video.avi" -loop 1 -i "image.png" -an -filter_complex "blend=difference:shortest=1,blackframe=90:32" -f null -

I then get the following output (alongside the usual data):

[Parsed_blackframe_1 @ 0000023e0bc3ff00] frame:16716 pblack:90 pts:174308159 t:697.232636 type:I last_keyframe:16716
[Parsed_blackframe_1 @ 0000023e0bc3ff00] frame:16717 pblack:90 pts:174318586 t:697.274344 type:B last_keyframe:16716
[Parsed_blackframe_1 @ 0000023e0bc3ff00] frame:16718 pblack:91 pts:174329013 t:697.316052 type:P last_keyframe:16716
[Parsed_blackframe_1 @ 0000023e0bc3ff00] frame:16719 pblack:91 pts:174339440 t:697.357760 type:B last_keyframe:16716
[Parsed_blackframe_1 @ 0000023e0bc3ff00] frame:16720 pblack:91 pts:174349867 t:697.399468 type:P last_keyframe:16716

What do I do to only get the numbers after frame:? Basically an output like this: (16716, 16717, 16718, 16719, 16720) or similar. Can I maybe make ffmpeg output only that? Can I use python for this somehow?

  • Offhand, I would use something like grep for that. I'm sure you could run a regular expression in just about any package, including Python, though it might take a little longer to run. I unfortunately don't have the time to figure one out right now, but copy-pasting to somewhere like regextester.com and tweaking your expression could help you narrow it down. Jun 7 at 13:51


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.