0

I've got some MKV videos encoded with FFV1. For each of the frames, I want to run some complex and time-intensive python or matlab code, so I'm using multithreading, where each thread works on an individual image.

I've tried extracting a single frame from the video using -ss, but it's terribly inefficient.

The most efficient way is to decompress everything into images in one go, but then I'm writing to disk, and then I'll be reading from disk, therefore it's not ideal either.

I've tried using a ram disk to export images to, and reading them from python/matlab, but it's not great performance-wise either. Also, I have to split the export into several batches, as the video file is 20GB and all of the exported images will not fit into memory

Is there a way to rapidly extract individual frames from ffmpeg directly into RAM (or ram disk), so that they can be used by another program? For example using something like a lookup-table.

For reference, each video is about 20GB, comprised of 50000 frames, and they are all keyframes (it's for archival purposes)

Babis
  • 147
  • 5
  • What command did you try for extraction? – Gyan Dec 17 '19 at 15:08
  • fffmpeg -y -ss seektime -i "some_input" -vframes 1 "some_output" – Babis Dec 17 '19 at 16:01
  • What times are you getting for extracting an image? – Gyan Dec 17 '19 at 16:42
  • It's less than a second, but I think the overhead of calling ffmpeg (e.g. from python or even command line) is quite big compared to the time required to actually decode the single frame. Multiply the overhead by 50,000 times and I got a problem. – Babis Dec 17 '19 at 17:07
  • Doing it in batches will be the most performant. – Gyan Dec 17 '19 at 17:18
  • I did batches already, but matlab's parfor has a long setup time (possibly because the amount of data to send to each process is high), so for every batch I have the additional parfor cost. Maybe I should explore starting a thread that runs ffmpeg and decompresses, and matlabs parfor consumes frames that have been decoded, if I can get it to do that. – Babis Dec 17 '19 at 17:34

0 Answers0