Index: /OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/CMakeLists.txt
===================================================================
--- /OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/CMakeLists.txt (revision 9854)
+++ /OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/CMakeLists.txt (revision 9948)
@@ -1,32 +1,25 @@
 # INCLUDE_DIRECTORIES( ${FFMPEG_INCLUDE_DIRS} )
+
+
+INCLUDE_DIRECTORIES( 
+    ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS} ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}/libavformat
+    ${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS} ${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS}/libavdevice
+    ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS} ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}/libavcodec
+    ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS} ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}/libavcodec
+)
+
+LINK_DIRECTORIES(${FFMPEG_LIBRARY_DIRS})
+
+SET(TARGET_EXTERNAL_LIBRARIES ${FFMPEG_LIBRARIES} )
+
+
 
 IF (FFMPEG_LIBSWSCALE_FOUND)
 
-    INCLUDE_DIRECTORIES( 
-        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS} ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}/libavformat ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}/ffmpeg
-        ${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS} ${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS}/libavdevice ${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS}/ffmpeg
-        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS} ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}/libavcodec ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}/ffmpeg
-        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS} ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}/libavcodec ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}/ffmpeg
-        ${FFMPEG_LIBSWSCALE_INCLUDE_DIRS} ${FFMPEG_LIBSWSCALE_INCLUDE_DIRS}/libswscale ${FFMPEG_LIBSWSCALE_INCLUDE_DIRS}/ffmpeg
-    )
+    INCLUDE_DIRECTORIES( ${FFMPEG_LIBSWSCALE_INCLUDE_DIRS} ${FFMPEG_LIBSWSCALE_INCLUDE_DIRS}/libswscale )
 
     ADD_DEFINITIONS(-DUSE_SWSCALE)
 
-    LINK_DIRECTORIES(${FFMPEG_LIBRARY_DIRS})
-
     SET(TARGET_EXTERNAL_LIBRARIES ${FFMPEG_LIBRARIES} ${FFMPEG_LIBSWSCALE_LIBRARIES})
-
-ELSE(FFMPEG_LIBSWSCALE_FOUND)
-
-    INCLUDE_DIRECTORIES( 
-        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS} ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}/libavformat ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}/ffmpeg
-        ${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS} ${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS}/libavdevice ${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS}/ffmpeg
-        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS} ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}/libavcodec ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}/ffmpeg
-        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS} ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}/libavcodec ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}/ffmpeg
-    )
-
-    LINK_DIRECTORIES(${FFMPEG_LIBRARY_DIRS})
-
-    SET(TARGET_EXTERNAL_LIBRARIES ${FFMPEG_LIBRARIES} )
 
 ENDIF()
Index: /OpenSceneGraph/trunk/CMakeModules/FindFFmpeg.cmake
===================================================================
--- /OpenSceneGraph/trunk/CMakeModules/FindFFmpeg.cmake (revision 9866)
+++ /OpenSceneGraph/trunk/CMakeModules/FindFFmpeg.cmake (revision 9948)
@@ -10,10 +10,23 @@
 # Created by Robert Osfield.
 
+
+#In ffmpeg code, old version use "#include <header.h>" and newer use "#include <libname/header.h>"
+#In OSG ffmpeg plugin, we use "#include <header.h>" for compatibility with old version of ffmpeg
+
+#We have to search the path which contain the header.h (usefull for old version)
+#and search the path which contain the libname/header.h (usefull for new version)
+
+#Then we need to include ${FFMPEG_libname_INCLUDE_DIRS} (in old version case, use by ffmpeg header and osg plugin code)
+#                                                       (in new version case, use by ffmpeg header) 
+#and ${FFMPEG_libname_INCLUDE_DIRS/libname}             (in new version case, use by osg plugin code)
+
+
 # Macro to find header and lib directories
 # example: FFMPEG_FIND(AVFORMAT avformat avformat.h)
-
 MACRO(FFMPEG_FIND varname shortname headername)
-    # First try to find header directly in include directory
+    # old version of ffmpeg put header in $prefix/include/[ffmpeg]
+    # so try to find header in include directory
     FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS ${headername}
+        PATHS
         ${FFMPEG_ROOT}/include
         $ENV{FFMPEG_DIR}/include
@@ -23,5 +36,5 @@
         /Library/Frameworks
         /usr/local/include
-        /usr/include/
+        /usr/include
         /sw/include # Fink
         /opt/local/include # DarwinPorts
@@ -29,9 +42,10 @@
         /opt/include
         /usr/freeware/include
+        PATH_SUFFIXES ffmpeg
+        DOC "Location of FFMPEG Headers"
     )
 
-    # If not found, try to find it in a subdirectory. Tanguy's build has
-    # avformat.h in include/libavformat, so this catches that case. If that's
-    # standard, perhaps we can keep just this case.
+    # newer version of ffmpeg put header in $prefix/include/[ffmpeg/]lib${shortname}
+    # so try to find lib${shortname}/header in include directory
     IF(NOT FFMPEG_${varname}_INCLUDE_DIRS)
         FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS lib${shortname}/${headername}
@@ -49,26 +63,6 @@
             /opt/include
             /usr/freeware/include
-        )
-    ENDIF(NOT FFMPEG_${varname}_INCLUDE_DIRS)
-
-
-    # If not found, try to find it in a subdirectory. Tanguy's build has
-    # avformat.h in include/libavformat, so this catches that case. If that's
-    # standard, perhaps we can keep just this case.
-    IF(NOT FFMPEG_${varname}_INCLUDE_DIRS)
-        FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS ffmpeg/${headername}
-            ${FFMPEG_ROOT}/include
-            $ENV{FFMPEG_DIR}/include
-            $ENV{OSGDIR}/include
-            $ENV{OSG_ROOT}/include
-            ~/Library/Frameworks
-            /Library/Frameworks
-            /usr/local/include
-            /usr/include/
-            /sw/include # Fink
-            /opt/local/include # DarwinPorts
-            /opt/csw/include # Blastwave
-            /opt/include
-            /usr/freeware/include
+            PATH_SUFFIXES ffmpeg
+            DOC "Location of FFMPEG Headers"
         )
     ENDIF(NOT FFMPEG_${varname}_INCLUDE_DIRS)
@@ -92,7 +86,8 @@
         /opt/lib
         /usr/freeware/lib64
+        DOC "Location of FFMPEG Libraries"
     )
 
-    IF   (FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
+    IF (FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
         SET(FFMPEG_${varname}_FOUND 1)
     ENDIF(FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
