View Full Version : FFmpeg pthreads-win32
rack04
1st March 2010, 14:28
I'm having some problems linking shared pthreads in win32. Is there a FFmpeg patch that allows static linking of pthreads? I'm trying to compile FFmpeg and FFMS2 libraries for x264 and up until now I have been using w32threads. Any help would be appreciated.
Here is how I am compiling FFmpeg win32:
./configure
--prefix=/c/ffmpeg/i686-pc-mingw32
--enable-gpl
--enable-version3
--enable-postproc
--enable-w32threads
--disable-network
--enable-runtime-cpudetect
--enable-memalign-hack
--disable-encoders
--disable-decoder=aac,ac3,adpcm_*,alac,als,ape,atrac?,cook,dca,dsicinaudio,dxa,eac3,flac,interplay_dpcm,mlp,mp1,mp2,mp3,mp3*,mpc?,pcm_*,qcelp,ra_*,sipr,truehd,truespeech,tta,vorbis,wavpack,wma*,twinvq
--disable-hwaccels
--disable-muxers
--disable-demuxer=aac,ac3,pcm_*,ape,amr,ass,au,avs,dts,eac3,flac,mp3,mpc,mpc8,truehd,tta,w64,wav,wv
--disable-parser=aac,ac3,dca,mlp,mpegaudio
--disable-indevs
--disable-outdevs
--disable-devices
--disable-filters
--extra-cflags=-I/c/ffmpeg/i686-pc-mingw32/include
--extra-cflags=-march=core2
--extra-ldflags=-L/c/ffmpeg/i686-pc-mingw32/lib
--disable-debug
Here is how I am compiling FFmpeg win64:
./configure
--prefix=/c/ffmpeg/x86_64-pc-mingw32
--enable-gpl
--enable-version3
--enable-postproc
--enable-w32threads
--disable-network
--enable-runtime-cpudetect
--enable-memalign-hack
--disable-encoders
--disable-decoder=aac,ac3,adpcm_*,alac,als,ape,atrac?,cook,dca,dsicinaudio,dxa,eac3,flac,interplay_dpcm,mlp,mp1,mp2,mp3,mp3*,mpc?,pcm_*,qcelp,ra_*,sipr,truehd,truespeech,tta,vorbis,wavpack,wma*,twinvq
--disable-hwaccels
--disable-muxers
--disable-demuxer=aac,ac3,pcm_*,ape,amr,ass,au,avs,dts,eac3,flac,mp3,mpc,mpc8,truehd,tta,w64,wav,wv
--disable-parser=aac,ac3,dca,mlp,mpegaudio
--disable-indevs
--disable-outdevs
--disable-devices
--disable-filters
--extra-cflags=-I/c/ffmpeg/x86_64-pc-mingw32/include
--extra-cflags=-march=core2
--extra-ldflags=-L/c/ffmpeg/x86_64-pc-mingw32/lib
--disable-debug
--arch=x86_64
--target-os=mingw32
--cpu=core2
--enable-cross-compile
--cross-prefix=x86_64-pc-mingw32-
--extra-cflags=-Dstrtod=__strtod
roozhou
1st March 2010, 18:56
What version of MinGW are you using? Latest build from TDM, xvidvideo.ru and Komisar all contain static linked libpthread.
P.S. Why does every one use the same "--disable-decoder=", "--disable-demuxer=" and "--disable-parser" options in their configure script? I wonder where you guys got this because this is exactly the one I sent to VFR_Maniac via irc and I have never post them in doom9.
rack04
1st March 2010, 19:06
What version of MinGW are you using? Latest build from TDM, xvidvideo.ru and Komisar all contain static linked libpthread.
I am using Komisar MinGW builds and I still can't get FFmpeg to link to the static pthreads.
When I configure with --enable-pthreads I receive "ERROR: can't find pthreads library"
When I configure omitting --enable-pthreads it shows "Threading Support No"
When I configure with --enable-w32threads it shows "Threading Support w32threads"
P.S. Why does every one use the same "--disable-decoder=", "--disable-demuxer=" and "--disable-parser" options in their configure script? I wonder where you guys got this because this is exactly the one I sent to VFR_Maniac via irc and I have never post them in doom9.
http://forum.doom9.org/showthread.php?p=1363644#post1363644
EDIT: I've almost got it figured out. I'm just having problems applying w64sup.patch. It fails to patch GNUmakefile and stress1.c properly. Any ideas?
ffmpeg
2nd March 2010, 03:03
try my patch:
http://www.assembla.com/code/NextPlayer/subversion/changesets/375
http://www.assembla.com/code/NextPlayer/subversion/changesets/376
ffmpeg
2nd March 2010, 03:06
BTW:
I have no problem to compile FFmpeg and FFMS2 libraries for x264 in static or shared library
rack04
2nd March 2010, 06:11
BTW:
I have no problem to compile FFmpeg and FFMS2 libraries for x264 in static or shared library
I don't have an issue with x32. Only x64.
ffmpeg
2nd March 2010, 06:19
you should ffmpeg's config.err to check the detail of failing to find pthread
rack04
2nd March 2010, 16:22
you should ffmpeg's config.err to check the detail of failing to find pthread
c:/mingw/bin/../lib/gcc/x86_64-pc-mingw32/4.4.3/../../../../x86_64-pc-mingw32/bin/ld.exe: cannot find -lpthread
collect2: ld returned 1 exit status
ERROR: can't find pthreads library
Maccara
3rd March 2010, 02:32
Somewhere on http://ffmpeg.arrozcru.com/ you can find a patch for ffmpeg to enable pthreads static linking. There are also pointers to the required pthreads patches etc etc.
(I don't remember which patches _exactly_ are needed for x64 + static pthreads, as there are many patches needed for practically all the components involved on 64bit builds, so you'll have to dig them out)
After correctly patched all and prerequisites built & installed correctly, ./configure --enable-pthreads (+ all the other required junk, of course) works ok for 64bit builds too.
Note, that some link options need to be modified still if you want to link ffmpeg&pthreads with libx264&pthreads, as the flags are not exactly compatible (unless it has been addressed already - haven't looked for a while). I haven't bothered (as I don't use ffmpeg for encoding) so don't have the exact mods at hand.
rack04
3rd March 2010, 21:19
I found a patch for ffmpeg that is supposed to allow static linking of pthreads. I have attempted to update the patch but I get failed hunks. Would anyone be so kind to review the patch and tell me why it's failing?
http://pastebin.ca/1821764
Maccara
3rd March 2010, 21:35
I found a patch for ffmpeg that is supposed to allow static linking of pthreads. I have attempted to update the patch but I get failed hunks. Would anyone be so kind to review the patch and tell me why it's failing?
http://pastebin.ca/1821764
That "looks" valid, but I'm not surprised if some chunks fail while patching, as there have been changes to configure scripts since.
That at least contains the detection changes (in configure) and the required non-standard attach/detach changes
Just apply it manually, as it is so trivial patch.
However, you may still need to adjust the linking flags, if you plan to link with libx264, so first make sure ffmpeg compilation works with --enable-pthreads in general with this patch and then compare the flags with x264 (ffmpeg does not use pkg-config to get the proper flags).
rack04
3rd March 2010, 21:37
That "looks" valid, but I'm not surprised if some chunks fail while patching, as there have been changes to configure scripts since.
I updated the patch to reflect the changes to config. I'm doing something wrong in my patches because all of them fail. :devil: It's frustrating.
Maccara
3rd March 2010, 21:43
I updated the patch to reflect the changes to config. I'm doing something wrong in my patches because all of them fail. :devil: It's frustrating.
Which patch are you using? I'm always running into issues with msys & lf/cr+lf differences, so you might want to try converting EOLs (notepad++ does that nicely).
rack04
3rd March 2010, 21:46
Which patch are you using? I'm always running into issues with msys & lf/cr+lf differences, so you might want to try converting EOLs (notepad++ does that nicely).
patch -p0 < /c/x264/patches/ffmpeg_static_pthreads.diff
BTW, the patch works! I just wished I knew why it is failing to patch.
Maccara
3rd March 2010, 21:53
Is that 2.5.4 from msys? (patch -v tells) I've often had issues with that for some reason, but didn't bother to check why.
I use 2.5 from git (or git apply) and that has worked ok for me.
rack04
3rd March 2010, 21:55
Is that 2.5.4 from msys? (patch -v tells) I've often had issues with that for some reason, but didn't bother to check why.
I use 2.5 from git (or git apply) and that has worked ok for me.
Not sure what you're asking. I am running this (http://downloads.sourceforge.net/mingw/MSYS-1.0.11.exe) version of MSYS.
Maccara
3rd March 2010, 22:04
Not sure what you're asking. I am running this (http://downloads.sourceforge.net/mingw/MSYS-1.0.11.exe) version of MSYS.
As you do x264 compilations, you have git installed, right? (i.e. either msysgit or the "preview" with the GUI)
Just open "git bash" and try the patch from there. It is a slightly different version of patch than supplied with the msys package.
Then you can make simple tests with simple files, i.e. something like:
new file -> edit -> diff -u old new > patch.diff -> patch <patch.diff
If that does not work, you know the patch supplied by msys is just broken.
If you made your amended patch from your sources (i.e. applied original manually and fixed the offset etc and then just diffed) it should just work. If it does not, patch is broken and you need to try a different version of it.
rack04
3rd March 2010, 23:42
As you do x264 compilations, you have git installed, right? (i.e. either msysgit or the "preview" with the GUI)
Just open "git bash" and try the patch from there. It is a slightly different version of patch than supplied with the msys package.
Then you can make simple tests with simple files, i.e. something like:
new file -> edit -> diff -u old new > patch.diff -> patch <patch.diff
If that does not work, you know the patch supplied by msys is just broken.
If you made your amended patch from your sources (i.e. applied original manually and fixed the offset etc and then just diffed) it should just work. If it does not, patch is broken and you need to try a different version of it.
The patch is successful using cmd but not msys. I can't figure out why.
Maccara
4th March 2010, 01:03
The patch is successful using cmd but not msys. I can't figure out why.
Most likely EOL mismatch.
Just use what works. :)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.