- Notifications
You must be signed in to change notification settings - Fork72
Full (dec+filters) ffmpeg-vaapi pipeline for Intel GPU (xpu pytorch backend)#832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Draft
dvrogozh wants to merge4 commits intometa-pytorch:mainChoose a base branch fromdvrogozh:filters-vaapi
base:main
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
FFmpeg filter graphs allow to cover a lot of use cases includingcpu and gpu usages. This commit moves filter graph support out ofCPU device interface which allows flexibility in usage acrossother contexts.Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@gmail.com>
This was referencedAug 22, 2025
Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@gmail.com>
This commit enables support for Intel GPUs in torchcodec. It adds:* ffmpeg-vaapi for decoding and color space conversion from decoding output to RGBA* RGBA surface import as torch tensor (on torch xpu device)* RGBA to RGB24 tensor slicingTo build torchcodec with Intel GPU support:* Install pytorch with XPU backend support. For example, with:```pip3 install torch --index-urlhttps://download.pytorch.org/whl/xpu```* Install oneAPI development environment followinghttps://github.com/pytorch/pytorch?tab=readme-ov-file#intel-gpu-support* Build and install FFmpeg with `--enable-vaapi`* Install torcheval (for tests): `pip3 install torcheval`* Build torchcodec with: `ENABLE_XPU=1 python3 setup.py devel`Notes:* RGB24 is not supported color format on current Intel GPUs (as it is considered to be suboptimal due to odd alignments)* Intel media and compute APIs can't seamlessly work with the memory from each other. For example, Intel computes's Unified Shared Memory pointers are not recognized by media APIs. Thus, lower level sharing via dma fds is needed. This alos makes this part of the solution OS dependent.* Color space conversion algoriths might be quite different as it happens for Intel. This requires to check PSNR values instead of per-pixel atol/rtol differences.* Installing oneAPI environment is neded due topytorch/pytorch#149075This commit was primary verfied on Intel Battlemage G21 (0xe20b) andIntel Data Center GPU Flex (0x56c0).Co-authored-by: Edgar Romo Montiel <edgar.romo.montiel@intel.com>Signed-off-by: Edgar Romo Montiel <edgar.romo.montiel@intel.com>Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>Use ffmpeg-vaapi filters for color conversion in XPU interfaceSigned-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@gmail.com>
Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading.Please reload this page.
Background
I submit this PR to illustrate filter graphs usage for multi-gpu support on the example of ffmpeg vaapi backend. The difference of this PR from#558 is usage of ffmpeg filters for color space conversion. Pay attention that
XpuDeviceInterfaceimplemented in the last commit of this PR can further be generalized to support any hw (and cpu) ffmpeg backend by having these 3 backend specific stuff:AVBufferRef)scalevs.scale_vaapivs.scale_cuda)AVFrame(from filters) to the tensorThe reason of this PR being a draft is that currently full (dec+filters) ffmpeg-vaapi pipeline generates worse quality output vs. pipeline in#558. Reason for that is handling of color standards in
scale_vaapifilter and Intel media driver. I believe there are some issues here in these components which needs to be reported and fixed. I will follow up.Details
This commit enables support for Intel GPUs in torchcodec. It adds:
output to RGBA
To build torchcodec with Intel GPU support:
https://github.com/pytorch/pytorch?tab=readme-ov-file#intel-gpu-support
--enable-vaapipip3 install torchevalENABLE_XPU=1 python3 setup.py developCC:@scotts@NicolasHug@eromomon