Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build with ffmpeg 6.0 #8096

Merged
merged 5 commits into from
Jan 15, 2024
Merged

Fix build with ffmpeg 6.0 #8096

merged 5 commits into from
Jan 15, 2024

Conversation

zboszor
Copy link
Contributor

@zboszor zboszor commented Nov 7, 2023

ffmpeg has this more than 3 years old changelog entry:

2020-05-21 - 13b1bbff0b - lavc 58.86.101 - avcodec.h
  Deprecated AV_CODEC_CAP_INTRA_ONLY and AV_CODEC_CAP_LOSSLESS.

Fixes #7998

Signed-off-by: Zoltán Böszörményi <[email protected]>
Copy link

pytorch-bot bot commented Nov 7, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/8096

Note: Links to docs will display an error until the docs builds have been completed.

⏳ 1 Pending, 1 Unrelated Failure

As of commit f179ecf with merge base 87f1521 (image):

FLAKY - The following job failed but was likely due to flakiness present on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot
Copy link

Hi @zboszor!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@surak
Copy link

surak commented Dec 19, 2023

Still not there for 0.16.2

@xvdp
Copy link

xvdp commented Jan 9, 2024

I don't know if this is related or not. But I have had much trouble using later versions of ffmpeg with torchvision.

On cuda 11.8 Ubuntu 22,04 torch 2.0.1 I could not get the the ffmpeg version I was using (5.1.2) . conda install torchvision would clobber it - either making torchvision of ffmpeg or both unusable depending in the installation order.

I resorted to create a docker image where I would first set channels strict, install torch , then set channels to flexible and install ffmpeg==5.1.2, then pull and compile torchvision. I encountered to errrors on doing that (clearly there could be some as ai didnt run a test suite, simply used it for my video projects)

Thinking that this may have been fixed, I just built a new image with cuda 12.1 and torch 2.1.2 and tried installing torchvision 16.2 with the rest of the conda packages. Unfortunately the ffmpeg installation got mangled up so I will resort to compiling vision again from github.

Error: when I type$ ffmpeg i get ffmpeg: error while loading shared libraries: libopenh264.so.5: cannot open shared object file: No such file or directory

ffmpeg is evolving so fast that it would be great that torchvision does not clobbler it.

Thanks!

@surak
Copy link

surak commented Jan 9, 2024

@xvdp we use the patch in production. It works for us.

Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix and for your patience @zboszor . Let me merge this now, it should be available with torchvision 0.18.


Notes for myself: video tests and CI building is completely toasted #8162. I verified locally that this PR works on ffmpeg6. This doesn't introduce any new construct so it should still work fine with previous versions of ffmpeg.

