[vtkusers] [vtk-developers] FFMPEG latest release in VTK
Berk Geveci
berk.geveci at kitware.com
Tue Dec 1 16:36:52 EST 2009
Here is the patch to support latest ffmpeg (based on the ParaView tree
so you have to do patch -p2). Let me know what you guys think and if
there are no objections, I can commit it.
-berk
On Tue, Dec 1, 2009 at 4:29 PM, Arnaud GELAS
<arnaud_gelas at hms.harvard.edu> wrote:
> Hi Berk,
>
> we are definitively interested in these changes!
> When do you expect to commit this code?
>
> Arnaud
>
> On 12/01/2009 04:05 PM, Berk Geveci wrote:
>>
>> Is this backwards compatible (i.e. would it work with older version of
>> ffmpeg)? I have some local changes to make VTK work with the latest
>> ffmpeg as well as older versions. If yours is not backwards
>> compatible, I'll probably ignore it and commit my stuff. Otherwise, I
>> can compare the two codes and commit the one that looks better.
>>
>> -berk
>>
>> On Tue, Dec 1, 2009 at 3:47 PM, Nicolas Rannou
>> <Nicolas_Rannou at hms.harvard.edu> wrote:
>>
>>>
>>> Hello,
>>>
>>> so far, we have to use old versions of FFMPEG in order to make it usable
>>> with vtkFFMPEGWriter.cxx.
>>> here is a solution to use FFMPEG latest release in VTK (note that we
>>> checked
>>> with ffmpeg folks and we only used LGPL components).
>>>
>>> It has been tested on Linux and Mac so far.
>>>
>>> You only need to replace:
>>> - FindFFMPEG.cmake in /VTK/CMake/
>>> - CMakeLists.txt in /VTK/IO/
>>> - vtkFFMPEGWriter.cxx in /VTK/IO/
>>>
>>> Would it be possible to integrate it in VTK? Indeed, the previous FFMPEG
>>> working version is more than 2 years old and it would be nice to upgrade
>>> to
>>> the next versions. I am not sure if old versions of ffmpeg with vtk
>>> properly
>>> work on mac, and windows...
>>> Since VTK is a visualization tool, easily recording video using FFMPEG
>>> would
>>> be very usefull!!!
>>>
>>> Few days back, I also asked if it was possible to add:
>>> SET( VTK_USE_FFMPEG_ENCODER "@VTK_USE_FFMPEG_ENCODER@" ) in
>>> /VTK/VTKConfig.cmake.in
>>> indeed, it appears that this variable is missing.
>>>
>>> Do I need to open a request/bug on Mantis for that?
>>>
>>> Thanks,
>>>
>>> Nicolas
>>>
>>>
>>> Nicolas Rannou wrote:
>>>
>>>>
>>>> Mathieu Malaterre wrote:
>>>>
>>>>
>>>>>
>>>>> On Tue, Dec 1, 2009 at 3:36 PM, David E DeMarle
>>>>> <dave.demarle at kitware.com> wrote:
>>>>>
>>>>>
>>>>>>
>>>>>> The recommended way to get ffmpeg to work with vtk is to download the
>>>>>> old version of ffmpeg that is known to work with VTK from from
>>>>>> http://www.vtk.org/VTK/resources/software.html#addons, and follow the
>>>>>> directions in the README.
>>>>>>
>>>>>> If you need to use a modern ffmpeg then FFMPEG_INCLUDE should point to
>>>>>> a directory that has ffmpeg/avformat.h in it. If you can't find that
>>>>>> in /usr/include, find out where ubuntu's ffmpeg package puts it.Note,
>>>>>> some linux distributions have separate developer and user packages and
>>>>>> you generally have to install the developer package to get the header
>>>>>> files, but I do not suspect that is the problem in this case.
>>>>>>
>>>>>> You will also have to change the vtk ffmpeg exporter class to work
>>>>>> with the new ffmpeg library. I recall seeing a patch on the mailing
>>>>>> list or the bug tracker that does that, but I can't seem to track it
>>>>>> down right now.
>>>>>>
>>>>>>
>>>>>
>>>>> debian is using this one:
>>>>>
>>>>>
>>>>>
>>>>> http://patch-tracker.debian.org/patch/misc/view/vtk/5.2.1-13/IO/vtkFFMPEGWriter.cxx
>>>>>
>>>>> HTH
>>>>>
>>>>>
>>>>
>>>> We just fixed this in linux.
>>>> You should remplace
>>>>
>>>> -FindFFMPEG.cmake in VTK/CMake/
>>>> -CMakeLists in VTK/IO/
>>>> -vtkFFMPEGWriter.cxx in VTK/IO/
>>>>
>>>> We still have to check that it works properly in mac and windows...
>>>>
>>>> HTH
>>>>
>>>>
>>>
>>> IF(VTK_USE_METAIO)
>>> SET(_VTK_METAIO_LIB vtkmetaio)
>>> SET(_VTK_METAIO_SOURCES vtkMetaImageReader.cxx vtkMetaImageWriter.cxx )
>>> ELSE(VTK_USE_METAIO)
>>> SET(_VTK_METAIO_LIB)
>>> SET(_VTK_METAIO_SOURCES)
>>> ENDIF(VTK_USE_METAIO)
>>>
>>> SET(KIT IO)
>>> SET(UKIT IO)
>>> SET(KIT_TCL_LIBS vtkFilteringTCL)
>>> SET(KIT_PYTHON_LIBS vtkFilteringPythonD)
>>> SET(KIT_JAVA_LIBS vtkFilteringJava)
>>> SET(KIT_INTERFACE_LIBRARIES vtkFiltering)
>>> SET(KIT_LIBS vtkDICOMParser vtkNetCDF ${_VTK_METAIO_LIB} vtksqlite
>>> ${VTK_PNG_LIBRARIES} ${VTK_ZLIB_LIBRARIES} ${VTK_JPEG_LIBRARIES}
>>> ${VTK_TIFF_LIBRARIES} ${VTK_EXPAT_LIBRARIES}
>>> ${KWSYS_NAMESPACE})
>>>
>>> SET( Kit_SRCS
>>> vtkAbstractParticleWriter.cxx
>>> vtkAVSucdReader.cxx
>>> vtkBMPReader.cxx
>>> vtkBMPWriter.cxx
>>> vtkBYUReader.cxx
>>> vtkBYUWriter.cxx
>>> vtkBase64InputStream.cxx
>>> vtkBase64OutputStream.cxx
>>> vtkBase64Utilities.cxx
>>> vtkCGMWriter.cxx
>>> vtkChacoReader.cxx
>>> vtkCosmoReader.cxx
>>> vtkDEMReader.cxx
>>> vtkDICOMImageReader.cxx
>>> vtkDataCompressor.cxx
>>> vtkDataObjectReader.cxx
>>> vtkDataObjectWriter.cxx
>>> vtkDataReader.cxx
>>> vtkDataSetReader.cxx
>>> vtkDataSetWriter.cxx
>>> vtkDataWriter.cxx
>>> vtkDelimitedTextWriter.cxx
>>> vtkEnSight6BinaryReader.cxx
>>> vtkEnSight6Reader.cxx
>>> vtkEnSightGoldBinaryReader.cxx
>>> vtkEnSightGoldReader.cxx
>>> vtkEnSightMasterServerReader.cxx
>>> vtkEnSightReader.cxx
>>> vtkFLUENTReader.cxx
>>> vtkFacetWriter.cxx
>>> vtkGenericDataObjectReader.cxx
>>> vtkGenericDataObjectWriter.cxx
>>> vtkGESignaReader.cxx
>>> vtkGAMBITReader.cxx
>>> vtkGaussianCubeReader.cxx
>>> vtkGenericEnSightReader.cxx
>>> vtkGenericMovieWriter.cxx
>>> vtkGlobFileNames.cxx
>>> vtkGraphReader.cxx
>>> vtkGraphWriter.cxx
>>> vtkIVWriter.cxx
>>> vtkImageReader.cxx
>>> vtkImageReader2.cxx
>>> vtkImageReader2Collection.cxx
>>> vtkImageReader2Factory.cxx
>>> vtkImageWriter.cxx
>>> vtkInputStream.cxx
>>> vtkJavaScriptDataWriter.cxx
>>> vtkJPEGReader.cxx
>>> vtkJPEGWriter.cxx
>>> vtkMFIXReader.cxx
>>> vtkMaterialLibrary.cxx
>>> vtkMCubesReader.cxx
>>> vtkMCubesWriter.cxx
>>> vtkMedicalImageProperties.cxx
>>> vtkMedicalImageReader2.cxx
>>> ${_VTK_METAIO_SOURCES}
>>> vtkMINCImageAttributes.cxx
>>> vtkMINCImageReader.cxx
>>> vtkMINCImageWriter.cxx
>>> vtkMultiBlockPLOT3DReader.cxx
>>> vtkMoleculeReaderBase.cxx
>>> vtkNetCDFCOARDSReader.cxx
>>> vtkNetCDFReader.cxx
>>> vtkOBJReader.cxx
>>> vtkOutputStream.cxx
>>> vtkOpenFOAMReader.cxx
>>> vtkPDBReader.cxx
>>> vtkPLOT3DReader.cxx
>>> vtkPLY.cxx
>>> vtkPLYReader.cxx
>>> vtkPLYWriter.cxx
>>> vtkPNGReader.cxx
>>> vtkPNGWriter.cxx
>>> vtkPNMReader.cxx
>>> vtkPNMWriter.cxx
>>> vtkParticleReader.cxx
>>> vtkPolyDataReader.cxx
>>> vtkPolyDataWriter.cxx
>>> vtkPostScriptWriter.cxx
>>> vtkRectilinearGridReader.cxx
>>> vtkRectilinearGridWriter.cxx
>>> vtkRTXMLPolyDataReader.cxx
>>> vtkRowQuery.cxx
>>> vtkSESAMEReader.cxx
>>> vtkShaderCodeLibrary.cxx
>>> vtkSLACParticleReader.cxx
>>> vtkSLACReader.cxx
>>> vtkSQLDatabase.cxx
>>> vtkSQLDatabaseSchema.cxx
>>> vtkSQLiteDatabase.cxx
>>> vtkSQLiteQuery.cxx
>>> vtkSQLQuery.cxx
>>> vtkSLCReader.cxx
>>> vtkSTLReader.cxx
>>> vtkSTLWriter.cxx
>>> vtkSimplePointsReader.cxx
>>> vtkSortFileNames.cxx
>>> vtkStructuredGridReader.cxx
>>> vtkStructuredGridWriter.cxx
>>> vtkStructuredPointsReader.cxx
>>> vtkStructuredPointsWriter.cxx
>>> vtkTableReader.cxx
>>> vtkTableWriter.cxx
>>> vtkTecplotReader.cxx
>>> vtkTIFFReader.cxx
>>> vtkTIFFWriter.cxx
>>> vtkTreeReader.cxx
>>> vtkTreeWriter.cxx
>>> vtkUGFacetReader.cxx
>>> vtkUnstructuredGridReader.cxx
>>> vtkUnstructuredGridWriter.cxx
>>> vtkVolume16Reader.cxx
>>> vtkVolumeReader.cxx
>>> vtkWriter.cxx
>>> vtkXMLCompositeDataReader.cxx
>>> vtkXMLDataParser.cxx
>>> vtkXMLDataReader.cxx
>>> vtkXMLDataSetWriter.cxx
>>> vtkXMLFileReadTester.cxx
>>> vtkXMLHierarchicalBoxDataReader.cxx
>>> vtkXMLHierarchicalDataReader.cxx
>>> vtkXMLImageDataReader.cxx
>>> vtkXMLImageDataWriter.cxx
>>> vtkXMLHyperOctreeReader.cxx
>>> vtkXMLHyperOctreeWriter.cxx
>>> vtkXMLMaterial.cxx
>>> vtkXMLMaterialParser.cxx
>>> vtkXMLMaterialReader.cxx
>>> vtkXMLMultiBlockDataReader.cxx
>>> vtkXMLMultiGroupDataReader.cxx
>>> vtkXMLCompositeDataWriter.cxx
>>> vtkXMLMultiBlockDataWriter.cxx
>>> vtkXMLHierarchicalBoxDataWriter.cxx
>>> vtkXMLPDataReader.cxx
>>> vtkXMLPDataSetWriter.cxx
>>> vtkXMLPDataWriter.cxx
>>> vtkXMLPImageDataReader.cxx
>>> vtkXMLPImageDataWriter.cxx
>>> vtkXMLPPolyDataReader.cxx
>>> vtkXMLPPolyDataWriter.cxx
>>> vtkXMLPRectilinearGridReader.cxx
>>> vtkXMLPRectilinearGridWriter.cxx
>>> vtkXMLPStructuredDataReader.cxx
>>> vtkXMLPStructuredDataWriter.cxx
>>> vtkXMLPStructuredGridReader.cxx
>>> vtkXMLPStructuredGridWriter.cxx
>>> vtkXMLPUnstructuredDataReader.cxx
>>> vtkXMLPUnstructuredDataWriter.cxx
>>> vtkXMLPUnstructuredGridReader.cxx
>>> vtkXMLPUnstructuredGridWriter.cxx
>>> vtkXMLParser.cxx
>>> vtkXMLPolyDataReader.cxx
>>> vtkXMLPolyDataWriter.cxx
>>> vtkXMLReader.cxx
>>> vtkXMLRectilinearGridReader.cxx
>>> vtkXMLRectilinearGridWriter.cxx
>>> vtkXMLShader.cxx
>>> vtkXMLStructuredDataReader.cxx
>>> vtkXMLStructuredDataWriter.cxx
>>> vtkXMLStructuredGridReader.cxx
>>> vtkXMLStructuredGridWriter.cxx
>>> vtkXMLUnstructuredDataReader.cxx
>>> vtkXMLUnstructuredDataWriter.cxx
>>> vtkXMLUnstructuredGridReader.cxx
>>> vtkXMLUnstructuredGridWriter.cxx
>>> vtkXMLUtilities.cxx
>>> vtkXMLWriter.cxx
>>> vtkXMLWriterC.cxx
>>> vtkXYZMolReader.cxx
>>> vtkZLibDataCompressor.cxx
>>> )
>>>
>>> SET_SOURCE_FILES_PROPERTIES(
>>> vtkAbstractParticleWriter
>>> vtkDataCompressor
>>> vtkEnSightReader
>>> vtkGenericMovieWriter
>>> vtkMoleculeReaderBase
>>> vtkRowQuery
>>> vtkSQLDatabase
>>> vtkSQLQuery
>>> vtkVolumeReader
>>> vtkWriter
>>> vtkXMLCompositeDataReader.cxx
>>> vtkXMLCompositeDataWriter
>>> vtkXMLDataReader
>>> vtkXMLPDataReader
>>> vtkXMLPDataWriter
>>> vtkXMLPStructuredDataReader
>>> vtkXMLPStructuredDataWriter
>>> vtkXMLPUnstructuredDataReader
>>> vtkXMLPUnstructuredDataWriter
>>> vtkXMLReader
>>> vtkXMLStructuredDataReader
>>> vtkXMLStructuredDataWriter
>>> vtkXMLUnstructuredDataReader
>>> vtkXMLUnstructuredDataWriter
>>> vtkXMLWriter
>>> ABSTRACT
>>> )
>>>
>>> INSTALL(FILES
>>> ${CMAKE_CURRENT_SOURCE_DIR}/vtkMINC.h
>>> DESTINATION ${VTK_INSTALL_INCLUDE_DIR_CM24}
>>> COMPONENT Development
>>> )
>>>
>>> # Set up dependencies on the header files generated by
>>> # Utilities/MaterialLibrary
>>> SET_SOURCE_FILES_PROPERTIES(vtkXMLShader.cxx PROPERTIES OBJECT_DEPENDS
>>> ${MATERIAL_LIBRARY_SHADER_MACRO_HEADER})
>>> SET_SOURCE_FILES_PROPERTIES(vtkXMLMaterial.cxx PROPERTIES OBJECT_DEPENDS
>>> ${MATERIAL_LIBRARY_MATERIAL_MACRO_HEADER})
>>>
>>> IF(WIN32)
>>> IF(VTK_USE_VIDEO_FOR_WINDOWS)
>>> SET(Kit_SRCS ${Kit_SRCS} vtkAVIWriter.cxx)
>>> SET(KIT_LIBS ${KIT_LIBS} vfw32)
>>> ENDIF(VTK_USE_VIDEO_FOR_WINDOWS)
>>> ENDIF(WIN32)
>>>
>>>
>>> #-----------------------------------------------------------------------------
>>> # FFMPEG
>>> # If the ffmpeg library is available, compile vtkFFMPEGWriter.
>>> IF (VTK_USE_FFMPEG_ENCODER)
>>> INCLUDE_DIRECTORIES(${FFMPEG_INCLUDE_DIR})
>>> SET(Kit_SRCS ${Kit_SRCS} vtkFFMPEGWriter.cxx)
>>> SET(KIT_LIBS ${KIT_LIBS} ${FFMPEG_LIBRARIES}
>>> # ${FFMPEG_avformat_LIBRARY}
>>> # ${FFMPEG_avcodec_LIBRARY}
>>> # ${FFMPEG_avutil_LIBRARY})
>>> )
>>> ENDIF (VTK_USE_FFMPEG_ENCODER)
>>>
>>>
>>> #-----------------------------------------------------------------------------
>>> # MPEG2
>>> #
>>> # Only include the vtkMPEG2Writer if the user has explicitly turned on
>>> # VTK_USE_MPEG2_ENCODER. If so, user should also have set
>>> # vtkMPEG2Encode_INCLUDE_PATH and vtkMPEG2Encode_LIBRARIES.
>>> #
>>> IF (VTK_USE_MPEG2_ENCODER)
>>> INCLUDE_DIRECTORIES(${vtkMPEG2Encode_INCLUDE_PATH})
>>> SET(Kit_SRCS ${Kit_SRCS} vtkMPEG2Writer.cxx)
>>> SET(KIT_LIBS ${KIT_LIBS} ${vtkMPEG2Encode_LIBRARIES})
>>> ENDIF (VTK_USE_MPEG2_ENCODER)
>>>
>>>
>>> #-----------------------------------------------------------------------------
>>> # PostgreSQL
>>> # build the PostgreSQL database backend (if the PostgresSQL and pqxx
>>> libraries are available)
>>> #
>>> OPTION( VTK_USE_POSTGRES "Build the PostgreSQL driver for
>>> vtkSQLDatabase."
>>> OFF)
>>> MARK_AS_ADVANCED(VTK_USE_POSTGRES)
>>> IF ( VTK_USE_POSTGRES )
>>> FIND_PACKAGE( POSTGRES REQUIRED )
>>> IF ( BUILD_TESTING )
>>> SET ( VTK_PSQL_TEST_URL "" CACHE STRING "A URL for a PostgreSQL server
>>> of
>>> the form psql://[[username[:password]@]hostname[:port]]/[dbname]" )
>>> ENDIF ( BUILD_TESTING )
>>> ENDIF ( VTK_USE_POSTGRES )
>>> #
>>> # Only include the Postgres backend if the user has explicitly turned on
>>> # VTK_USE_POSTGRES. If so, user must also have set POSTGRES_LIBRARIES
>>> # and POSTGRES_INCLUDE_DIRECTORIES to valid values.
>>> IF ( VTK_USE_POSTGRES AND POSTGRES_FOUND )
>>> INCLUDE_DIRECTORIES( ${POSTGRES_INCLUDE_DIRECTORIES} )
>>> SET( Kit_SRCS
>>> ${Kit_SRCS}
>>> vtkPostgreSQLDatabase.cxx
>>> vtkPostgreSQLQuery.cxx
>>> )
>>> LINK_LIBRARIES( ${POSTGRES_LIBRARIES} )
>>> ENDIF ( VTK_USE_POSTGRES AND POSTGRES_FOUND )
>>>
>>>
>>> #-----------------------------------------------------------------------------
>>> # MySQL
>>> # build the MySQL database backend (if the MySQL libraries are available)
>>> #
>>> OPTION( VTK_USE_MYSQL "Build the MySQL driver for vtkSQLDatabase." OFF)
>>> MARK_AS_ADVANCED(VTK_USE_MYSQL)
>>> IF ( VTK_USE_MYSQL )
>>> FIND_PACKAGE( MySQL REQUIRED )
>>> IF ( BUILD_TESTING )
>>> SET ( VTK_MYSQL_TEST_URL "" CACHE STRING "A URL for a MySQL server of
>>> the
>>> form mysql://[[username[:password]@]hostname[:port]]/[dbname]" )
>>> ENDIF ( BUILD_TESTING )
>>> ENDIF ( VTK_USE_MYSQL )
>>> #
>>> # Only include the MySQL backend if the user has explicitly turned on
>>> # VTK_USE_MYSQL. If so, user must also have set MYSQL_LIBRARIES
>>> # and MYSQL_INCLUDE_DIRECTORIES to valid values.
>>> IF ( VTK_USE_MYSQL AND MYSQL_FOUND )
>>> INCLUDE_DIRECTORIES( ${MYSQL_INCLUDE_DIRECTORIES} )
>>> SET( Kit_SRCS
>>> ${Kit_SRCS}
>>> vtkMySQLDatabase.cxx
>>> vtkMySQLQuery.cxx
>>> )
>>> LINK_LIBRARIES( ${MYSQL_LIBRARY} ${MYSQL_EXTRA_LIBRARIES} )
>>> ENDIF ( VTK_USE_MYSQL AND MYSQL_FOUND )
>>>
>>>
>>> #-----------------------------------------------------------------------------
>>> # ODBC
>>> # Build the ODBC database backend only if ODBC driver manager is
>>> available
>>> #
>>> OPTION (VTK_USE_ODBC "Build the ODBC database interface" OFF)
>>> MARK_AS_ADVANCED(VTK_USE_ODBC)
>>> IF ( VTK_USE_ODBC )
>>> FIND_PACKAGE( ODBC REQUIRED )
>>> IF ( BUILD_TESTING )
>>> SET ( VTK_ODBC_TEST_DSN "" CACHE STRING "A data source name (DSN) for
>>> an
>>> ODBC database connection to use for testing." )
>>> ENDIF ( BUILD_TESTING )
>>> ENDIF ( VTK_USE_ODBC )
>>>
>>> IF ( VTK_USE_ODBC AND ODBC_FOUND )
>>> INCLUDE_DIRECTORIES( ${ODBC_INCLUDE_DIRECTORIES} )
>>> SET( Kit_SRCS
>>> ${Kit_SRCS}
>>> vtkODBCDatabase.cxx
>>> vtkODBCQuery.cxx
>>> )
>>> LINK_LIBRARIES( ${ODBC_LIBRARIES} )
>>> # Note: Strange things happen on 64-bit machines. We must compile
>>> # ODBC code with -DBUILD_REAL_64_BIT_MODE in order to have the driver
>>> # work properly.
>>> INCLUDE(CheckTypeSize)
>>> CHECK_TYPE_SIZE("unsigned long" CMAKE_SIZEOF_LONG)
>>> IF ( "${CMAKE_SIZEOF_LONG}" STREQUAL "8" )
>>> # MESSAGE( STATUS "Building ODBC driver with 64-bit flag." )
>>> ADD_DEFINITIONS( -DBUILD_REAL_64_BIT_MODE )
>>> ENDIF ( "${CMAKE_SIZEOF_LONG}" STREQUAL "8" )
>>> ENDIF ( VTK_USE_ODBC AND ODBC_FOUND )
>>>
>>>
>>> #-----------------------------------------------------------------------------
>>> # Add these classes only if vtkTypeUInt64Array exists
>>> IF(VTK_HAS_UINT64_ARRAY)
>>> SET(Kit_SRCS
>>> ${Kit_SRCS}
>>> vtkRowQueryToTable.cxx
>>> )
>>> ENDIF(VTK_HAS_UINT64_ARRAY)
>>>
>>>
>>>
>>> #-----------------------------------------------------------------------------
>>> SET_SOURCE_FILES_PROPERTIES(
>>> vtkPLY
>>> vtkXMLWriterC
>>> WRAP_EXCLUDE
>>> )
>>>
>>>
>>> #-----------------------------------------------------------------------------
>>> # N-WAY ARRAYS READER AND WRITER
>>> IF(VTK_USE_N_WAY_ARRAYS)
>>>
>>> SET(Kit_SRCS
>>> ${Kit_SRCS}
>>> vtkArrayReader.cxx
>>> vtkArrayWriter.cxx
>>> )
>>>
>>> ENDIF(VTK_USE_N_WAY_ARRAYS)
>>>
>>> #-----------------------------------------------------------------------------
>>>
>>> SET(Kit_EXTRA_SRCS)
>>> SET(Kit_EXTRA_CMDS)
>>> SET(Kit_TCL_EXTRA_SRCS)
>>> SET(Kit_PYTHON_EXTRA_SRCS)
>>> SET(Kit_JAVA_EXTRA_SRCS)
>>> SET(KIT_TCL_DEPS)
>>> SET(KIT_PYTHON_DEPS)
>>> SET(KIT_JAVA_DEPS)
>>>
>>>
>>> #-----------------------------------------------------------------------------
>>> # Include CMake code common to all kits.
>>> INCLUDE(${VTK_CMAKE_DIR}/KitCommonBlock.cmake)
>>>
>>> #-----------------------------------------------------------------------------
>>> # Add target dependency.
>>> ADD_DEPENDENCIES(vtkIO
>>> vtkMaterialLibraryConfiguredFiles)
>>>
>>> #-----------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the VTK FAQ at:
>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>>>
>>>
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtk-developers
>>
>>
>
>
-------------- next part --------------
commit 1c67750864cd4bf620092764c5dfedca93435e8e
Author: Berk Geveci <berk at tatooine.kitwarein.com>
Date: Thu Sep 10 10:21:07 2009 -0400
ENH: Added support for multiple versions of ffmpeg.
diff --git a/VTK/CMake/FindFFMPEG.cmake b/VTK/CMake/FindFFMPEG.cmake
index d5e0d02..6f34f7b 100644
--- a/VTK/CMake/FindFFMPEG.cmake
+++ b/VTK/CMake/FindFFMPEG.cmake
@@ -61,6 +61,11 @@ FIND_LIBRARY(FFMPEG_gsm_LIBRARY gsm
/usr/lib
)
+FIND_LIBRARY(FFMPEG_swscale_LIBRARY swscale
+ /usr/local/lib
+ /usr/lib
+)
+
FIND_LIBRARY(FFMPEG_z_LIBRARY z
/usr/local/lib
/usr/lib
@@ -85,6 +90,7 @@ IF(FFMPEG_INCLUDE_DIR)
${FFMPEG_theora_LIBRARY}
${FFMPEG_dts_LIBRARY}
${FFMPEG_gsm_LIBRARY}
+ ${FFMPEG_swscale_LIBRARY}
${FFMPEG_z_LIBRARY})
ENDIF(FFMPEG_avutil_LIBRARY)
ENDIF(FFMPEG_avcodec_LIBRARY)
@@ -102,5 +108,6 @@ MARK_AS_ADVANCED(
FFMPEG_theora_LIBRARY
FFMPEG_dts_LIBRARY
FFMPEG_gsm_LIBRARY
+ FFMPEG_swscale_LIBRARY
FFMPEG_z_LIBRARY
)
diff --git a/VTK/CMake/vtkFFMPEGTestAvAlloc.cxx b/VTK/CMake/vtkFFMPEGTestAvAlloc.cxx
new file mode 100644
index 0000000..caf3a0c
--- /dev/null
+++ b/VTK/CMake/vtkFFMPEGTestAvAlloc.cxx
@@ -0,0 +1,13 @@
+extern "C" {
+#ifdef HAS_OLD_HEADER
+# include <ffmpeg/avformat.h>
+#else
+# include <libavformat/avformat.h>
+#endif
+}
+
+int main()
+{
+ avformat_alloc_context();
+ return 0;
+}
\ No newline at end of file
diff --git a/VTK/CMake/vtkFFMPEGTestImgConvert.cxx b/VTK/CMake/vtkFFMPEGTestImgConvert.cxx
new file mode 100644
index 0000000..4662208
--- /dev/null
+++ b/VTK/CMake/vtkFFMPEGTestImgConvert.cxx
@@ -0,0 +1,15 @@
+extern "C" {
+#ifdef HAS_OLD_HEADER
+# include <ffmpeg/avcodec.h>
+#else
+# include <libavcodec/avcodec.h>
+#endif
+}
+
+int main()
+{
+ img_convert(0, PIX_FMT_RGB24,
+ 0, PIX_FMT_RGB24,
+ 0, 0);
+ return 0;
+}
diff --git a/VTK/CMake/vtkFFMPEGTestURLFClose.cxx b/VTK/CMake/vtkFFMPEGTestURLFClose.cxx
new file mode 100644
index 0000000..0bf4314
--- /dev/null
+++ b/VTK/CMake/vtkFFMPEGTestURLFClose.cxx
@@ -0,0 +1,14 @@
+extern "C" {
+#ifdef HAS_OLD_HEADER
+# include <ffmpeg/avformat.h>
+#else
+# include <libavformat/avformat.h>
+#endif
+}
+
+int main()
+{
+ AVFormatContext *ctx;
+ url_fclose(&ctx->pb);
+ return 0;
+}
diff --git a/VTK/CMake/vtkTestFFMPEG.cmake b/VTK/CMake/vtkTestFFMPEG.cmake
new file mode 100644
index 0000000..398ba73
--- /dev/null
+++ b/VTK/CMake/vtkTestFFMPEG.cmake
@@ -0,0 +1,106 @@
+IF (FFMPEG_INCLUDE_DIR)
+ IF("VTK_FFMPEG_HAS_OLD_HEADER" MATCHES "^VTK_FFMPEG_HAS_OLD_HEADER$" OR NOT "VTK_FFMPEG_CACHED_INCLUDE" MATCHES "^${FFMPEG_INCLUDE_DIR}$")
+ IF (EXISTS ${FFMPEG_INCLUDE_DIR}/ffmpeg)
+ SET(VTK_FFMPEG_HAS_OLD_HEADER "TRUE" CACHE INTERNAL "Is the FFMPEG include in the old location" FORCE)
+ ELSE (EXISTS ${FFMPEG_INCLUDE_DIR}/ffmpeg)
+ SET(VTK_FFMPEG_HAS_OLD_HEADER "FALSE" CACHE INTERNAL "Is the FFMPEG include in the old location" FORCE)
+ ENDIF (EXISTS ${FFMPEG_INCLUDE_DIR}/ffmpeg)
+ IF (VTK_FFMPEG_HAS_OLD_HEADER)
+ MESSAGE(STATUS "Checking if FFMPEG uses old style header files - yes")
+ ELSE (VTK_FFMPEG_HAS_OLD_HEADER)
+ MESSAGE(STATUS "Checking if FFMPEG uses old style header files - no")
+ ENDIF (VTK_FFMPEG_HAS_OLD_HEADER)
+ SET(VTK_FFMPEG_CACHED_INCLUDE ${FFMPEG_INCLUDE_DIR} CACHE INTERNAL "Previous value of FFMPEG_INCLUDE_DIR" FORCE)
+ ENDIF("VTK_FFMPEG_HAS_OLD_HEADER" MATCHES "^VTK_FFMPEG_HAS_OLD_HEADER$" OR NOT "VTK_FFMPEG_CACHED_INCLUDE" MATCHES "^${FFMPEG_INCLUDE_DIR}$")
+
+ IF("VTK_FFMPEG_HAS_IMG_CONVERT" MATCHES "^VTK_FFMPEG_HAS_IMG_CONVERT$" OR NOT "VTK_FFMPEG_CACHED_AVCODEC" MATCHES "^${FFMPEG_avcodec_LIBRARY}$")
+ IF(VTK_FFMPEG_HAS_OLD_HEADER)
+ SET(VTK_FFMPEG_CDEFS "HAS_OLD_HEADER")
+ ELSE(VTK_FFMPEG_HAS_OLD_HEADER)
+ SET(VTK_FFMPEG_CDEFS "HAS_NEW_HEADER")
+ ENDIF(VTK_FFMPEG_HAS_OLD_HEADER)
+
+ IF(FFMPEG_avcodec_LIBRARY)
+ TRY_COMPILE(VTK_FFMPEG_HAS_IMG_CONVERT
+ ${VTK_BINARY_DIR}/CMakeTmp
+ ${VTK_CMAKE_DIR}/vtkFFMPEGTestImgConvert.cxx
+ CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${FFMPEG_INCLUDE_DIR}"
+ "-DLINK_LIBRARIES:STRING=${FFMPEG_avcodec_LIBRARY}"
+ -DCOMPILE_DEFINITIONS:STRING=-D${VTK_FFMPEG_CDEFS}
+ OUTPUT_VARIABLE OUTPUT)
+ IF(VTK_FFMPEG_HAS_IMG_CONVERT)
+ MESSAGE(STATUS "Checking if FFMPEG has img_convert - found")
+ FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Checking if FFMPEG has img_convert (passed):\n"
+ "${OUTPUT}\n\n")
+ ELSE(VTK_FFMPEG_HAS_IMG_CONVERT)
+ MESSAGE(STATUS "Checking if FFMPEG has img_convert - not found")
+ FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Checking if FFMPEG has img_convert (failed):\n"
+ "${OUTPUT}\n\n")
+ ENDIF(VTK_FFMPEG_HAS_IMG_CONVERT)
+ ENDIF(FFMPEG_avcodec_LIBRARY)
+ SET(VTK_FFMPEG_CACHED_AVCODEC ${FFMPEG_avcodec_LIBRARY} CACHE INTERNAL "Previous value of FFMPEG_avcodec_LIBRARY" FORCE)
+ ENDIF("VTK_FFMPEG_HAS_IMG_CONVERT" MATCHES "^VTK_FFMPEG_HAS_IMG_CONVERT$" OR NOT "VTK_FFMPEG_CACHED_AVCODEC" MATCHES "^${FFMPEG_avcodec_LIBRARY}$")
+
+ IF("VTK_FFMPEG_OLD_URL_FCLOSE" MATCHES "^VTK_FFMPEG_OLD_URL_FCLOSE$" OR NOT "VTK_FFMPEG_CACHED_AVFORMAT" MATCHES "^${FFMPEG_avformat_LIBRARY}$")
+ IF(VTK_FFMPEG_HAS_OLD_HEADER)
+ SET(VTK_FFMPEG_CDEFS "HAS_OLD_HEADER")
+ ELSE(VTK_FFMPEG_HAS_OLD_HEADER)
+ SET(VTK_FFMPEG_CDEFS "HAS_NEW_HEADER")
+ ENDIF(VTK_FFMPEG_HAS_OLD_HEADER)
+
+ IF(FFMPEG_avformat_LIBRARY)
+ TRY_COMPILE(VTK_FFMPEG_OLD_URL_FCLOSE
+ ${VTK_BINARY_DIR}/CMakeTmp
+ ${VTK_CMAKE_DIR}/vtkFFMPEGTestURLFClose.cxx
+ CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${FFMPEG_INCLUDE_DIR}"
+ -DCOMPILE_DEFINITIONS:STRING=-D${VTK_FFMPEG_CDEFS}
+ "-DLINK_LIBRARIES:STRING=${FFMPEG_avformat_LIBRARY}"
+ OUTPUT_VARIABLE OUTPUT)
+
+ IF(VTK_FFMPEG_OLD_URL_FCLOSE)
+ MESSAGE(STATUS "Checking if FFMPEG uses old API for url_fclose - found")
+ FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Checking if FFMPEG uses old API for url_fclose (passed):\n"
+ "${OUTPUT}\n\n")
+ ELSE(VTK_FFMPEG_OLD_URL_FCLOSE)
+ MESSAGE(STATUS "Checking if FFMPEG uses old API for url_fclose - not found")
+ FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Checking if FFMPEG uses old API for url_fclose (failed):\n"
+ "${OUTPUT}\n\n")
+ ENDIF(VTK_FFMPEG_OLD_URL_FCLOSE)
+ ENDIF(FFMPEG_avformat_LIBRARY)
+ ENDIF("VTK_FFMPEG_OLD_URL_FCLOSE" MATCHES "^VTK_FFMPEG_OLD_URL_FCLOSE$" OR NOT "VTK_FFMPEG_CACHED_AVFORMAT" MATCHES "^${FFMPEG_avformat_LIBRARY}$")
+
+ IF("VTK_FFMPEG_NEW_ALLOC" MATCHES "^VTK_FFMPEG_NEW_ALLOC$" OR NOT "VTK_FFMPEG_CACHED_AVFORMAT" MATCHES "^${FFMPEG_avformat_LIBRARY}$")
+ IF(VTK_FFMPEG_HAS_OLD_HEADER)
+ SET(VTK_FFMPEG_CDEFS "HAS_OLD_HEADER")
+ ELSE(VTK_FFMPEG_HAS_OLD_HEADER)
+ SET(VTK_FFMPEG_CDEFS "HAS_NEW_HEADER")
+ ENDIF(VTK_FFMPEG_HAS_OLD_HEADER)
+
+ IF(FFMPEG_avformat_LIBRARY)
+ TRY_COMPILE(VTK_FFMPEG_NEW_ALLOC
+ ${VTK_BINARY_DIR}/CMakeTmp
+ ${VTK_CMAKE_DIR}/vtkFFMPEGTestAvAlloc.cxx
+ CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${FFMPEG_INCLUDE_DIR}"
+ -DCOMPILE_DEFINITIONS:STRING=-D${VTK_FFMPEG_CDEFS}
+ "-DLINK_LIBRARIES:STRING=${FFMPEG_avformat_LIBRARY}"
+ OUTPUT_VARIABLE OUTPUT)
+
+ IF(VTK_FFMPEG_NEW_ALLOC)
+ MESSAGE(STATUS "Checking if FFMPEG has avformat_alloc_context - found")
+ FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Checking if FFMPEG has avformat_alloc_context (passed):\n"
+ "${OUTPUT}\n\n")
+ ELSE(VTK_FFMPEG_NEW_ALLOC)
+ MESSAGE(STATUS "Checking if FFMPEG has avformat_alloc_context - not found")
+ FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Checking if FFMPEG has avformat_alloc_context (failed):\n"
+ "${OUTPUT}\n\n")
+ ENDIF(VTK_FFMPEG_NEW_ALLOC)
+ ENDIF(FFMPEG_avformat_LIBRARY)
+ SET(VTK_FFMPEG_CACHED_AVFORMAT ${FFMPEG_avformat_LIBRARY} CACHE INTERNAL "Previous value of FFMPEG_avformat_LIBRARY" FORCE)
+ ENDIF("VTK_FFMPEG_NEW_ALLOC" MATCHES "^VTK_FFMPEG_NEW_ALLOC$" OR NOT "VTK_FFMPEG_CACHED_AVFORMAT" MATCHES "^${FFMPEG_avformat_LIBRARY}$")
+ENDIF (FFMPEG_INCLUDE_DIR)
diff --git a/VTK/CMakeLists.txt b/VTK/CMakeLists.txt
index 2ec6011..496acfc 100644
--- a/VTK/CMakeLists.txt
+++ b/VTK/CMakeLists.txt
@@ -876,6 +876,12 @@ OPTION (VTK_USE_FFMPEG_ENCODER "If the FFMPEG library is available, should VTK u
MARK_AS_ADVANCED(VTK_USE_FFMPEG_ENCODER)
IF (VTK_USE_FFMPEG_ENCODER)
INCLUDE(${VTK_CMAKE_DIR}/FindFFMPEG.cmake OPTIONAL)
+ MARK_AS_ADVANCED(CLEAR
+ FFMPEG_INCLUDE_DIR
+ FFMPEG_avformat_LIBRARY
+ FFMPEG_avcodec_LIBRARY
+ FFMPEG_avutil_LIBRARY
+ )
ENDIF (VTK_USE_FFMPEG_ENCODER)
#-----------------------------------------------------------------------------
diff --git a/VTK/IO/CMakeLists.txt b/VTK/IO/CMakeLists.txt
index a725c54..46eeab3 100644
--- a/VTK/IO/CMakeLists.txt
+++ b/VTK/IO/CMakeLists.txt
@@ -251,12 +251,25 @@ ENDIF(WIN32)
# FFMPEG
# If the ffmpeg library is available, compile vtkFFMPEGWriter.
IF (VTK_USE_FFMPEG_ENCODER)
+ INCLUDE(${VTK_CMAKE_DIR}/vtkTestFFMPEG.cmake)
+
+ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/vtkFFMPEGConfig.h.in
+ ${CMAKE_CURRENT_BINARY_DIR}/vtkFFMPEGConfig.h @ONLY)
+ INCLUDE_DIRECTORIES(${VTK_BINARY_DIR}/IO)
+ INSTALL(FILES vtkFFMPEGConfig.h
+ DESTINATION ${VTK_INSTALL_INCLUDE_DIR_CM24}
+ COMPONENT Development)
+
INCLUDE_DIRECTORIES(${FFMPEG_INCLUDE_DIR})
SET(Kit_SRCS ${Kit_SRCS} vtkFFMPEGWriter.cxx)
SET(KIT_LIBS ${KIT_LIBS}
${FFMPEG_avformat_LIBRARY}
${FFMPEG_avcodec_LIBRARY}
${FFMPEG_avutil_LIBRARY})
+ IF (NOT VTK_FFMPEG_HAS_IMG_CONVERT)
+ SET(KIT_LIBS ${KIT_LIBS}
+ ${FFMPEG_swscale_LIBRARY})
+ ENDIF (NOT VTK_FFMPEG_HAS_IMG_CONVERT)
ENDIF (VTK_USE_FFMPEG_ENCODER)
#-----------------------------------------------------------------------------
diff --git a/VTK/IO/vtkFFMPEGConfig.h.in b/VTK/IO/vtkFFMPEGConfig.h.in
new file mode 100644
index 0000000..19d8598
--- /dev/null
+++ b/VTK/IO/vtkFFMPEGConfig.h.in
@@ -0,0 +1,25 @@
+/*=========================================================================
+
+ Program: Visualization Toolkit
+ Module: $RCSfile$
+
+ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
+ All rights reserved.
+ See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notice for more information.
+
+=========================================================================*/
+#ifndef __vtkFFMPEGConfig_h
+#define __vtkFFMPEGConfig_h
+
+/* This header is configured by VTK's build process. */
+
+#cmakedefine VTK_FFMPEG_HAS_OLD_HEADER
+#cmakedefine VTK_FFMPEG_OLD_URL_FCLOSE
+#cmakedefine VTK_FFMPEG_HAS_IMG_CONVERT
+#cmakedefine VTK_FFMPEG_NEW_ALLOC
+
+#endif
diff --git a/VTK/IO/vtkFFMPEGWriter.cxx b/VTK/IO/vtkFFMPEGWriter.cxx
index abda3b6..f6c85b1 100644
--- a/VTK/IO/vtkFFMPEGWriter.cxx
+++ b/VTK/IO/vtkFFMPEGWriter.cxx
@@ -18,9 +18,18 @@
#include "vtkImageData.h"
#include "vtkObjectFactory.h"
#include "vtkErrorCode.h"
+#include "vtkFFMPEGConfig.h"
extern "C" {
-#include <ffmpeg/avformat.h>
+#ifdef VTK_FFMPEG_HAS_OLD_HEADER
+# include <ffmpeg/avformat.h>
+#else
+# include <libavformat/avformat.h>
+#endif
+
+#ifndef VTK_FFMPEG_HAS_IMG_CONVERT
+# include <libswscale/swscale.h>
+#endif
}
//---------------------------------------------------------------------------
@@ -98,7 +107,11 @@ int vtkFFMPEGWriterInternal::Start()
av_register_all();
//create the format context that wraps all of the media output structures
+#ifdef VTK_FFMPEG_NEW_ALLOC
+ this->avFormatContext = avformat_alloc_context();
+#else
this->avFormatContext = av_alloc_format_context();
+#endif
if (!this->avFormatContext)
{
vtkGenericWarningMacro (<< "Coult not open the format context.");
@@ -256,10 +269,39 @@ int vtkFFMPEGWriterInternal::Write(vtkImageData *id)
}
//convert that to YUV for input to the codec
+#ifdef VTK_FFMPEG_HAS_IMG_CONVERT
img_convert((AVPicture *)this->yuvOutput, cc->pix_fmt,
(AVPicture *)this->rgbInput, PIX_FMT_RGB24,
cc->width, cc->height);
-
+#else
+ //convert that to YUV for input to the codec
+ SwsContext* convert_ctx = sws_getContext(
+ cc->width, cc->height, PIX_FMT_RGB24,
+ cc->width, cc->height, cc->pix_fmt,
+ SWS_BICUBIC, NULL, NULL, NULL);
+
+ if(convert_ctx == NULL)
+ {
+ vtkGenericWarningMacro(<< "swscale context initialization failed");
+ return 0;
+ }
+
+ int result = sws_scale(convert_ctx,
+ this->rgbInput->data, this->rgbInput->linesize,
+ 0, cc->height,
+ this->yuvOutput->data, this->yuvOutput->linesize
+ );
+
+ sws_freeContext(convert_ctx);
+
+ if(!result)
+ {
+ vtkGenericWarningMacro(<< "sws_scale() failed");
+ return 0;
+ }
+#endif
+
+
//run the encoder
int toAdd = avcodec_encode_video(cc,
this->codecBuf,
@@ -332,7 +374,11 @@ void vtkFFMPEGWriterInternal::End()
if (this->openedFile)
{
av_write_trailer(this->avFormatContext);
+#ifdef VTK_FFMPEG_OLD_URL_FCLOSE
url_fclose(&this->avFormatContext->pb);
+#else
+ url_fclose(this->avFormatContext->pb);
+#endif
this->openedFile = 0;
}
More information about the vtkusers
mailing list