{"id":13905610,"url":"https://github.com/chenxinfeng4/ffmpegcv","last_synced_at":"2025-10-04T05:17:00.166Z","repository":{"id":49759797,"uuid":"482195801","full_name":"chenxinfeng4/ffmpegcv","owner":"chenxinfeng4","description":"The ffmpegcv is a ffmpeg backbone for open-cv like Video Reader and Writer","archived":false,"fork":false,"pushed_at":"2025-09-26T08:35:12.000Z","size":198,"stargazers_count":220,"open_issues_count":17,"forks_count":32,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-09-27T23:02:32.737Z","etag":null,"topics":["ffmpeg","opencv-python","video-decoding","video-encoding"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chenxinfeng4.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-04-16T08:14:02.000Z","updated_at":"2025-09-26T08:35:15.000Z","dependencies_parsed_at":"2022-08-30T14:01:31.390Z","dependency_job_id":"82fd4c4b-4075-44f0-9d31-9081b44db11e","html_url":"https://github.com/chenxinfeng4/ffmpegcv","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/chenxinfeng4/ffmpegcv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenxinfeng4%2Fffmpegcv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenxinfeng4%2Fffmpegcv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenxinfeng4%2Fffmpegcv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenxinfeng4%2Fffmpegcv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chenxinfeng4","download_url":"https://codeload.github.com/chenxinfeng4/ffmpegcv/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenxinfeng4%2Fffmpegcv/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277318709,"owners_count":25798184,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-28T02:00:08.834Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ffmpeg","opencv-python","video-decoding","video-encoding"],"created_at":"2024-08-06T23:01:19.751Z","updated_at":"2025-10-04T05:17:00.160Z","avatar_url":"https://github.com/chenxinfeng4.png","language":"Python","funding_links":[],"categories":["HarmonyOS"],"sub_categories":["Windows Manager"],"readme":"# FFMPEGCV is an alternative to OPENCV for video reading\u0026writing.\n![Python versions](https://img.shields.io/badge/Python-3.6%2B-blue.svg)\n[![PyPI version](https://img.shields.io/pypi/v/ffmpegcv.svg?logo=pypi\u0026logoColor=FFE873)](https://pypi.org/project/ffmpegcv/)\n[![PyPI downloads](https://static.pepy.tech/badge/ffmpegcv/month)](https://pepy.tech/project/ffmpegcv)\n![Code size](https://shields.io/github/languages/code-size/chenxinfeng4/ffmpegcv\n)\n![Last Commit](https://shields.io/github/last-commit/chenxinfeng4/ffmpegcv)\n\nEnglish Version | [中文版本](./README_CN.md)\n\nHere is the Python version of ffmpegcv. For the C++ version, please visit [FFMPEGCV-CPP](https://github.com/chenxinfeng4/ffmpegcv-cpp)\n\nThe ffmpegcv provide Video Reader and Video Witer with ffmpeg backbone, which are faster and powerful than cv2. Integrating ffmpegcv into your deeplearning pipeline is very smooth.\n\n- The ffmpegcv is api **compatible** to open-cv. \n- The ffmpegcv can use **GPU accelerate** encoding and decoding*.\n- The ffmpegcv supports much more video **codecs** v.s. open-cv.\n- The ffmpegcv supports **RGB** \u0026 BGR \u0026 GRAY format as you like.\n- The ffmpegcv supports fp32 CHW \u0026 HWC format shortcut to CUDA memory.\n- The ffmpegcv supports **Stream reading** (IP Camera) in low latency.\n- The ffmpegcv supports ROI operations.You can **crop**, **resize** and **pad** the ROI.\n\nIn all, ffmpegcv is just similar to opencv api. But it has more codecs and does't require opencv installed at all. It's great for deeplearning pipeline.\n\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://i.imghippo.com/files/cg9641723107581.jpg\"  width=\"95%\"\u003e\n\u003c/p\u003e\n\n## Functions:\n- `VideoWriter`: Write a video file.\n- `VideoCapture`: Read a video file.\n- `VideoCaptureNV`: Read a video file by NVIDIA GPU.\n- `VideoCaptureQSV`: Read a video file by Intel QuickSync Video.\n- `VideoCaptureCAM`: Read a camera.\n- `VideoCaptureStream`: Read a RTP/RTSP/RTMP/HTTP stream.\n- `VideoCaptureStreamRT`: Read a RTSP stream (IP Camera) in real time low latency as possible.\n- `noblock`: Read/Write a video file in background using mulitprocssing.\n- `toCUDA`: Translate a video/stream as CHW/HWC-float32 format into CUDA device, \u003e2x faster.\n\n## Install\nYou need to download ffmpeg before you can use ffmpegcv.\n```\n #1A. LINUX: sudo apt install ffmpeg\n #1B. MAC (No NVIDIA GPU): brew install ffmpeg\n #1C. WINDOWS: download ffmpeg and add to the path\n #1D. CONDA: conda install ffmpeg=6.0.0     #don't use the default 4.x.x version\n \n #2A. python\n pip install ffmpegcv                                      #stable verison\n pip install git+https://github.com/chenxinfeng4/ffmpegcv  #latest verison\n\n #2B. recommand only when you want advanced functions. See the toCUDA section\n pip install ffmpegcv[cuda]\n```\n\n## When should choose `ffmpegcv` other than `opencv`:\n- The `opencv` is hard to install. The ffmpegcv only requires `numpy` and `FFmpeg`, works across Mac/Windows/Linux platforms.\n- The `opencv` packages too much image processing toolbox. You just want a simple video/camero IO with GPU accessible.\n- The `opencv` didn't support profiling `h264`/`h265` and other video writers.\n- You want to **crop**, **resize** and **pad** the video/camero ROI.\n- You are interested in deeplearning pipeline.\n## Basic example\nRead a video by CPU, and rewrite it by GPU.\n```python\nvidin = ffmpegcv.VideoCapture(vfile_in)\nvidout = ffmpegcv.VideoWriterNV(vfile_out, 'h264', vidin.fps)  #NVIDIA-GPU\n\nwith vidin, vidout:\n    for frame in vidin:\n        cv2.imshow('image', frame)\n        vidout.write(frame)\n```\n\nRead the camera.\n```python\n# by device ID\ncap = ffmpegcv.VideoCaptureCAM(0)\n# by device name\ncap = ffmpegcv.VideoCaptureCAM(\"Integrated Camera\")\n```\n\nDeeplearning pipeline.\n```python\n\"\"\"\n          ——————————  NVIDIA GPU accelerating ⤴⤴ ———————\n          |                                              |\n          V                                              V\nvideo -\u003e decode -\u003e crop -\u003e resize -\u003e RGB -\u003e CUDA:CHW float32 -\u003e model\n\"\"\"\ncap = ffmpegcv.toCUDA(\n    ffmpegcv.VideoCaptureNV(file, pix_fmt='nv12', resize=(W,H)),\n    tensor_format='chw')\n\nfor frame_CHW_cuda in cap:\n    frame_CHW_cuda = (frame_CHW_cuda - mean) / std\n    result = model(frame_CHW_cuda)\n```\n## Cross platform\n\nThe ffmpegcv is based on Python+FFmpeg, it can cross platform among `Windows, Linux, Mac, X86, Arm`systems.\n\n## GPU Acceleration\n\n- Support **NVIDIA** card only, test in x86_64 only.\n- Works in **Windows**, **Linux** and **Anaconda**.\n- Works in the **Google Colab** notebook. \n- Infeasible in the **MacOS**. That ffmpeg didn't supports NVIDIA at all.\n\n\u003e \\* The ffmegcv GPU reader is a bit slower than CPU reader, but much faster when use ROI operations (crop, resize, pad).\n\n## Codecs\n\n| Codecs      | OpenCV-reader | ffmpegcv-cpu-r     | gpu-r  | OpenCV-writer | ffmpegcv-cpu-w     | gpu-w  |\n| ----------- | ------------- | ---------------- | ---- | ------------- | ---------------- | ---- |\n| h264        | √             | √                | √    | ×             | √                | √    |\n| h265 (hevc) | not sure      | √                | √    | ×             | √                | √    |\n| mjpeg       | √             | √                | ×    | √             | √                | ×    |\n| mpeg        | √             | √                | ×    | √             | √                | ×    |\n| others      | not sure      | ffmpeg -decoders | ×    | not sure      | ffmpeg -encoders | ×    |\n\n## Benchmark\n*On the way...（maybe never）*\n\n\n## Video Reader\n---\nThe ffmpegcv is just similar to opencv in api.\n```python\n# open cv\nimport cv2\ncap = cv2.VideoCapture(file)\nwhile True:\n    ret, frame = cap.read()\n    if not ret:\n        break\n    pass\n\n# ffmpegcv\nimport ffmpegcv\ncap = ffmpegcv.VideoCapture(file)\nwhile True:\n    ret, frame = cap.read()\n    if not ret:\n        break\n    pass\ncap.release()\n\n# alternative\ncap = ffmpegcv.VideoCapture(file)\nnframe = len(cap)\nfor frame in cap:\n    pass\ncap.release()\n\n# more pythonic, recommand\nwith ffmpegcv.VideoCapture(file) as cap:\n    nframe = len(cap)\n    for iframe, frame in enumerate(cap):\n        if iframe\u003e100: break\n        pass\n```\n\nUse GPU to accelerate decoding. It depends on the video codes.\nh264_nvcuvid, hevc_nvcuvid ....\n```python\ncap_cpu = ffmpegcv.VideoCapture(file)\ncap_gpu0 = ffmpegcv.VideoCaptureNV(file)         #NVIDIA GPU0\ncap_gpu1 = ffmpegcv.VideoCaptureNV(file, gpu=1)  #NVIDIA GPU1\ncap_qsv = ffmpegcv.VideoCaptureQSV(file)         #Intel QSV, experimental\n```\n\nUse `rgb24` instead of `bgr24`. The `gray` version would be more efficient.\n```python\ncap = ffmpegcv.VideoCapture(file, pix_fmt='rgb24') #rgb24, bgr24, gray\nret, frame = cap.read()\nplt.imshow(frame)\n```\n\n### ROI Operations\nYou can crop, resize and pad the video. These ROI operation is `ffmpegcv-GPU` \u003e `ffmpegcv-CPU` \u003e\u003e `opencv`.\n\n**Crop** video, which will be much faster than read the whole canvas. The top-left corner is (0, 0).\n```python\ncap = ffmpegcv.VideoCapture(file, crop_xywh=(0, 0, 640, 480))\n```\n\n**Resize** the video to the given size.\n```python\ncap = ffmpegcv.VideoCapture(file, resize=(640, 480))\n```\n\n**Resize** and keep the aspect ratio with black border **padding**.\n```python\ncap = ffmpegcv.VideoCapture(file, resize=(640, 480), resize_keepratio=True)\n```\n\n**Crop** and then **resize** the video.\n```python\ncap = ffmpegcv.VideoCapture(file, crop_xywh=(0, 0, 640, 480), resize=(512, 512))\n```\n\n### Extend Options\n**INFILE_OPTIONS**: Add extra options to ffmpeg input. \n\n```python\ncap = ffmpegcv.VideoCapture(file, infile_options='-re -stream_loop -1')\n\n# equivalent ffmpeg command\nffmpeg INFILE_OPTIONS -i FILE -f rawvideo pipe:\n```\n\n## toCUDA device\n---\nThe ffmpegcv can translate the video/stream from HWC-uint8 cpu to CHW-float32 in CUDA device. It significantly reduce your cpu load, and get \u003e2x faster than your manually convertion.\n\nPrepare your environment. The cuda environment is required. The `pycuda` package is required. The `pytorch` package is non-essential.\n\u003e nvcc --version      # check you've installed NVIDIA CUDA Compiler. Already installed if\n\u003e                     you've installed Tensorflow-gpu or Pytorch-gpu\n\u003e\n\u003e pip install ffmpegcv[cuda]  #auto install pycuda\n\n```python\n# Read a video file to CUDA device, original\ncap = ffmpegcv.VideoCaptureNV(file, pix_fmt='rgb24')\nret, frame_HWC_CPU = cap.read()\nframe_CHW_CUDA = torch.from_numpy(frame_HWC_CPU).permute(2, 0, 1).cuda().contiguous().float()    # 120fps, 1200% CPU load\n\n# speed up\ncap = toCUDA(ffmpegcv.VideoCapture(file, pix_fmt='yuv420p')) #pix_fmt: 'yuv420p' or 'nv12' only\ncap = toCUDA(ffmpegcv.VideoCaptureNV(file, pix_fmt='nv12'))  #'nv12' is better for gpu\ncap = toCUDA(vid, tensor_format='chw') #tensor format:'chw'(default) or 'hwc', fp32 precision\ncap = toCUDA(vid, gpu=1) #choose gpu\n\n# read to the cuda device\nret, frame_CHW_pycuda = cap.read()     #380fps, 200% CPU load, dtype is [pycuda array]\nret, frame_CHW_pycudamem = cap.read_cudamem()  #dtype is  [pycuda mem_alloc]\nret, frame_CHW_CUDA = cap.read_torch()  #dtype is  [pytorch tensor]\nret, _ = cap.read_torch(frame_CHW_CUDA)  #no copy, but need to specify the output memory\n\nframe_CHW_pycuda[:] = (frame_CHW_pycuda - mean) / std  #normalize\n```\n\nHow can `toCUDA` make it faster in your deeplearning pipeline than `opencv` or `ffmpeg`?\n\u003e 1. The opencv/ffmpeg uses the cpu to convert video pix_fmt from original YUV to RGB24, which is slow. The ffmpegcv use the cuda to accelerate pix_fmt convertion.\n\u003e 2. Use `yuv420p` or `nv12` can save the cpu load and reduce the memory copy from CPU to GPU.\n\u003e 3. The ffmpeg stores the image as HWC format. The ffmpegcv can use HWC \u0026 CHW format to accelerate the video reading.\n\n## Video Writer\n---\n\n```python\n# cv2\nout = cv2.VideoWriter('outpy.avi',\n                       cv2.VideoWriter_fourcc('M','J','P','G'), \n                       10, \n                       (w, h))\nout.write(frame1)\nout.write(frame2)\nout.release()\n\n# ffmpegcv, default codec is 'h264' in cpu 'h265' in gpu.\n# frameSize is decided by the size of the first frame.\n# use the 'mp4/mkv' instead of 'avi' to avoid the codec outdated.\nout = ffmpegcv.VideoWriter('outpy.mp4', None, 10)\nout.write(frame1)\nout.write(frame2)\nout.release()\n\n# more pythonic\nwith ffmpegcv.VideoWriter('outpy.mp4', None, 10) as out:\n    out.write(frame1)\n    out.write(frame2)\n```\n\n\nUse GPU to accelerate encoding. Such as h264_nvenc, hevc_nvenc.\n```python\nout_cpu = ffmpegcv.VideoWriter('outpy.mp4', None, 10)\nout_gpu0 = ffmpegcv.VideoWriterNV('outpy.mp4', 'h264', 10)        #NVIDIA GPU0\nout_gpu1 = ffmpegcv.VideoWriterNV('outpy.mp4', 'hevc', 10, gpu=1) #NVIDIA GPU1\nout_qsv  = ffmpegcv.VideoWriterQSV('outpy.mp4', 'h264', 10)        #Intel QSV, experimental\n\n```\n\nInput image is rgb24 instead of bgr24\n```python\nout = ffmpegcv.VideoWriter('outpy.mp4', None, 10, pix_fmt='rgb24')\n```\n\nResize the video\n```python\nout_resz = ffmpegcv.VideoWriter('outpy.mp4', None, 10, resize=(640, 480)) #Resize\n```\n## Video Reader and Writer\n---\n```python\nimport ffmpegcv\nvfile_in = 'A.mp4'\nvfile_out = 'A_h264.mp4'\nvidin = ffmpegcv.VideoCapture(vfile_in)\nvidout = ffmpegcv.VideoWriter(vfile_out, None, vidin.fps)\n\nwith vidin, vidout:\n    for frame in vidin:\n        vidout.write(frame)\n```\n\n## Camera Reader\n---\n**Experimental feature**. The ffmpegcv offers Camera reader. Which is consistent with VideoFiler reader. \n\n- The `VideoCaptureCAM` aims to support ROI operations. The Opencv will be general fascinating than ffmpegcv in camera read. **I recommand the opencv in most camera reading case**.\n- The ffmpegcv can use name to retrieve the camera device. Use `ffmpegcv.VideoCaptureCAM(\"Integrated Camera\")` is readable than `cv2.VideoCaptureCAM(0)`.\n- The `VideoCaptureCAM` will be laggy and dropping frames if your post-process takes long time. The VideoCaptureCAM will buffer the recent frames.\n- The `VideoCaptureCAM` is continously working on background even if you didn't read it. **Please release it in time**.\n- Works perfect in Windows, not-perfect in Linux and macOS.\n\n```python\nimport cv2\ncap = cv2.VideoCapture(0)\nwhile True:\n    ret, frame = cap.read()\n    cv2.imshow('frame', frame)\n    if cv2.waitKey(1) \u0026 0xFF == ord('q'):\n        break\ncap.release()\n\n# ffmpegcv, in Windows\u0026Linux\nimport ffmpegcv\ncap = ffmpegcv.VideoCaptureCAM(0)\nwhile True:\n    ret, frame = cap.read()\n    cv2.imshow('frame', frame)\n    if cv2.waitKey(1) \u0026 0xFF == ord('q'):\n        break\ncap.release()\n\n# ffmpegcv use by camera name, in Windows\u0026Linux\ncap = ffmpegcv.VideoCaptureCAM(\"Integrated Camera\")\n\n# ffmpegcv use camera path if multiple cameras conflict\ncap = ffmpegcv.VideoCaptureCAM('@device_pnp_\\\\\\\\?\\\\usb#vid_2304\u0026'\n    'pid_oot#media#0001#{65e8773d-8f56-11d0-a3b9-00a0c9223196}'\n    '\\\\global')\n\n# ffmpegcv use camera with ROI operations\ncap = ffmpegcv.VideoCaptureCAM(\"Integrated Camera\", crop_xywh=(0, 0, 640, 480), resize=(512, 512), resize_keepratio=True)\n\n\n```\n\n**List all camera devices**\n```python\nfrom ffmpegcv.ffmpeg_reader_camera import query_camera_devices\n\ndevices = query_camera_devices()\nprint(devices)\n```\n\u003e{0: ('Integrated Camera', '@device_pnp_\\\\\\\\?\\\\usb#vid_2304\u0026pid_oot#media#0001#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\\\\global'),  \n1: ('OBS Virtual Camera', '@device_sw_{860BB310-5D01-11D0-BD3B-00A0C911CE86}\\\\{A3FCE0F5-3493-419F-958A-ABA1250EC20B}')}\n\n\n**Set the camera resolution, fps, vcodec/pixel-format**\n\n```python\nfrom ffmpegcv.ffmpeg_reader_camera import query_camera_options\n\noptions = query_camera_options(0)  # or query_camera_options(\"Integrated Camera\") \nprint(options)\ncap = ffmpegcv.VideoCaptureCAM(0, **options[-1])\n```\n\u003e[{'camcodec': 'mjpeg', 'campix_fmt': None, 'camsize_wh': (1280, 720), 'camfps': 60.0002}, {'camcodec': 'mjpeg', 'campix_fmt': None, 'camsize_wh': (640, 480), 'camfps': 60.0002}, {'camcodec': 'mjpeg', 'campix_fmt': None, 'camsize_wh': (1920, 1080), 'camfps': 60.0002}, {'camcodec': None, 'campix_fmt': 'yuyv422', 'camsize_wh': (1280, 720), 'camfps': 10}, {'camcodec': None, 'campix_fmt': 'yuyv422', 'camsize_wh': (640, 480), 'camfps': 30}, {'camcodec': None, 'campix_fmt': 'yuyv422', 'camsize_wh': (1920, 1080), 'camfps': 5}]\n\n**Known issues**\n1. The VideoCaptureCAM didn't give a smooth experience in macOS. You must specify all the camera parameters. And the query_camera_options woun't give any suggestion. That's because the `ffmpeg` cannot list device options using mac native `avfoundation`. \n```python\n# The macOS requires full argument.\ncap = ffmpegcv.VideoCaptureCAM('FaceTime HD Camera', camsize_wh=(1280,720), camfps=30, campix_fmt='nv12')\n```\n\n2. The VideoCaptureCAM cann't list the FPS in linux. Because the `ffmpeg` cound't query the device's FPS using linux native `v4l2` module. However, it's just OK to let the FPS empty.\n\n\n## Stream Reader (Live streaming, RTSP IP cameras)\n**Experimental feature**. The ffmpegcv offers Stream reader. Which is consistent with VideoFiler reader, and more similiar to the camera.\nBecareful when using it.\n\n- Support `RTSP`, `RTP`, `RTMP`, `HTTP`, `HTTPS` streams.\n- The `VideoCaptureStream` will be laggy and dropping frames if your post-process takes long time. The VideoCaptureCAM will buffer the recent frames.\n- The `VideoCaptureStreamRT` is continously working on background even if you didn't read it. **Please release it in time**.\n- **Low latency** RTSP IP camera reader. Batter than opencv.\n- *It's still experimental*. Recommand you to use opencv.\n\n\n```python\n# opencv\nimport cv2\nstream_url = 'http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear2/prog_index.m3u8'\ncap = cv2.VideoCapture(stream_url, cv2.CAP_FFMPEG)\n\nif not cap.isOpened():\n    print('Cannot open the stream')\n    exit(-1)\n\nwhile True:\n    ret, frame = cap.read()\n    if not ret:\n        break\n    pass\n\n# ffmpegcv\nimport ffmpegcv\ncap = ffmpegcv.VideoCaptureStream(stream_url)\nwhile True:\n    ret, frame = cap.read()\n    if not ret:\n        break\n    pass\n\n# ffmpegcv, IP Camera Low-latency\n# e.g. HIK Vision IP Camera, `101` Main camera stream, `102` the second\nstream_url = 'rtsp://admin:PASSWD@192.168.1.xxx:8554/Streaming/Channels/102'\ncap = ffmpegcv.VideoCaptureStreamRT(stream_url)  # Low latency \u0026 recent buffered\ncap = ffmpegcv.ReadLiveLast(ffmpegcv.VideoCaptureStreamRT, stream_url) #no buffer\nwhile True:\n    ret, frame = cap.read()\n    if not ret:\n        break\n    pass\n```\n\n## Noblock\nA proxy to automatic prepare frames in backgroud, which does not block when reading\u0026writing current frame (multiprocessing). This make your python program more efficient in CPU usage. Up to 2x boost.\n\n\u003e ffmpegcv.VideoCapture(*args) -\u003e ffmpegcv.noblock(ffmpegcv.VideoCapture, *args)\n\u003e \n\u003e ffmpegcv.VideoWriter(*args) -\u003e ffmpegcv.noblock(ffmpegcv.VideoWriter, *args)\n```python\n#Proxy any VideoCapture\u0026VideoWriter args and kargs\nvid_noblock = ffmpegcv.noblock(ffmpegcv.VideoCapture, vfile, pix_fmt='rbg24')\n\n# this is fast\ndef cpu_tense(): time.sleep(0.01)\nfor _ in tqdm.trange(1000):\n    ret, img = vid_noblock.read() #current img is already buffered, take no time\n    cpu_tense()                   #meanwhile, the next img is buffering in background\n\n# this is slow\nvid = ffmpegcv.VideoCapture(vfile, pix_fmt='rbg24')\nfor _ in tqdm.trange(1000):\n    ret, img = vid.read()         #this read will block cpu, take time\n    cpu_tense()\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenxinfeng4%2Fffmpegcv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchenxinfeng4%2Fffmpegcv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenxinfeng4%2Fffmpegcv/lists"}