Page 1 of 2
[Sequencer] FFMPEG & Blender
Posted: Sun Mar 30, 2008 7:13 pm
There's just two things I want to notify the official blender builders about.
1) Your 2.46 preview release has a bad link with the ffmpeg libraries. When importing standard MPEG clips, an error regarding stack size differences in the library is reported and the result is very slow load times, which could potentially lead to application failures too. I haven't tested this much since I went and built my own version anyway.
2) The FFMPEG library supports AVISynth (presently only available for Windows users). For future builds, I would suggest enabling this option for Windows builds. Aside from the added benefit of the power of AVISynth, let me also explain from my own perspective.
As a cinematographer hobbyist, I love using Blender for its sequence editor. It's very powerful and has infinite possibilities (especially since I wrote a LUA sequencer plugin for it). The problem lies in the HDV format, which either suffers from pulldown removal with PF24 recorded video or interlacing with I30 recordings. Both of these are trivially fixed when using AVISynth. Without it, I am forced to use external programs and process/save the video as some compressed format before importing it into blender, which is a long process and wasteful amount of memory.
To enable AVISynth, simply:
1) Replace and use the latest version of FFMPEG. The version in SVN is pretty old now.
2) Open blender\extern\ffmpeg\SConscript and update the ffmpeg_switches tag to include "--enable-avisynth". There are other switches I would recommend as well, such as support for XVid and X264, but that's up to you guys.
3) Open blender\config\win32-mingw-config.py and update the LLIBS array to include "-lvfw32", since this is a required library for AVISynth.
That's it. Compile and have fun.
Keep in mind that I have built in AVISynth support with my own Blender builds, but I strongly believe this feature should be added to the official Blender builds. The ability to frameserve streams without having to create new versions of the video is an extremely powerful tool.
Posted: Sun Mar 30, 2008 8:21 pm
> Keep in mind that I have built in AVISynth support with my own Blender
It sounds like you've solved the issues, it's just a matter of putting the argument forward to the core developers.
You might want to visit the #blendercoders IRC channel on irc.freenode.net and have a chat with the developers there - a meeting takes place every Sunday, which is the best time to put your argument across.
Your experience with FFMPEG and Blender seems extensive - how would you suggest adding in support for FLV ( Flash Video ) with ffmpeg, including audio. Is this something you've tried already? ( I believe there may be an issue with the audio aspect of this )
Posted: Sun Mar 30, 2008 9:42 pm
These changes could be made to SVN indeed, the only thing is that our releases are built with MSVC, not MingW, so if you manage to build (dynamic) FFMPEG libraries that support all you need, then please notify me.
Posted: Mon Mar 31, 2008 1:41 pm
FLV is also built into FFMPEG now. In my build, I can load .flv files with audio as easily as I can avi or mpeg files.
I'll see what can be done with the Visual Studio 7 project files, but I recall FFMPEG being somewhat stubborn to compile in Visual Studio. I noticed FFMPEG wasn't part of the extern MSVC project too, but the libraries were built in the windows lib folder. That will have to change since FFMPEG should be compiled as part of the process. If I have some time tonight I'll look into it and let you guys know.
Posted: Mon Mar 31, 2008 1:50 pm
> FLV is also built into FFMPEG now. In my build, I can load .flv files with
> audio as easily as I can avi or mpeg files.
Did you have to build FFMPEG with LAME support ( for bringing in the audio from Flash / mp3 support )?
As well as loading FLVs, are you able to write them also with your build? This would be very helpful, as a lot of people may want to post their animations online using a generic FLV player ( in fact, some-one might even re-create a Blender skinned FLV Flash player for even easier usage / spreading the word of Blender
Re: [Sequencer] FFMPEG & Blender
Posted: Wed Jul 02, 2008 3:08 am
TheNut wrote:To enable AVISynth, simply:
1) Replace and use the latest version of FFMPEG...
2) Open blender\extern\ffmpeg\SConscript and update ...
3) Open blender\config\win32-mingw-config.py and update the LLIBS array ... Compile and have fun.
I have tried several times to compile SVN Blender using these instructions, and each time it compiles successfully, but selecting an .AVS file just yields "The selected file is not a movie or FFMPEG-support not compiled in!"
Are there any other things I should check for? Thanks!
(BTW, I am an experienced C/C++ software developer, but this is the first time I have attempted to compile Blender.)
Posted: Wed Jul 02, 2008 9:40 pm
TheNut wrote:In my build, I can load .flv files with audio as easily as I can avi or mpeg files.
TheNut, would you consider uploading your build(s) to GraphicAll.org? (Sorry about replying twice to this thread.)
Posted: Wed Jul 30, 2008 6:22 am
Hey all. Sorry for the delay here. I sort of fell out of sync ;\
Since the release of 2.46, I decided to use Visual Studio 2008 Express to produce the blender executable; including the aforementioned support for avisynth. I'm going to outline the instructions below for those who desire the same support. It is _incredibly_ easy for the blender devs to provide an updated version of the FFMPEG dynamic libraries hosted on SVN; otherwise others will have to go through the painstaking process to compile their own. In any case, here are the instructions.
1) Download Blender sources from SVN (I'm assuming you download to a folder called "trunk")
2) Download the Windows compiled libraries from SVN. Don't waste time or bandwidth downloading the Linux libraries since they are not needed. You'll be compiling them on Linux anyway (someone should trash those from SVN).
----- START: FFMPEG BUILD PROCESS -----
-- This whole chunk can be skipped if the SVN FFMPEG libraries are updated --
3) Download the latest FFMPEG sources from their SVN
4) You need MinGW and MSYS to compile FFMPEG. I won't go into details about these two (if you don't have much experience here, your life just got a whole lot more complicated ;). I will however let you know that in order to compile MSVC compatible libraries, you need to specify the path to MSVC includes and library folders. You do that by adding the following line to the top of your msys.bat file (MSVC 2008 Express example):
call "C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"
So now when you compile code in MSYS, a .lib and/or .lib/.dll MSVC compatible binaries will be created. If you do not do this, you will likely run into runtime errors/crashes with your Blender executable due to incompatibility between GCC libraries and MSVC.
5) Before you compile FFMPEG, make sure you compile the following 3rd party libraries and include them in your local/include and local/lib folder. I recommend you build these 3rd party libraries as static.
These libraries extend FFMPEG to support ac3, mp3, x264, and xvid. If you plan on just using the AVI Codec output feature, then you may not need to build these into FFMPEG; however, keep in mind that FFMPEG can multiplex audio with your video output. The AVI Codec option cannot do that, so FFMPEG is a more complete video-out solution.
6) Use the following configure command line to build your FFMPEG with the most useful options.
./configure --extra-cflags=-I/local/include --extra-ldflags=-L/local/lib --enable-shared --disable-static --enable-gpl --disable-network --enable-swscale --enable-w32threads --enable-liba52 --enable-avisynth --enable-libfaac --enable-libfaad --enable-libmp3lame --enable-libx264 --enable-libxvid --disable-vhook --disable-debug --disable-ffserver --disable-ffplay --enable-memalign-hack
The extra cflags and ldflags are used to tell FFMPEG where my 3rd party library include and lib files are located. If you do the standard ./configure, make, make install with those libraries, you can safely use my settings; otherwise change them. All the other options turn on extra support, including avisynth frameserving (--enable-avisynth)
7) Once the binaries are built, go into each FFMPEG folder and copy/paste the .lib/.dll files over into your trunk/lib/windows/ffmpeg/lib folder. Replace the garbage in there ;) Note, update the trunk/lib/windows/ffmpeg/include folder with the include files from your FFMPEG build as well. You might need to do a bit of leg work there since someone thought it would be funny to change FFMPEG's include directory structure. In Blender's main project file, it's interesting that some projects properly use FFMPEG's structure, while other internal projects do not.
----- END: FFMPEG BUILD PROCESS -----
8) To build blender, you must first:
a) Build extern projects (trunk/blender/extern/make/msvc_7_0/extern.sln)
b) Build intern projects (trunk/blender/intern/make/msvc_7_0/intern.sln)
c) Builder Blender (trunk/blender/projectfiles_vc7/blender/blender.sln
I recommend you go through each project and set maximum optimization. If you use MSVC 2008 Express like I did, you'll find the 2005 -> 2008 project conversion doesn't do a proper job on the optimization settings. Alas, this will require a bit more time on your part, but the time you save in renders will make up for it (a hell of a lot too!)
8a) Note: Intern building
a) The project Boolop will probably give a link error about missing special malloc and free calls. This is because someone forgot to set project priorities up. Just right click on the "guardedalloc" project and chose compile, then recompile the solution and everything will link properly. That's the quick fix, otherwise update the project dependencies in the main solution.
8b) Note: Blender building
a) If you're building Blender in MSVC 2008 Express, you need to update one of the library directories used to link against OpenEXR. Set the path to trunk\lib\windows\openexr\lib_vs2008. By default, it links against some other version, which will prevent you from linking.
Et voila! You now have a Blender you can call your very own (within reason ;). Again, AVISynth is a most powerful frameserver, with the ability to help stream HDV content into Blender without the conversion middle-process.
I hope this helps everyone out. I'm a bit tiered right now, so if anyone has questions on this, let me know.
Posted: Wed Jul 30, 2008 6:42 am
Just FYI, you can compile using the msvc compiler using SCons - should save you quite a bit of frustration. Just start a cmd.exe, run vcvarsall.bat in it, add Python to your path (and scons, if necessary) and issue 'scons' as a command.
Building FFMPEG just as described above. The --enable-avisynth is probably the most important part there
Posted: Wed Jul 30, 2008 12:45 pm
There's only one downfall to using SCons. I've noticed that it will not properly build the "AVI Codec" movie output renderer option. You can click on the "Set Codec" button, but the window will never pop-up and give you the option to choose. Probably something to do with GCC or WIN32 flags are not being respected with mingw. There's also some doggy functionality with FFMPEG and outputting certain movie formats compiling this way. 2.45 was fine with this, but I noticed in 2.46 most of the selectable formats choked on output. Just an FYI from my experience on that.
Posted: Wed Jul 30, 2008 9:18 pm
TheNut wrote:Probably something to do with GCC or WIN32 flags are not being respected with mingw. There's also some doggy functionality with FFMPEG and outputting certain movie formats compiling this way. 2.45 was fine with this, but I noticed in 2.46 most of the selectable formats choked on output. Just an FYI from my experience on that.
You can also build Blender with msvc/scons.
I didn't know that there were problems with the output - I haven't really tested all, since I generally use only mpeg2, which works just fine. This needs to be investigated further then.
Posted: Thu Jul 31, 2008 5:13 pm
Thanks for the information! I'm going to try to get this compiled ... in the meantime, could one of you fellows please upload your build to graphicall.org? That would be very helpful.
Posted: Sat Aug 02, 2008 6:00 pm
To spamagnet and anyone else interested, I've uploaded my build to http://graphicall.org/builds/builds/sho ... how&id=751
Posted: Mon Aug 04, 2008 3:25 pm
TheNut wrote:To spamagnet and anyone else interested, I've uploaded my build ...
Thank you!! I have tried compiling this thing several times, and I just can't get it right. I'll keep trying, but in the meantime, this build will be very helpful.
I have a new video camera (Canon Vixia HF100
) which records directly to AVC
. It's a terrific camera, but very few video editing packages have direct support for AVC. Blender does, but it doesn't quite get the frame rate/audio sync correctly. Being able to process it via Avisynth will be wonderful.
I wrote a Python/XSLT script that automatically generates the .avs files for each clip, and will pre-generate the proxy images for Blender. I might post this in case it would be useful to anyone.
Posted: Mon Aug 11, 2008 4:29 pm
Well, nobody has indicated the slightest interest, but I am determined to blithely ignore such discouraging facts! BlenderAVC
is my new free/open-source project which provides an efficient means of editing AVCHD footage in Blender. It uses the new build by TheNut (thanks!), AviSynth scripts and FFMPEG to pre-generate proxy images.