(ffmpeg6) ➜  vision git:(fix-with-ffmpeg6) ✗ ldd build/lib.linux-x86_64-cpython-310/torchvision/video_reader.so
	linux-vdso.so.1 (0x00007ffd78f94000)
	libavcodec.so.60 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/libavcodec.so.60 (0x00007fb5dfe00000)
	libavformat.so.60 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/libavformat.so.60 (0x00007fb5dfa00000)
	libavutil.so.58 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/libavutil.so.58 (0x00007fb5de800000)
	libswresample.so.4 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/libswresample.so.4 (0x00007fb5e122f000)
	libswscale.so.7 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/libswscale.so.7 (0x00007fb5e1198000)
	libc10.so => not found
	libtorch.so => not found
	libtorch_cpu.so => not found
	libtorch_python.so => not found
	libstdc++.so.6 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/libstdc++.so.6 (0x00007fb5de61d000)
	libm.so.6 => /lib64/libm.so.6 (0x00007fb5dfd22000)
	libgcc_s.so.1 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/libgcc_s.so.1 (0x00007fb5e1160000)
	libc.so.6 => /lib64/libc.so.6 (0x00007fb5de400000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fb5e12cb000)
	libvpx.so.8 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libvpx.so.8 (0x00007fb5de209000)
	libiconv.so.2 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libiconv.so.2 (0x00007fb5df919000)
	liblzma.so.5 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./liblzma.so.5 (0x00007fb5e1130000)
	libdav1d.so.6 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libdav1d.so.6 (0x00007fb5de011000)
	libaom.so.3 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libaom.so.3 (0x00007fb5dd800000)
	libmp3lame.so.0 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libmp3lame.so.0 (0x00007fb5dfcaa000)
	libopus.so.0 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libopus.so.0 (0x00007fb5ddfb0000)
	libSvtAv1Enc.so.1 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libSvtAv1Enc.so.1 (0x00007fb5dd000000)
	libx264.so.164 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libx264.so.164 (0x00007fb5dcc00000)
	libx265.so.199 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libx265.so.199 (0x00007fb5db800000)
	libopenh264.so.7 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libopenh264.so.7 (0x00007fb5dcedf000)
	libz.so.1 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libz.so.1 (0x00007fb5e1111000)
	libva.so.2 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libva.so.2 (0x00007fb5ddf7f000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007fb5e110c000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fb5e1107000)
	libxml2.so.2 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libxml2.so.2 (0x00007fb5dca97000)
	libbz2.so.1.0 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libbz2.so.1.0 (0x00007fb5dfc96000)
	libgnutls.so.30 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libgnutls.so.30 (0x00007fb5db400000)
	libva-drm.so.2 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libva-drm.so.2 (0x00007fb5e1100000)
	libva-x11.so.2 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libva-x11.so.2 (0x00007fb5e10f9000)
	libX11.so.6 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libX11.so.6 (0x00007fb5db6bb000)
	librt.so.1 => /lib64/librt.so.1 (0x00007fb5df914000)
	libicui18n.so.73 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libicui18n.so.73 (0x00007fb5db000000)
	libicuuc.so.73 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libicuuc.so.73 (0x00007fb5dac00000)
	libicudata.so.73 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libicudata.so.73 (0x00007fb5d8c00000)
	libp11-kit.so.0 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libp11-kit.so.0 (0x00007fb5daed2000)
	libidn2.so.0 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libidn2.so.0 (0x00007fb5ddf2c000)
	libtasn1.so.6 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libtasn1.so.6 (0x00007fb5df8ff000)
	libnettle.so.8 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libnettle.so.8 (0x00007fb5dd7aa000)
	libhogweed.so.6 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libhogweed.so.6 (0x00007fb5db663000)
	libgmp.so.10 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libgmp.so.10 (0x00007fb5db358000)
	libdrm.so.2 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libdrm.so.2 (0x00007fb5de606000)
	libXext.so.6 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libXext.so.6 (0x00007fb5ddf17000)
	libXfixes.so.3 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libXfixes.so.3 (0x00007fb5ddf0e000)
	libX11-xcb.so.1 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libX11-xcb.so.1 (0x00007fb5ddf09000)
	libxcb.so.1 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libxcb.so.1 (0x00007fb5dd77e000)
	libxcb-dri3.so.0 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libxcb-dri3.so.0 (0x00007fb5ddf03000)
	libffi.so.8 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./././libffi.so.8 (0x00007fb5dcece000)
	libunistring.so.2 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./././libunistring.so.2 (0x00007fb5d8a7b000)
	libXau.so.6 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./././libXau.so.6 (0x00007fb5dcec9000)
	libXdmcp.so.6 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./././libXdmcp.so.6 (0x00007fb5dca8f000)

