Author Topic: Easy way to build FFMPEG and x264 under Windows  (Read 5940 times)

dosdan

  • Full Member
  • ***
  • Posts: 157
Easy way to build FFMPEG and x264 under Windows
« on: October 16, 2016, 08:35:51 PM »
Although not specifically about ADM, it you are currently using ADM under Windows, it is likely you are already interested in or soon will be interested in FFMPEG and x264.

When I did a search on my PC for FFMPEG and x264, I found:

FFMPEG executable
MeGUI
FFDshow
TX264
MKVtoMP4
Vegas Application Extensions

x264 executable (e.g. x264.exe, x264_32.exe, x264_64.exe, etc.)
TX264
MKVtoMP4

as well a modified version of x264: x264vfw

and adapted FFMPEG & x264 libraries in AVIDemux.

x264 is a very well regarded H.264 codec. In fact, so much development has been done on it, it performs better than commercial H.264 software:

http://www.compression.ru/video/cod...12/mpeg4_avc_h264_video_codecs_comparison.pdf


While you can get W64 & W32 builds of FFMPEG, sometimes these are significantly older than the source code which is updated very often (on-going development is fast-paced). Also due to licensing, the high-quality Fraunhofer FDK AAC codec (libfdk_aac) can no longer be distributed in built versions of FFMPEG, although you are free to compile it from source code and use it for yourself (as long as you don't redistribute it). And FFMPEG includes a lot of components that you may have no need for. So being able to build FFMPEG yourself is quite desirable.

FFMPEG is a command-line program, but there are plenty of GUI front-ends for it. However, if you do a lot of conversions, creating a batchfile to run FFMPEG and dragging-&-dropping a group of media files onto the batchfile icon becomes a very easy way to accomplish this.

Compiling FFMPEG and all its associated tools & libraries under Windows appears daunting, with many programs needing to be downloaded, and many scripts to be run. However, there is very straightforward way of doing all this: media-autobuild_suite.

https://gitlab.com/RiCON/media-autobuild_suite

Quoting from its docs:

Quote
This Windows Batchscript setups a MinGW/GCC compiler environment for building ffmpeg and other media tools under Windows. After building the environment it retrieves and compiles all tools. All tools get static compiled, no external .dlls needed (with some optional exceptions)

How to use it:

Download the file, and extract it to your target folder. Compilers and tools will get installed there. Please make sure you use a folder without space characters. A good place is: c:\mingw
Double click the media-autobuild_suite.bat file
Select the toolchain you'll want (select the one your operating system is on, if you don't know it's probably 64-bit)
Select if you want to compile for Windows 32-bit, 64-bit or both
Select if you want to compile non-free tools like "fdk aac"
Select the numbers of CPU (cores) you want to use
Wait a little bit, and hopefully after a while you'll find all your "*.exe" tools under local32\bin-(audio/global/video) or local64\bin-(audio/global/video)
The Script writes a ini-file, so you only need to make these choices the first time what you want to build.

For all you need ~7 GB disk space. The script doesn't build any registry key or system variables, when you don't need it any more you can delete the folder and your system will be clean. Building everything from scratch takes about ~3 hours.

Check doc/forcing-recompilations.md to check how you can force a rebuild of all libs/binaries.

To save a bit of space you can delete, after compiling, all source folders (except the folders with a "-git", "-svn" or "-hg" on end) in /build. There's an option in the .bat for the script to remove these folders automatically.​


I've never compiled any source code before under Windows. I found with my I5 PC, using 2 out of the its 4 cores (so I could do other things), 16GB RAM & working from a SSD, it took 63 mins to automatically check for updates, download, install and then compile a w64 version of FFMPEG with Libfdk_aac included. Further changes and recompiles were much quicker as most libraries do not change depending on what compilation options you alter.

My C:\mingw and all its FFMPEG sub-directories comes to 3.32GB. This is with the automated cleanup after a compile option enabled.

There is an option in the media-autobuild_suite to also compile some associated tools/breakouts from the FFMPEG package including MediaInfo (CLI version) and x264 (H.264 stand-alone encoder).

So, if you've been put off compiling FFMPEG for yourself, try this suite. It's a fairly painless way to start compiling code.

Dan.
 
« Last Edit: October 16, 2016, 08:46:46 PM by dosdan »

AQUAR

  • Hero Member
  • *****
  • Posts: 1079
Re: Easy way to build FFMPEG and x264 under Windows
« Reply #1 on: October 20, 2016, 12:18:58 PM »
Have you ever tried compiling ADM using mingw and msys?

Unfortunately, due to a lack of time and interest/support from others, I had to stop trying to build ADM with all its extras.
Only got the build root to build a featureless version of ADM. 

dosdan

  • Full Member
  • ***
  • Posts: 157
Re: Easy way to build FFMPEG and x264 under Windows
« Reply #2 on: October 20, 2016, 08:34:48 PM »
Have you ever tried compiling ADM using mingw and msys?

No.  Perhaps some day.  Seems to be a rite-of-passage that you have to work it out for yourself.

Dan.

AQUAR

  • Hero Member
  • *****
  • Posts: 1079
Re: Easy way to build FFMPEG and x264 under Windows
« Reply #3 on: October 23, 2016, 12:08:40 PM »
In days gone by (2.5 branch days) there were a few that were doing this.
I remember one guy that was using code blocks.

I tried to solicit their help but they just weren't interested anymore.

Mean promised to update the wiki wrt to compiling ADM in windows.
That obviously is a low priority at the moment but maybe one day it will happen.
   
There is always hope that someone capable will pop up that wants to give this a try and collaborate with lesser C++ mortals.
 

mean

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 10974
Re: Easy way to build FFMPEG and x264 under Windows
« Reply #4 on: October 23, 2016, 01:29:37 PM »
For plugins, the wiki is up to date

AQUAR

  • Hero Member
  • *****
  • Posts: 1079
Re: Easy way to build FFMPEG and x264 under Windows
« Reply #5 on: October 25, 2016, 12:26:20 PM »
Thanks Mean.
I was aware of the wiki on how to compile your own plugin on windows.

I could muddle forward, but its just too inefficient to be side tracked on every small "obstacle".
Just need more focused help/approach from those that are proficient in C++ and a good IDE running in windows.
 

mean

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 10974
Re: Easy way to build FFMPEG and x264 under Windows
« Reply #6 on: October 25, 2016, 05:00:56 PM »
Setting up the build env on windows is painful
If you get winbuild or mxe up and running it's a good start
(you need gcc /g++ as compilier)

AQUAR

  • Hero Member
  • *****
  • Posts: 1079
Re: Easy way to build FFMPEG and x264 under Windows
« Reply #7 on: October 26, 2016, 12:44:02 PM »
My current ADM build environment is on a dedicated windows 7.
Basically using MSYS, MINGW64, a specific version of CMAKE and then executing the bash script.

I made many "changes" to the code and scripts to get it to build, but have no understanding of the implications of these brute force twiddles. But it did build a "frankenstein" ADM.

I'll DL Winbuild and MXE and get some familiarity with them.   

mean

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 10974
Re: Easy way to build FFMPEG and x264 under Windows
« Reply #8 on: October 26, 2016, 05:59:51 PM »
Pick one
They offer an easy way to get the dependancy

win64->winbuild
win32->mxe


AQUAR

  • Hero Member
  • *****
  • Posts: 1079
Re: Easy way to build FFMPEG and x264 under Windows
« Reply #9 on: October 27, 2016, 12:04:56 PM »
Thanks,

I'll try winbuild as suggested for the win64 OS.
I presume by winbuild you we are talking about http://win-builds.org.
« Last Edit: October 27, 2016, 12:41:00 PM by AQUAR »