FFmpeg - How to encode raw screen buffers (frame arrays) into a bitstream?

406 views Asked by At

I have thousands of frame arrays (NumPy) with shape (3, 225, 400), which were obtained from game screens.

Each one of those frame buffers has a label (screen class and timestamp). I'd like to create a bitstream from those arrays, to be used for analysis with an RNN or similar ML technique.

Can I use FFmpeg to create a bitstream (e.g. bitrate on the y-axis, timestamp on the x-axis)?

I appreciate any help, thanks!

1

There are 1 answers

0
bbasaran On BEST ANSWER

I solved my problem with a handy tool named plotbitrate which was developed on FFmpeg. It is easy to obtain a CSV/XML file of bitstream data from a video by using plotbitrate.

Once having saved frame buffer arrays as PNG images, I created a video from those images by using FFmpeg. The bash commands below generate CSV and XML bitstream data based on the input video, respectively.

plotbitrate -f csv_raw -o frames.csv input.mp4
plotbitrate -f xml_raw -o frames.xml input.mp4