(ffmpeg6) ➜  vision git:(fix-with-ffmpeg6) ✗ ldd build/lib.linux-x86_64-cpython-310/torchvision/video_reader.so
	linux-vdso.so.1 (0x00007ffd78f94000)
	libavcodec.so.60 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/libavcodec.so.60 (0x00007fb5dfe00000)
	libavformat.so.60 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/libavformat.so.60 (0x00007fb5dfa00000)
	libavutil.so.58 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/libavutil.so.58 (0x00007fb5de800000)
	libswresample.so.4 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/libswresample.so.4 (0x00007fb5e122f000)
	libswscale.so.7 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/libswscale.so.7 (0x00007fb5e1198000)
	libc10.so => not found
	libtorch.so => not found
	libtorch_cpu.so => not found
	libtorch_python.so => not found
	libstdc++.so.6 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/libstdc++.so.6 (0x00007fb5de61d000)
	libm.so.6 => /lib64/libm.so.6 (0x00007fb5dfd22000)
	libgcc_s.so.1 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/libgcc_s.so.1 (0x00007fb5e1160000)
	libc.so.6 => /lib64/libc.so.6 (0x00007fb5de400000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fb5e12cb000)
	libvpx.so.8 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libvpx.so.8 (0x00007fb5de209000)
	libiconv.so.2 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libiconv.so.2 (0x00007fb5df919000)
	liblzma.so.5 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./liblzma.so.5 (0x00007fb5e1130000)
	libdav1d.so.6 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libdav1d.so.6 (0x00007fb5de011000)
	libaom.so.3 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libaom.so.3 (0x00007fb5dd800000)
	libmp3lame.so.0 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libmp3lame.so.0 (0x00007fb5dfcaa000)
	libopus.so.0 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libopus.so.0 (0x00007fb5ddfb0000)
	libSvtAv1Enc.so.1 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libSvtAv1Enc.so.1 (0x00007fb5dd000000)
	libx264.so.164 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libx264.so.164 (0x00007fb5dcc00000)
	libx265.so.199 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libx265.so.199 (0x00007fb5db800000)
	libopenh264.so.7 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libopenh264.so.7 (0x00007fb5dcedf000)
	libz.so.1 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libz.so.1 (0x00007fb5e1111000)
	libva.so.2 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libva.so.2 (0x00007fb5ddf7f000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007fb5e110c000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fb5e1107000)
	libxml2.so.2 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libxml2.so.2 (0x00007fb5dca97000)
	libbz2.so.1.0 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libbz2.so.1.0 (0x00007fb5dfc96000)
	libgnutls.so.30 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libgnutls.so.30 (0x00007fb5db400000)
	libva-drm.so.2 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libva-drm.so.2 (0x00007fb5e1100000)
	libva-x11.so.2 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libva-x11.so.2 (0x00007fb5e10f9000)
	libX11.so.6 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./libX11.so.6 (0x00007fb5db6bb000)
	librt.so.1 => /lib64/librt.so.1 (0x00007fb5df914000)
	libicui18n.so.73 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libicui18n.so.73 (0x00007fb5db000000)
	libicuuc.so.73 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libicuuc.so.73 (0x00007fb5dac00000)
	libicudata.so.73 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libicudata.so.73 (0x00007fb5d8c00000)
	libp11-kit.so.0 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libp11-kit.so.0 (0x00007fb5daed2000)
	libidn2.so.0 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libidn2.so.0 (0x00007fb5ddf2c000)
	libtasn1.so.6 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libtasn1.so.6 (0x00007fb5df8ff000)
	libnettle.so.8 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libnettle.so.8 (0x00007fb5dd7aa000)
	libhogweed.so.6 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libhogweed.so.6 (0x00007fb5db663000)
	libgmp.so.10 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libgmp.so.10 (0x00007fb5db358000)
	libdrm.so.2 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libdrm.so.2 (0x00007fb5de606000)
	libXext.so.6 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libXext.so.6 (0x00007fb5ddf17000)
	libXfixes.so.3 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libXfixes.so.3 (0x00007fb5ddf0e000)
	libX11-xcb.so.1 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libX11-xcb.so.1 (0x00007fb5ddf09000)
	libxcb.so.1 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libxcb.so.1 (0x00007fb5dd77e000)
	libxcb-dri3.so.0 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/././libxcb-dri3.so.0 (0x00007fb5ddf03000)
	libffi.so.8 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./././libffi.so.8 (0x00007fb5dcece000)
	libunistring.so.2 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./././libunistring.so.2 (0x00007fb5d8a7b000)
	libXau.so.6 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./././libXau.so.6 (0x00007fb5dcec9000)
	libXdmcp.so.6 => /home/nicolashug/.miniconda3/envs/ffmpeg6/lib/./././libXdmcp.so.6 (0x00007fb5dca8f000)
(ffmpeg6) ➜  vision git:(fix-with-ffmpeg6) ✗ python lol.py 
pyav
video_reader
/home/nicolashug/vision/torchvision/io/_video_opt.py:443: UserWarning: The pts_unit 'pts' gives wrong results and will be removed in a follow-up version. Please use pts_unit 'sec'.
  warnings.warn(
torch.Size([83, 240, 320, 3])
torch.Size([3, 240, 320])

@NicolasHug NicolasHug merged commit a00a72b into pytorch:main Jan 15, 2024
63 of 64 checks passed
ahmadsharif1 pushed a commit to ahmadsharif1/vision that referenced this pull request Jan 16, 2024
Signed-off-by: Zoltán Böszörményi <[email protected]>
Co-authored-by: Nicolas Hug <[email protected]>
facebook-github-bot pushed a commit that referenced this pull request Mar 19, 2024
Summary: Signed-off-by: Zoltán Böszörményi <[email protected]>

Reviewed By: vmoens

Differential Revision: D55062796

fbshipit-source-id: ebd3bd552ee55f1bc2788df64ed21ed4fefab09e

Co-authored-by: Nicolas Hug <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

torchvision 0.15.2 + ffmpeg 6.0 build error: ‘AV_CODEC_CAP_INTRA_ONLY’ was not declared
5 participants