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

(Windows) error: Video support is permanently disabled in this executable. #226

Open
ericoporto opened this issue Mar 19, 2022 · 14 comments

Comments

@ericoporto
Copy link

ericoporto commented Mar 19, 2022

The release binaries doesn't support video input, but in the same page it says video as input should be possible.

@kornelski
Copy link
Member

Building ffmpeg on Windows is a pain. I've managed to get it working on Linux and macOS, but I have no hope of fixing it on Windows. You'll have to use a separate command to make PNG frames.

@camjac251
Copy link

Would these help @kornelski https://www.gyan.dev/ffmpeg/builds/

@kornelski
Copy link
Member

No, these are builds of ffmpeg command-line tool, which isn't for integrating into other programs.

@andylizi
Copy link
Contributor

andylizi commented Mar 22, 2022

It does provided a "shared" build for dynamic linking. I have successfully built gifski with it before, and I remember it being a relatively painless process — just followed the instruction here. gyan.dev is also what ffmpeg-sys-next used for it's CI build test.

Of course, trying to build it statically is a whole other beast……

@kornelski
Copy link
Member

ah, ok

@kornelski
Copy link
Member

I've tried gyan.dev/ffmpeg/builds. Only ffmpeg-4.4.1-full_build-shared.7z contained libraries. Even though they were supposedly static .lib files, compiling the ffmpeg crate with them made gifski.exe depend on these DLLs:

avcodec-58.dll
avformat-58.dll
avutil-56.dll
swscale-5.dll
swresample-3.dll
avfilter-7.dll

and it crashes without them (exit code: 0xc0000135, STATUS_DLL_NOT_FOUND).

To repro:

  1. Install LLVM
  2. Extract ffmpeg-4.4.1-full_build-shared.7z to C:\whatever\ffmpegbuild
  3. set FFMPEG_DIR=C:\whatever\ffmpegbuild
  4. cargo run --features=video-prebuilt-static

@andylizi
Copy link
Contributor

Ah yes…… That's the thing. The "static .lib files" actually just reexport from the DLLs, and do not contain the code itself (their sizes are too small for that). I've spent a long time trying to do the same thing and eventually decided it's not possible.

I had to build my own ffmpeg in the end, which was fun.

@jalba69
Copy link

jalba69 commented Jul 1, 2022

Hello,
can you give a little more details about how to have it even with the FFMPEG dll's needed please ?

I tried it but i end up with an error :

