ffmpeg – How to improve random access of a video frame with Python?

I’m using pims library (github.com/soft-matter/pims) to access frames from .MOV file with over 25K frames, 3840 × 2160, H.264 (High Profile), 60fps.

import pims
from time import perf_counter

video = pims.Video('video/v1.MOV')
t0 = perf_counter()
img = video[1000]
t1 = perf_counter()
print(f'{(t1-t0):.3f}s  {img.shape}')

Here are the timings on a fairly fast PC, after file open:

  • frame #100: 2.97s
  • frame #1,000: 28.39s
  • frame #10,000: 280.19s

AFAIK, this library uses ffmpeg, which can access frame #10,000 with ffmpeg -ss 00:02:46.66 -i v1.MOV -frames:v 1 f10k.png practically instantaneously. Is there a way to improve frame access with pims or some other method?

Read more here: Source link

ffmpeg – How to improve random access of a video frame with Python?

I’m using pims library (github.com/soft-matter/pims) to access frames from .MOV file with over 25K frames, 3840 × 2160, H.264 (High Profile), 60fps.

import pims
from time import perf_counter

video = pims.Video('video/v1.MOV')
t0 = perf_counter()
img = video[1000]
t1 = perf_counter()
print(f'{(t1-t0):.3f}s  {img.shape}')

Here are the timings on a fairly fast PC, after file open:

  • frame #100: 2.97s
  • frame #1,000: 28.39s
  • frame #10,000: 280.19s

AFAIK, this library uses ffmpeg, which can access frame #10,000 with ffmpeg -ss 00:02:46.66 -i v1.MOV -frames:v 1 f10k.png practically instantaneously. Is there a way to improve frame access with pims or some other method?

Read more here: Source link