-
Notifications
You must be signed in to change notification settings - Fork 8
Documentation
dongrixinyu edited this page Aug 8, 2024
·
2 revisions
- 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 bymode="encoder"
,mode="ENCODE"
,mode="Decoder"
ormode="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 isFalse
. -
pix_fmt_hw_enabled: besides the hardware acceleration inside ffmpeg, there is also a pixel format conversion from
yuv->rgb
orrgb->yuv
, which can be accelerated by hardware. If you set this argument toTrue
, ffio will do this job onnvidia cuda
. But if you sethw_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.