Skip to content

Documentation

dongrixinyu edited this page Aug 8, 2024 · 2 revisions

ffio

  • The main class of ffio is ffio.FFIO. You should initialize it by setting correct arguments.
import ffio

target_url = "rtmp://ip:port/xxxx"
decoder = ffio.FFIO(target_url, mode="decoder", hw_enabled=False, pix_fmt_hw_enabled=False,
                    hw_device="", shm_name=None, shm_size=0, shm_offset=0, codec_params=None)
  • target_url: this is the address of your online video stream or local file. all formats supported by ffmpeg are also can be processed for this argument.
    • rtmp://ip:port/xxxx
    • srt://ip:port/yyyy
    • rtsp://ip:port/xxxx
    • /path/to/your/xxxx.mp4
    • /path/to/your/yyyy.flv
  • mode: you can set the FFIO to be encoder or decoder by mode="encoder", mode="ENCODE", mode="Decoder" or mode="decode", the default is "decoder"
  • hw_enabled: ffmpeg supports a range of hardware acceleration of decoder and encoder for H264 and H265. If you have an available hardware such as cuda, vaapi, or sth else, you can set it to True. The default is False.
  • pix_fmt_hw_enabled: besides the hardware acceleration inside ffmpeg, there is also a pixel format conversion from yuv->rgb or rgb->yuv, which can be accelerated by hardware. If you set this argument to True, ffio will do this job on nvidia cuda. But if you set hw_enabled=False, pix_fmt_hw_enabled=True, this acceleration will not work.
  • hw_device: for nvidia cuda, if you have several GPUs on your machine, you can choose the GPU id by setting hw_device="cuda:4", the default is "cuda:0", and this argument will not work unless nvidia cuda.
Clone this wiki locally