Open chenxinfeng4 opened 3 months ago
Hi @chenxinfeng4, that's a cool project! Would you have some numbers on speedup vs opencv for sequential read and accurate random seek?
The ffmpegcv support sequential read, but not random seek. As for the random seek, I would prefer use mmcv.VideoReader
, a wrapper function by open-mmlab teams. Plus, the random seek
is not reliable especially the hevc file.
As for the speed test, it depent on the usage of ffmpegcv. At the worst case, the ffmpegcv is a bitter slow than opencv. But ffmpegcv supports GPU coding, resize&crop in GPU, RBG24
pixel format directly, CHW torch array
directly. In any one of those cases, it would be most likely >2x faster. How much time faster depends on how you recruit the preprocessing stages.
Not only faster, but also less code and less CPU usage. Version CPU only.
Version GPU enforced (>2x faster).
The ffmpegcv
also supports high level multiprocessing to speedup video read/writing.
Here is a PR that I use ffmpegcv in open-mmlab/mmdetection. https://github.com/open-mmlab/mmdetection/pull/7832
The deeplabcut/dlclivegui is cool to use queue and share-memory to stage recent live camera frame!!!! Fantastic. And that's what ffmpegcv has done the same way. The ffmpegcv has some out-of-box decorator functions.
As for USB Camera or RTSP Camera (IP camera), the ffmpegcv can buffer recent frames (default) or only read the last frame in strict realtime applications (ReadLiveLast
).
I'm Xinfeng Chen, from Ying Li lab, Beijing China. Neural science group.
I created the
ffmpegcv
, which is an alternative to OPENCV for video reading and writing. I used ffmpegcv to speed up my 3D skeleton reconstruion from multiview videos. I noticed that you also useffmpeg
as the backbone to read and write video. You may be interested in my project.https://github.com/chenxinfeng4/ffmpegcv
Basic usage.
Plus, it supports NVIDIA GPU to decode and encode video, and supports CUDA to resize the video while live reading. Fast and CPU friendly.