Compiling imagequant v4.0.0
Compiling ffmpeg-sys-next v4.4.0 (https://github.com/kornelski/rust-ffmpeg-sys-1?rev=78458039d5fac99354f9cb078869f3be3f3af5fb#78458039)
error: failed to run custom build command for ffmpeg-sys-next v4.4.0 (https://github.com/kornelski/rust-ffmpeg-sys-1?rev=78458039d5fac99354f9cb078869f3be3f3af5fb#78458039)

Caused by:
  process didn't exit successfully: H:\gifski-main\target\debug\build\ffmpeg-sys-next-80de3680ed4e4b8b\build-script-build` (exit code: 101)

H:\gifski-main>
  • I have LLVM_clang 14.0.6 installed and path is set in the environment
  • Tried with the files from the link above for FFMPEG, and also from the package i got using VS2022 and the vcpkg package version 4.4.1#13 we can find on vcpkg repo
  • I set the FFMPEG path to either one of those and always end up with an error when launching the cargo run --features=video-prebuilt-static command from Gifski folder.

Am i doing it wrong or missing something please ?

I'd rather use the files i have from vcpkg as I enabled the Avisynth+ switch there so i could feed Gifski directly with .avs files.

Right now i already have a simplified way to use Gifski but if i could avoid the step where i need to extract the png's it will be a big plus, no matter if i need the dll's from ffmpeg.

PS : also saw vcpkg-rs with the RUSTFLAGS=-Ctarget-feature=+crt-static parameter that could maybe help avoid the separate dll's, well i think... this is far behind my knowledge and after looking around i still have no clue how to use this in a rust package.
Anyways maybe something to explore for coding guru's, will make things way easier, at least for me who is used to getting vcpkg lib's with visual studio and already have the ffmpeg ones.

Thanks a lot.

@jalba69
Copy link

jalba69 commented Jul 2, 2022

Should have waited to post my previous comment...

after many more failed attempts i have it finally working, seems like adding LIBCLANG_PATH to env. variable did the trick, i already had the rest correctly set and according to the doc it's one or the other if you have LLVM path set but I'm just happy it works.

Used the FFmpeg files from windows vcpkg package i had already, of course i still need FFmpeg dll's like mentioned in your attempts but this is just a minor annoyance compared to the benefits of having FFmpeg built-in.

Bonus : it have avisynth support, so i can feed Gifski directly with a simple .avs script containing a few lines to trim,crop,resize video using a better resizing filter or add any other avisynth supported filters/plugins to it in a blink which is what i had in mind since i discovered this tool some years ago.

Now it is time to play with this and test it deeply, thank you very much guys :)

Edit :

Tried with the static version of ffmpeg via vcpkg using triplet vcpkg install ffmpeg:x64-windows-static (previously was with x64-windows only )

then cargo build --release --features=video-prebuilt-static for gifski, ffmpeg seems to compile, but when it makes Gifski itself it appears a lot of link.exe issues and fails...

   Compiling ffmpeg-sys-next v4.4.0 (https://github.com/kornelski/rust-ffmpeg-sys-1?rev=78458039d5fac99354f9cb078869f3be3f3af5fb#78458039)
   Compiling gifski v1.7.0 (H:\gifski-main)
warning: use of deprecated associated function `ffmpeg_next::decoder::Video::decode`: Underlying API avcodec_decode_video2 has been deprecated since FFmpeg 3.1; consider switching to send_packet() and receive_frame()
   --> src\bin\ffmpeg_source.rs:106:35
    |
106 |             let decoded = decoder.decode(&packet, &mut vid_frame)?;
    |                                   ^^^^^^
    |
    = note: `#[warn(deprecated)]` on by default

error: linking with `link.exe` failed: exit code: 1120
  |
  = note: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.32.31326\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "H:\\gifski-main\\target\\release\\deps\\gifski.gifski.5d80da7e-cgu.11.rcgu.o" "/LIBPATH:H:\\gifski-main\\target\\release\\deps" "/LIBPATH:F:\\Compilers_Stuff\\vcpkg\\installed\\x64-windows-static\\lib" "/LIBPATH:H:\\gifski-main\\target\\release\\build\\gifsicle-900e2bbb040dea74\\out" "/LIBPATH:F:\\Compilers_Stuff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\user\\AppData\\Local\\Temp\\rustcj9BUgr\\libffmpeg_sys_next-a8f36765305b9faf.rlib" "C:\\Users\\user\\AppData\\Local\\Temp\\rustcj9BUgr\\libgifsicle-a261648c20138029.rlib" "F:\\Compilers_Stuff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-c9e4ee006e473c58.rlib" "advapi32.lib" "cfgmgr32.lib" "gdi32.lib" "kernel32.lib" "msimg32.lib" "opengl32.lib" "user32.lib" "winspool.lib" "bcrypt.lib" "kernel32.lib" "ws2_32.lib" "bcrypt.lib" "advapi32.lib" "userenv.lib" "kernel32.lib" "msvcrt.lib" "/NXCOMPAT" "/LIBPATH:F:\\Compilers_Stuff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "/OUT:H:\\gifski-main\\target\\release\\deps\\gifski.exe" "/OPT:REF,ICF" "/DEBUG" "/NATVIS:F:\\Compilers_Stuff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:F:\\Compilers_Stuff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:F:\\Compilers_Stuff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:F:\\Compilers_Stuff\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libstd.natvis"
  = note: LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
          libffmpeg_sys_next-a8f36765305b9faf.rlib(mfenc.o) : error LNK2019: unresolved external symbol MFCreateMediaType referenced in function mf_choose_output_type
          libffmpeg_sys_next-a8f36765305b9faf.rlib(mfenc.o) : error LNK2001: unresolved external symbol IID_ICodecAPI
          libffmpeg_sys_next-a8f36765305b9faf.rlib(mfenc.o) : error LNK2001: unresolved external symbol IID_IMFMediaEventGenerator
          libffmpeg_sys_next-a8f36765305b9faf.rlib(mf_utils.o) : error LNK2019: unresolved external symbol __imp_CoUninitialize referenced in function ff_free_mf
          libffmpeg_sys_next-a8f36765305b9faf.rlib(mf_utils.o) : error LNK2019: unresolved external symbol __imp_CoInitializeEx referenced in function ff_instantiate_mf
          libffmpeg_sys_next-a8f36765305b9faf.rlib(mf_utils.o) : error LNK2019: unresolved external symbol __imp_CoTaskMemFree referenced in function ff_instantiate_mf
          libffmpeg_sys_next-a8f36765305b9faf.rlib(dxva2.o) : error LNK2001: unresolved external symbol __imp_CoTaskMemFree
          libffmpeg_sys_next-a8f36765305b9faf.rlib(mf_utils.o) : error LNK2019: unresolved external symbol MFStartup referenced in function ff_instantiate_mf
          libffmpeg_sys_next-a8f36765305b9faf.rlib(mf_utils.o) : error LNK2019: unresolved external symbol MFShutdown referenced in function ff_free_mf
          libffmpeg_sys_next-a8f36765305b9faf.rlib(mf_utils.o) : error LNK2019: unresolved external symbol MFCreateAlignedMemoryBuffer referenced in function ff_create_memory_sample
          libffmpeg_sys_next-a8f36765305b9faf.rlib(mf_utils.o) : error LNK2019: unresolved external symbol MFCreateSample referenced in function ff_create_memory_sample
          libffmpeg_sys_next-a8f36765305b9faf.rlib(mf_utils.o) : error LNK2001: unresolved external symbol IID_IMFTransform
          libffmpeg_sys_next-a8f36765305b9faf.rlib(tls_schannel.o) : error LNK2019: unresolved external symbol AcquireCredentialsHandleA referenced in function tls_open
          libffmpeg_sys_next-a8f36765305b9faf.rlib(tls_schannel.o) : error LNK2019: unresolved external symbol __imp_FreeCredentialsHandle referenced in function tls_close
          libffmpeg_sys_next-a8f36765305b9faf.rlib(tls_schannel.o) : error LNK2019: unresolved external symbol InitializeSecurityContextA referenced in function tls_close
          libffmpeg_sys_next-a8f36765305b9faf.rlib(tls_schannel.o) : error LNK2019: unresolved external symbol __imp_DeleteSecurityContext referenced in function tls_close
          libffmpeg_sys_next-a8f36765305b9faf.rlib(tls_schannel.o) : error LNK2019: unresolved external symbol __imp_ApplyControlToken referenced in function tls_close
          libffmpeg_sys_next-a8f36765305b9faf.rlib(tls_schannel.o) : error LNK2019: unresolved external symbol QueryContextAttributesA referenced in function tls_write
          libffmpeg_sys_next-a8f36765305b9faf.rlib(tls_schannel.o) : error LNK2019: unresolved external symbol FreeContextBuffer referenced in function tls_close
          libffmpeg_sys_next-a8f36765305b9faf.rlib(tls_schannel.o) : error LNK2019: unresolved external symbol EncryptMessage referenced in function tls_write
          libffmpeg_sys_next-a8f36765305b9faf.rlib(tls_schannel.o) : error LNK2019: unresolved external symbol DecryptMessage referenced in function tls_read
          H:\gifski-main\target\release\deps\gifski.exe : fatal error LNK1120: 20 unresolved externals


warning: `gifski` (bin "gifski") generated 1 warning
error: could not compile `gifski` due to previous error; 1 warning emitted

Seems linked to how vcpkg works sadly : microsoft/vcpkg#9571 (comment)
Maybe adding the list of libs missing at Gifski's build will help but i have no clue how to link all those libs in a rust package, will need to investigate...

Well it ain't for this time to succeed with this, it had been too easy I guess, but as long as i have it working with additional dll's it's fine for now :)

@jalba69
Copy link

jalba69 commented Jul 2, 2022

So...
I have it now compiled as a single .exe with ffmpeg support and no dll's needed with it :)

getting the ffmpeg static files needed :
vcpkg install ffmpeg:x64-windows-static

then :
FFMPEG_DIR= set to \vcpkg\installed\x64-windows-static folder

and most important to fix the link.exe errors i had because of how vcpkg works and skip libraries :

  • create a folder at Gifski files root named .cargo and inside it create a config.toml file with this content inside :
[target.x86_64-pc-windows-msvc]
rustflags = [
    "-C", "link-arg=dxva2.lib",
    "-C", "link-arg=evr.lib",
    "-C", "link-arg=mf.lib",
    "-C", "link-arg=mfplat.lib",
    "-C", "link-arg=mfplay.lib",
    "-C", "link-arg=mfreadwrite.lib",
    "-C", "link-arg=mfuuid.lib",
    "-C", "link-arg=bcrypt.lib",
    "-C", "link-arg=ws2_32.lib",
    "-C", "link-arg=Secur32.lib",
    "-C", "link-arg=Strmiids.lib",
    "-C", "link-arg=Ole32.lib"
]

Then cargo build --release --features=video-prebuilt-static in Gifski main folder and i end up with a 18.9MB .exe and it works for the few tries i done ;)

Only big down for me is that vcpkg doesn't seems able to get the static FFMEG with avisynth feature enabled, seems possible only with a dynamic version, but i'll have to see this with ffmpeg's vcpkg guys directly in the next days I guess, hopefully this can be fixed since we can have a avisynth static version from vcpkg.

Anyways, after spending so many time on this it works so I'm happy and it might help someone else who knows ^^

Edit :

After messing a bit with the vcpkg port for ffmpeg i managed to build the static files with Avisynth support, in the meantime i had asked on vcpkg page about it and we will see what they say but seems like it could be fully supported.

The first time i asked on this project about ffmpeg and avisynth support for windows it was more than 4 years ago, always had been disappointed to not see this possible on windows, better late than never, thanks a lot, I'm done now :)

@megapro17
Copy link

@jalba69 upload EXE

@jalba69
Copy link

jalba69 commented Oct 20, 2022

Here it is :

gifski.zip v1.7.2.0

SHA-256 for the zipped file : AB05114DBF0CEAF9974A0C1D1A2346841726A334E4D387E8C7697E549FB6142C
SHA-256 for the .exe once unzipped : 7AC8F5A8A28BF39D26C9F1B398651F92EA081767A4CD0921259D2674DA8843FF

VirusTotal scan for the zip : https://www.virustotal.com/gui/url-analysis/u-2dbffbefbbc162183294b2a1f6ae021d28fbc48647cda708e92117900967185e-1666291294

It have ffmpeg & avisynth support + added infos details in the proprieties and a dedicated icon for the .exe using a .res file.
It also use the mimalloc 0.1.29 crate that give slightly better performances for me on windows.

Enjoy ;)

@kornelski : if you have a problem with me uploading the .exe here let me know, i'll remove my post asap, thanks again for this nice tool :)

@megapro17
Copy link

Thanks, but why you're worrying so much..

@jalba69
Copy link

jalba69 commented Oct 20, 2022

not worried, just used to do it that way, plus this might start to travel around on the net so adding infos from the starting source ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants