ffmpeg-python icon indicating copy to clipboard operation
ffmpeg-python copied to clipboard

HWACCEL + tensorflow without leaving GpuRam

Open BlueMagma2 opened this issue 1 year ago • 1 comments

I would like to decode a video using complex_filter and nvdec hardware acceleration. To have it be as fast as possible I would like the decoded frame to be passed to tensorflow directly without leaving the gpu ram so that we don't spend time memcpy-ing the frame from gpu memory to cpu memory and back.

Is it possible using ffmpeg-python ?

BlueMagma2 avatar Apr 17 '24 12:04 BlueMagma2

In the "Experimental" section of TensorFlow, there's the barely documented/commented tfio.experimental.ffmpeg.decode_video() -> ffmpeg_ops.io_ffmpeg_decode_video() -> libtensorflow_io_ffmpeg_4.2.so -> ...

PyTorch seems more promising. TorchAudio (a library for audio and signal processing with PyTorch) talks here about video:

Using NVIDIA’s GPU decoder and encoder, it is also possible to pass around CUDA Tensor directly, that is decode video into CUDA tensor or encode video from CUDA tensor, without moving data from/to CPU.

The bottom of that page leads to tutorials on video decoding and encoding.

Keep us posted how that goes.

page200 avatar Jul 08 '24 23:07 page200