Skip to content

Conversation

dvrogozh
Copy link
Contributor

@dvrogozh dvrogozh commented Oct 7, 2025

This commit exposes torchcodec core library to be used by third party modules on the C++ level. The primary purpose is to allow non-CUDA device interfaces out-of-tree implementations. There are the following major changes:

  • Exposed TorchCodecConfig.cmake which defines torchcodec targets to be linked with

  • Provided Python level APIs to faciliate out-of-tree device interfaces work with torchcodec:

    • torchcodec.cmake_prefix_path - path which points to TorchCodecConfig.cmake configuration
    • torchcodec.variant - variant of the torchcodec library which was loaded, i.e. N in libtorchcodec_core{N}.so (currently ffmpeg_major_version)
    • torchcodec.core_library_path - full path of the loaded torchcodec core library
  • src/torchcodec/_core/ dropped from include paths to allow using of the core library out-of-tree

TorchCodecConfig.cmake has 2 working modes:

  • By default config works by checking available version of FFmpeg libraries via pkg-config and configures corresponding (single) version of torchcodec
  • Altenatively, if TORCHCODEC_FFMPEG{N}_INSTALL_PREFIX is set (N=4,5,6,7 - version of FFmpeg), then config defines torchcodec target corresponding to the specified FFmpeg version. Note that multiple prefixes can be specified at the same time allowing to build against few torchcodec versions at once.

Config will define TORCHCODEC_VARIANTS variable with value corresponding to FFmpeg major versions of available torchcodec core libraries. Further, config will also define torchcodec::ffmpeg${N} and torchcodec::core${N} targets where N takes values from TORCHCODEC_VARIANTS.

See the following repository for an actual out-of-tree device interface torchcodec plugin:

I suggest to pay attention on these:

CC: @scotts, @NicolasHug

This commit exposes torchcodec core library to be used by third
party modules on the C++ level. The primary purpose is to allow
non-CUDA device interfaces out-of-tree implementations. There
are the following major changes:

* Exposed TorchCodecConfig.cmake which defines torchcodec
  targets to be linked with

* Provided Python level APIs to faciliate out-of-tree device
  interfaces work with torchcodec:

  * `torchcodec.cmake_prefix_path` - path which points to
    `TorchCodecConfig.cmake` configuration
  * `torchcodec.variant` - variant of the torchcodec library
    which was loaded, i.e. N in libtorchcodec_core{N}.so
    (currently ffmpeg_major_version)
  * `torchcodec.core_library_path` - full path of the loaded
    torchcodec core library

* `src/torchcodec/_core/` dropped from include paths to allow
  using of the core library out-of-tree

`TorchCodecConfig.cmake` has 2 working modes:

* By default config works by checking available version of
  FFmpeg libraries via `pkg-config` and configures corresponding
  (single) version of torchcodec
* Altenatively, if `TORCHCODEC_FFMPEG{N}_INSTALL_PREFIX` is set
  (`N=4,5,6,7` - version of FFmpeg), then config defines
  torchcodec target corresponding to the specified FFmpeg version.
  Note that multiple prefixes can be specified at the same time
  allowing to build against few torchcodec versions at once.

Config will define `TORCHCODEC_VARIANTS` variable with value
corresponding to FFmpeg major versions of available torchcodec
core libraries. Further, config will also define `torchcodec::ffmpeg${N}`
and `torchcodec::core${N}` targets where `N` takes values from
`TORCHCODEC_VARIANTS`.

Signed-off-by: Dmitry Rogozhkin <[email protected]>
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant