diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3059ee9d..66701244 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,6 +23,8 @@ linux-builder: - mv /usr/local/lib/python3.4/dist-packages/*openshot* install-x64/python - echo -e "CI_PROJECT_NAME:$CI_PROJECT_NAME\nCI_COMMIT_REF_NAME:$CI_COMMIT_REF_NAME\nCI_COMMIT_SHA:$CI_COMMIT_SHA\nCI_JOB_ID:$CI_JOB_ID" > "install-x64/share/$CI_PROJECT_NAME" when: always + except: + - tags tags: - linux @@ -47,6 +49,8 @@ mac-builder: - mv /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/*openshot* install-x64/python - echo -e "CI_PROJECT_NAME:$CI_PROJECT_NAME\nCI_COMMIT_REF_NAME:$CI_COMMIT_REF_NAME\nCI_COMMIT_SHA:$CI_COMMIT_SHA\nCI_JOB_ID:$CI_JOB_ID" > "install-x64/share/$CI_PROJECT_NAME" when: always + except: + - tags tags: - mac @@ -73,6 +77,8 @@ windows-builder-x86: - cp src\libopenshot.dll install-x86\lib - New-Item -path "install-x86/share/" -Name "$CI_PROJECT_NAME" -Value "CI_PROJECT_NAME:$CI_PROJECT_NAME`nCI_COMMIT_REF_NAME:$CI_COMMIT_REF_NAME`nCI_COMMIT_SHA:$CI_COMMIT_SHA`nCI_JOB_ID:$CI_JOB_ID" -ItemType file -force when: always + except: + - tags tags: - windows @@ -99,6 +105,8 @@ windows-builder-x64: - cp src\libopenshot.dll install-x64\lib - New-Item -path "install-x64/share/" -Name "$CI_PROJECT_NAME" -Value "CI_PROJECT_NAME:$CI_PROJECT_NAME`nCI_COMMIT_REF_NAME:$CI_COMMIT_REF_NAME`nCI_COMMIT_SHA:$CI_COMMIT_SHA`nCI_JOB_ID:$CI_JOB_ID" -ItemType file -force when: always + except: + - tags tags: - windows @@ -108,5 +116,7 @@ trigger-pipeline: - "curl -X POST -F token=$OPENSHOT_QT_PIPELINE_TOKEN -F ref=$CI_COMMIT_REF_NAME http://gitlab.openshot.org/api/v4/projects/3/trigger/pipeline" when: always dependencies: [] + except: + - tags tags: - gitlab diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..fa191b2b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,49 @@ +dist: trusty + +matrix: + include: + - language: cpp + name: "FFmpeg 2" + before_script: + - sudo add-apt-repository ppa:openshot.developers/libopenshot-daily -y + - sudo add-apt-repository ppa:beineri/opt-qt58-trusty -y + - sudo apt-get update -qq + - sudo apt-get install gcc-4.8 cmake libavcodec-dev libavformat-dev libswscale-dev libavresample-dev libavutil-dev libopenshot-audio-dev libopenshot-dev libfdk-aac-dev libfdk-aac-dev libjsoncpp-dev libmagick++-dev libopenshot-audio-dev libunittest++-dev libzmq3-dev pkg-config python3-dev qtbase5-dev qtmultimedia5-dev swig -y + - sudo apt autoremove -y + script: + - mkdir -p build; cd build; + - cmake -D"CMAKE_BUILD_TYPE:STRING=Debug" ../ + - make VERBOSE=1 + - make test + + - language: cpp + name: "FFmpeg 3" + before_script: + - sudo add-apt-repository ppa:openshot.developers/libopenshot-daily -y + - sudo add-apt-repository ppa:beineri/opt-qt58-trusty -y + - sudo add-apt-repository ppa:jonathonf/ffmpeg-3 -y + - sudo apt-get update -qq + - sudo apt-get install gcc-4.8 cmake libavcodec-dev libavformat-dev libswscale-dev libavresample-dev libavutil-dev libopenshot-audio-dev libopenshot-dev libfdk-aac-dev libfdk-aac-dev libjsoncpp-dev libmagick++-dev libopenshot-audio-dev libunittest++-dev libzmq3-dev pkg-config python3-dev qtbase5-dev qtmultimedia5-dev swig -y + - sudo apt autoremove -y + script: + - mkdir -p build; cd build; + - cmake -D"CMAKE_BUILD_TYPE:STRING=Debug" ../ + - make VERBOSE=1 + - make test + + - language: cpp + name: "FFmpeg 4" + before_script: + - sudo add-apt-repository ppa:openshot.developers/libopenshot-daily -y + - sudo add-apt-repository ppa:beineri/opt-qt58-trusty -y + - sudo add-apt-repository ppa:jonathonf/ffmpeg -y + - sudo add-apt-repository ppa:jonathonf/ffmpeg-4 -y + - sudo add-apt-repository ppa:jonathonf/backports -y + - sudo apt-get update -qq + - sudo apt-get install gcc-4.8 cmake libavcodec58 libavformat58 libavcodec-dev libavformat-dev libswscale-dev libavresample-dev libavutil-dev libopenshot-audio-dev libopenshot-dev libfdk-aac-dev libfdk-aac-dev libjsoncpp-dev libmagick++-dev libopenshot-audio-dev libunittest++-dev libzmq3-dev pkg-config python3-dev qtbase5-dev qtmultimedia5-dev swig -y + - sudo apt autoremove -y + script: + - mkdir -p build; cd build; + - cmake -D"CMAKE_BUILD_TYPE:STRING=Debug" ../ + - make VERBOSE=1 + - make test diff --git a/cmake/Modules/FindFFmpeg.cmake b/cmake/Modules/FindFFmpeg.cmake index 45a27a9e..c4eb7ca3 100644 --- a/cmake/Modules/FindFFmpeg.cmake +++ b/cmake/Modules/FindFFmpeg.cmake @@ -1,189 +1,161 @@ -# - Try to find FFMPEG +# vim: ts=2 sw=2 +# - Try to find the required ffmpeg components(default: AVFORMAT, AVUTIL, AVCODEC) +# # Once done this will define -# -# FFMPEG_FOUND - system has FFMPEG -# FFMPEG_INCLUDE_DIR - the include directory -# FFMPEG_LIBRARY_DIR - the directory containing the libraries -# FFMPEG_LIBRARIES - Link these to use FFMPEG -# - -# FindAvformat -FIND_PATH( AVFORMAT_INCLUDE_DIR libavformat/avformat.h - PATHS /usr/include/ - /usr/include/ffmpeg/ - $ENV{FFMPEGDIR}/include/ - $ENV{FFMPEGDIR}/include/ffmpeg/ ) - -FIND_LIBRARY( AVFORMAT_LIBRARY avformat avformat-55 avformat-57 - PATHS /usr/lib/ - /usr/lib/ffmpeg/ - $ENV{FFMPEGDIR}/lib/ - $ENV{FFMPEGDIR}/lib/ffmpeg/ - $ENV{FFMPEGDIR}/bin/ ) - -#FindAvcodec -FIND_PATH( AVCODEC_INCLUDE_DIR libavcodec/avcodec.h - PATHS /usr/include/ - /usr/include/ffmpeg/ - $ENV{FFMPEGDIR}/include/ - $ENV{FFMPEGDIR}/include/ffmpeg/ ) - -FIND_LIBRARY( AVCODEC_LIBRARY avcodec avcodec-55 avcodec-57 - PATHS /usr/lib/ - /usr/lib/ffmpeg/ - $ENV{FFMPEGDIR}/lib/ - $ENV{FFMPEGDIR}/lib/ffmpeg/ - $ENV{FFMPEGDIR}/bin/ ) - -#FindAvutil -FIND_PATH( AVUTIL_INCLUDE_DIR libavutil/avutil.h - PATHS /usr/include/ - /usr/include/ffmpeg/ - $ENV{FFMPEGDIR}/include/ - $ENV{FFMPEGDIR}/include/ffmpeg/ ) - -FIND_LIBRARY( AVUTIL_LIBRARY avutil avutil-52 avutil-55 - PATHS /usr/lib/ - /usr/lib/ffmpeg/ - $ENV{FFMPEGDIR}/lib/ - $ENV{FFMPEGDIR}/lib/ffmpeg/ - $ENV{FFMPEGDIR}/bin/ ) - -#FindAvdevice -FIND_PATH( AVDEVICE_INCLUDE_DIR libavdevice/avdevice.h - PATHS /usr/include/ - /usr/include/ffmpeg/ - $ENV{FFMPEGDIR}/include/ - $ENV{FFMPEGDIR}/include/ffmpeg/ ) - -FIND_LIBRARY( AVDEVICE_LIBRARY avdevice avdevice-55 avdevice-56 - PATHS /usr/lib/ - /usr/lib/ffmpeg/ - $ENV{FFMPEGDIR}/lib/ - $ENV{FFMPEGDIR}/lib/ffmpeg/ - $ENV{FFMPEGDIR}/bin/ ) - -#FindSwscale -FIND_PATH( SWSCALE_INCLUDE_DIR libswscale/swscale.h - PATHS /usr/include/ - /usr/include/ffmpeg/ - $ENV{FFMPEGDIR}/include/ - $ENV{FFMPEGDIR}/include/ffmpeg/ ) - -FIND_LIBRARY( SWSCALE_LIBRARY swscale swscale-2 swscale-4 - PATHS /usr/lib/ - /usr/lib/ffmpeg/ - $ENV{FFMPEGDIR}/lib/ - $ENV{FFMPEGDIR}/lib/ffmpeg/ - $ENV{FFMPEGDIR}/bin/ ) - -#FindAvresample -FIND_PATH( AVRESAMPLE_INCLUDE_DIR libavresample/avresample.h - PATHS /usr/include/ - /usr/include/ffmpeg/ - $ENV{FFMPEGDIR}/include/ - $ENV{FFMPEGDIR}/include/ffmpeg/ ) - -FIND_LIBRARY( AVRESAMPLE_LIBRARY avresample avresample-2 avresample-3 - PATHS /usr/lib/ - /usr/lib/ffmpeg/ - $ENV{FFMPEGDIR}/lib/ - $ENV{FFMPEGDIR}/lib/ffmpeg/ - $ENV{FFMPEGDIR}/bin/ ) - -#FindSwresample -FIND_PATH( SWRESAMPLE_INCLUDE_DIR libswresample/swresample.h - PATHS /usr/include/ - /usr/include/ffmpeg/ - $ENV{FFMPEGDIR}/include/ - $ENV{FFMPEGDIR}/include/ffmpeg/ ) - -FIND_LIBRARY( SWRESAMPLE_LIBRARY swresample - PATHS /usr/lib/ - /usr/lib/ffmpeg/ - $ENV{FFMPEGDIR}/lib/ - $ENV{FFMPEGDIR}/lib/ffmpeg/ - $ENV{FFMPEGDIR}/bin/ ) - -SET( FFMPEG_FOUND FALSE ) - -IF ( AVFORMAT_INCLUDE_DIR AND AVFORMAT_LIBRARY ) - SET ( AVFORMAT_FOUND TRUE ) -ENDIF ( AVFORMAT_INCLUDE_DIR AND AVFORMAT_LIBRARY ) - -IF ( AVCODEC_INCLUDE_DIR AND AVCODEC_LIBRARY ) - SET ( AVCODEC_FOUND TRUE) -ENDIF ( AVCODEC_INCLUDE_DIR AND AVCODEC_LIBRARY ) - -IF ( AVUTIL_INCLUDE_DIR AND AVUTIL_LIBRARY ) - SET ( AVUTIL_FOUND TRUE ) -ENDIF ( AVUTIL_INCLUDE_DIR AND AVUTIL_LIBRARY ) - -IF ( AVDEVICE_INCLUDE_DIR AND AVDEVICE_LIBRARY ) - SET ( AVDEVICE_FOUND TRUE ) -ENDIF ( AVDEVICE_INCLUDE_DIR AND AVDEVICE_LIBRARY ) - -IF ( SWSCALE_INCLUDE_DIR AND SWSCALE_LIBRARY ) - SET ( SWSCALE_FOUND TRUE ) -ENDIF ( SWSCALE_INCLUDE_DIR AND SWSCALE_LIBRARY ) - -IF ( AVRESAMPLE_INCLUDE_DIR AND AVRESAMPLE_LIBRARY ) - SET ( AVRESAMPLE_FOUND TRUE ) -ENDIF ( AVRESAMPLE_INCLUDE_DIR AND AVRESAMPLE_LIBRARY ) - -IF ( SWRESAMPLE_INCLUDE_DIR AND SWRESAMPLE_LIBRARY ) - SET ( SWRESAMPLE_FOUND TRUE ) -ENDIF ( SWRESAMPLE_INCLUDE_DIR AND SWRESAMPLE_LIBRARY ) - -IF ( AVFORMAT_INCLUDE_DIR OR AVCODEC_INCLUDE_DIR OR AVUTIL_INCLUDE_DIR OR AVDEVICE_FOUND OR SWSCALE_FOUND OR AVRESAMPLE_FOUND OR SWRESAMPLE_FOUND ) - - SET ( FFMPEG_FOUND TRUE ) - - IF ( SWRESAMPLE_FOUND ) - SET ( FFMPEG_INCLUDE_DIR - ${AVFORMAT_INCLUDE_DIR} - ${AVCODEC_INCLUDE_DIR} - ${AVUTIL_INCLUDE_DIR} - ${AVDEVICE_INCLUDE_DIR} - ${SWSCALE_INCLUDE_DIR} - ${AVRESAMPLE_INCLUDE_DIR} - ${SWRESAMPLE_INCLUDE_DIR} ) - - SET ( FFMPEG_LIBRARIES - ${AVFORMAT_LIBRARY} - ${AVCODEC_LIBRARY} - ${AVUTIL_LIBRARY} - ${AVDEVICE_LIBRARY} - ${SWSCALE_LIBRARY} - ${AVRESAMPLE_LIBRARY} - ${SWRESAMPLE_LIBRARY} ) - ELSE () - SET ( FFMPEG_INCLUDE_DIR - ${AVFORMAT_INCLUDE_DIR} - ${AVCODEC_INCLUDE_DIR} - ${AVUTIL_INCLUDE_DIR} - ${AVDEVICE_INCLUDE_DIR} - ${SWSCALE_INCLUDE_DIR} - ${AVRESAMPLE_INCLUDE_DIR} ) - - SET ( FFMPEG_LIBRARIES - ${AVFORMAT_LIBRARY} - ${AVCODEC_LIBRARY} - ${AVUTIL_LIBRARY} - ${AVDEVICE_LIBRARY} - ${SWSCALE_LIBRARY} - ${AVRESAMPLE_LIBRARY} ) - ENDIF () - -ENDIF ( AVFORMAT_INCLUDE_DIR OR AVCODEC_INCLUDE_DIR OR AVUTIL_INCLUDE_DIR OR AVDEVICE_FOUND OR SWSCALE_FOUND OR AVRESAMPLE_FOUND OR SWRESAMPLE_FOUND ) - -MARK_AS_ADVANCED( - FFMPEG_LIBRARY_DIR - FFMPEG_INCLUDE_DIR -) +# FFMPEG_FOUND - System has the all required components. +# FFMPEG_INCLUDE_DIRS - Include directory necessary for using the required components headers. +# FFMPEG_LIBRARIES - Link these to use the required ffmpeg components. +# FFMPEG_DEFINITIONS - Compiler switches required for using the required ffmpeg components. +# +# For each of the components it will additionally set. +# - AVCODEC +# - AVDEVICE +# - AVFORMAT +# - AVFILTER +# - AVUTIL +# - POSTPROC +# - SWSCALE +# - SWRESAMPLE +# - AVRESAMPLE +# the following variables will be defined +# _FOUND - System has +# _INCLUDE_DIRS - Include directory necessary for using the headers +# _LIBRARIES - Link these to use +# _DEFINITIONS - Compiler switches required for using +# _VERSION - The components version +# +# Copyright (c) 2006, Matthias Kretz, +# Copyright (c) 2008, Alexander Neundorf, +# Copyright (c) 2011, Michael Jansen, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. include(FindPackageHandleStandardArgs) -# handle the QUIETLY and REQUIRED arguments and set FFMPEG_FOUND to TRUE -# if all listed variables are TRUE -find_package_handle_standard_args(FFMPEG DEFAULT_MSG - FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIR) + +# The default components were taken from a survey over other FindFFMPEG.cmake files +if (NOT FFmpeg_FIND_COMPONENTS) + set(FFmpeg_FIND_COMPONENTS AVCODEC AVFORMAT AVUTIL) +endif () + +# +### Macro: set_component_found +# +# Marks the given component as found if both *_LIBRARIES AND *_INCLUDE_DIRS is present. +# +macro(set_component_found _component ) + if (${_component}_LIBRARIES AND ${_component}_INCLUDE_DIRS) + # message(STATUS " - ${_component} found.") + set(${_component}_FOUND TRUE) + else () + # message(STATUS " - ${_component} not found.") + endif () +endmacro() + +# +### Macro: find_component +# +# Checks for the given component by invoking pkgconfig and then looking up the libraries and +# include directories. +# +macro(find_component _component _pkgconfig _library _header) + + if (NOT WIN32) + # use pkg-config to get the directories and then use these values + # in the FIND_PATH() and FIND_LIBRARY() calls + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_check_modules(PC_${_component} ${_pkgconfig}) + endif () + endif (NOT WIN32) + + find_path(${_component}_INCLUDE_DIRS ${_header} + HINTS + /opt/ + /opt/include/ + ${PC_LIB${_component}_INCLUDEDIR} + ${PC_LIB${_component}_INCLUDE_DIRS} + $ENV{FFMPEGDIR}/include/ + $ENV{FFMPEGDIR}/include/ffmpeg/ + PATH_SUFFIXES + ffmpeg + ) + + find_library(${_component}_LIBRARIES NAMES ${_library} + HINTS + ${PC_LIB${_component}_LIBDIR} + ${PC_LIB${_component}_LIBRARY_DIRS} + $ENV{FFMPEGDIR}/lib/ + $ENV{FFMPEGDIR}/lib/ffmpeg/ + $ENV{FFMPEGDIR}/bin/ + ) + + set(${_component}_DEFINITIONS ${PC_${_component}_CFLAGS_OTHER} CACHE STRING "The ${_component} CFLAGS.") + set(${_component}_VERSION ${PC_${_component}_VERSION} CACHE STRING "The ${_component} version number.") + + set_component_found(${_component}) + + mark_as_advanced( + ${_component}_INCLUDE_DIRS + ${_component}_LIBRARIES + ${_component}_DEFINITIONS + ${_component}_VERSION) + +endmacro() + + +# Check for cached results. If there are skip the costly part. +if (NOT FFMPEG_LIBRARIES) + + # Check for all possible component. + find_component(AVCODEC libavcodec avcodec libavcodec/avcodec.h) + find_component(AVFORMAT libavformat avformat libavformat/avformat.h) + find_component(AVDEVICE libavdevice avdevice libavdevice/avdevice.h) + find_component(AVUTIL libavutil avutil libavutil/avutil.h) + find_component(AVFILTER libavfilter avfilter libavfilter/avfilter.h) + find_component(SWSCALE libswscale swscale libswscale/swscale.h) + find_component(POSTPROC libpostproc postproc libpostproc/postprocess.h) + find_component(SWRESAMPLE libswresample swresample libswresample/swresample.h) + find_component(AVRESAMPLE libavresample avresample libavresample/avresample.h) + + # Check if the required components were found and add their stuff to the FFMPEG_* vars. + foreach (_component ${FFmpeg_FIND_COMPONENTS}) + if (${_component}_FOUND) + # message(STATUS "Required component ${_component} present.") + set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${${_component}_LIBRARIES}) + set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} ${${_component}_DEFINITIONS}) + list(APPEND FFMPEG_INCLUDE_DIRS ${${_component}_INCLUDE_DIRS}) + else () + # message(STATUS "Required component ${_component} missing.") + endif () + endforeach () + + # Build the include path with duplicates removed. + if (FFMPEG_INCLUDE_DIRS) + list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS) + endif () + + # cache the vars. + set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} CACHE STRING "The FFmpeg include directories." FORCE) + set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} CACHE STRING "The FFmpeg libraries." FORCE) + set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} CACHE STRING "The FFmpeg cflags." FORCE) + + mark_as_advanced(FFMPEG_INCLUDE_DIRS + FFMPEG_LIBRARIES + FFMPEG_DEFINITIONS) + +endif () + +# Now set the noncached _FOUND vars for the components. +foreach (_component AVCODEC AVDEVICE AVFORMAT AVUTIL POSTPROCESS SWSCALE SWRESAMPLE AVRESAMPLE) + set_component_found(${_component}) +endforeach () + +# Compile the list of required vars +set(_FFmpeg_REQUIRED_VARS FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIRS) +foreach (_component ${FFmpeg_FIND_COMPONENTS}) + list(APPEND _FFmpeg_REQUIRED_VARS ${_component}_LIBRARIES ${_component}_INCLUDE_DIRS) +endforeach () + +# Give a nice error message if some of the required vars are missing. +find_package_handle_standard_args(FFmpeg DEFAULT_MSG ${_FFmpeg_REQUIRED_VARS}) diff --git a/include/Version.h b/include/Version.h index 971d5cfe..4ff2c36c 100644 --- a/include/Version.h +++ b/include/Version.h @@ -36,8 +36,8 @@ #define OPENSHOT_VERSION_MAJOR 0; /// Major version number is incremented when huge features are added or improved. #define OPENSHOT_VERSION_MINOR 2; /// Minor version is incremented when smaller (but still very important) improvements are added. -#define OPENSHOT_VERSION_BUILD 0; /// Build number is incremented when minor bug fixes and less important improvements are added. -#define OPENSHOT_VERSION_SO 15; /// Shared object version number. This increments any time the API and ABI changes (so old apps will no longer link) +#define OPENSHOT_VERSION_BUILD 2; /// Build number is incremented when minor bug fixes and less important improvements are added. +#define OPENSHOT_VERSION_SO 16; /// Shared object version number. This increments any time the API and ABI changes (so old apps will no longer link) #define OPENSHOT_VERSION_MAJOR_MINOR STRINGIZE(OPENSHOT_VERSION_MAJOR) "." STRINGIZE(OPENSHOT_VERSION_MINOR); /// A string of the "Major.Minor" version #define OPENSHOT_VERSION_ALL STRINGIZE(OPENSHOT_VERSION_MAJOR) "." STRINGIZE(OPENSHOT_VERSION_MINOR) "." STRINGIZE(OPENSHOT_VERSION_BUILD); /// A string of the entire version "Major.Minor.Build" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f4e8fba4..d71067a3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -37,12 +37,12 @@ IF (WIN32) ENDIF(WIN32) IF (APPLE) # If you still get errors compiling with GCC 4.8, mac headers need to be patched: http://hamelot.co.uk/programming/osx-gcc-dispatch_block_t-has-not-been-declared-invalid-typedef/ - SET_PROPERTY(GLOBAL PROPERTY JUCE_MAC "JUCE_MAC") - ADD_DEFINITIONS(-DNDEBUG) - SET(EXTENSION "mm") - - SET(JUCE_PLATFORM_SPECIFIC_DIR build/macosx/platform_specific_code) - SET(JUCE_PLATFORM_SPECIFIC_LIBRARIES "-framework Carbon -framework Cocoa -framework CoreFoundation -framework CoreAudio -framework CoreMidi -framework IOKit -framework AGL -framework AudioToolbox -framework QuartzCore -lobjc -framework Accelerate") + SET_PROPERTY(GLOBAL PROPERTY JUCE_MAC "JUCE_MAC") + ADD_DEFINITIONS(-DNDEBUG) + SET(EXTENSION "mm") + + SET(JUCE_PLATFORM_SPECIFIC_DIR build/macosx/platform_specific_code) + SET(JUCE_PLATFORM_SPECIFIC_LIBRARIES "-framework Carbon -framework Cocoa -framework CoreFoundation -framework CoreAudio -framework CoreMidi -framework IOKit -framework AGL -framework AudioToolbox -framework QuartzCore -lobjc -framework Accelerate") ENDIF(APPLE) ################ IMAGE MAGICK ################## @@ -74,13 +74,43 @@ IF (ImageMagick_FOUND) SET(CMAKE_SWIG_FLAGS "-DUSE_IMAGEMAGICK=1") ENDIF (ImageMagick_FOUND) - + ################### FFMPEG ##################### # Find FFmpeg libraries (used for video encoding / decoding) FIND_PACKAGE(FFmpeg REQUIRED) # Include FFmpeg headers (needed for compile) -include_directories(${FFMPEG_INCLUDE_DIR}) +message('AVCODEC_FOUND: ${AVCODEC_FOUND}') +message('AVCODEC_INCLUDE_DIRS: ${AVCODEC_INCLUDE_DIRS}') +message('AVCODEC_LIBRARIES: ${AVCODEC_LIBRARIES}') + +IF (AVCODEC_FOUND) + include_directories(${AVCODEC_INCLUDE_DIRS}) +ENDIF (AVCODEC_FOUND) +IF (AVDEVICE_FOUND) + include_directories(${AVDEVICE_INCLUDE_DIRS}) +ENDIF (AVDEVICE_FOUND) +IF (AVFORMAT_FOUND) + include_directories(${AVFORMAT_INCLUDE_DIRS}) +ENDIF (AVFORMAT_FOUND) +IF (AVFILTER_FOUND) + include_directories(${AVFILTER_INCLUDE_DIRS}) +ENDIF (AVFILTER_FOUND) +IF (AVUTIL_FOUND) + include_directories(${AVUTIL_INCLUDE_DIRS}) +ENDIF (AVUTIL_FOUND) +IF (POSTPROC_FOUND) + include_directories(${POSTPROC_INCLUDE_DIRS}) +ENDIF (POSTPROC_FOUND) +IF (SWSCALE_FOUND) + include_directories(${SWSCALE_INCLUDE_DIRS}) +ENDIF (SWSCALE_FOUND) +IF (SWRESAMPLE_FOUND) + include_directories(${SWRESAMPLE_INCLUDE_DIRS}) +ENDIF (SWRESAMPLE_FOUND) +IF (AVRESAMPLE_FOUND) + include_directories(${AVRESAMPLE_INCLUDE_DIRS}) +ENDIF (AVRESAMPLE_FOUND) ################# LIBOPENSHOT-AUDIO ################### # Find JUCE-based openshot Audio libraries @@ -112,11 +142,11 @@ add_definitions(${Qt5Gui_DEFINITIONS}) add_definitions(${Qt5Multimedia_DEFINITIONS}) add_definitions(${Qt5MultimediaWidgets_DEFINITIONS}) -SET(QT_LIBRARIES ${Qt5Widgets_LIBRARIES} - ${Qt5Core_LIBRARIES} - ${Qt5Gui_LIBRARIES} - ${Qt5Multimedia_LIBRARIES} - ${Qt5MultimediaWidgets_LIBRARIES}) +SET(QT_LIBRARIES ${Qt5Widgets_LIBRARIES} + ${Qt5Core_LIBRARIES} + ${Qt5Gui_LIBRARIES} + ${Qt5Multimedia_LIBRARIES} + ${Qt5MultimediaWidgets_LIBRARIES}) # Set compiler flags for Qt set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS} ") @@ -133,15 +163,15 @@ qt5_wrap_cpp(MOC_FILES ${QT_HEADER_FILES}) # Find BlackMagic DeckLinkAPI libraries IF (ENABLE_BLACKMAGIC) FIND_PACKAGE(BlackMagic) - + IF (BLACKMAGIC_FOUND) # Include headers (needed for compile) include_directories(${BLACKMAGIC_INCLUDE_DIR}) - + # define a global var (used in the C++) add_definitions( -DUSE_BLACKMAGIC=1 ) SET(CMAKE_SWIG_FLAGS "-DUSE_BLACKMAGIC=1") - + ENDIF (BLACKMAGIC_FOUND) ENDIF (ENABLE_BLACKMAGIC) @@ -150,14 +180,14 @@ ENDIF (ENABLE_BLACKMAGIC) FIND_PACKAGE(OpenMP) if (OPENMP_FOUND) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} ") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} ") endif(OPENMP_FOUND) ################### ZEROMQ ##################### # Find ZeroMQ library (used for socket communication & logging) FIND_PACKAGE(ZMQ REQUIRED) -# Include FFmpeg headers (needed for compile) +# Include ZeroMQ headers (needed for compile) include_directories(${ZMQ_INCLUDE_DIRS}) ################### JSONCPP ##################### @@ -182,8 +212,8 @@ FILE(GLOB QT_PLAYER_FILES "${CMAKE_CURRENT_SOURCE_DIR}/Qt/*.cpp") ############### SET LIBRARY SOURCE FILES ################# SET ( OPENSHOT_SOURCE_FILES - AudioBufferSource.cpp - AudioReaderSource.cpp + AudioBufferSource.cpp + AudioReaderSource.cpp AudioResampler.cpp CacheBase.cpp CacheDisk.cpp @@ -215,37 +245,37 @@ SET ( OPENSHOT_SOURCE_FILES QtImageReader.cpp QtPlayer.cpp Timeline.cpp - + # Qt Video Player ${QT_PLAYER_FILES} ${MOC_FILES}) - IF (NOT USE_SYSTEM_JSONCPP) - # Third Party JSON Parser - SET ( OPENSHOT_SOURCE_FILES ${OPENSHOT_SOURCE_FILES} - ../thirdparty/jsoncpp/src/lib_json/json_reader.cpp - ../thirdparty/jsoncpp/src/lib_json/json_value.cpp - ../thirdparty/jsoncpp/src/lib_json/json_writer.cpp) - ENDIF (NOT USE_SYSTEM_JSONCPP) +IF (NOT USE_SYSTEM_JSONCPP) + # Third Party JSON Parser + SET ( OPENSHOT_SOURCE_FILES ${OPENSHOT_SOURCE_FILES} + ../thirdparty/jsoncpp/src/lib_json/json_reader.cpp + ../thirdparty/jsoncpp/src/lib_json/json_value.cpp + ../thirdparty/jsoncpp/src/lib_json/json_writer.cpp) +ENDIF (NOT USE_SYSTEM_JSONCPP) + +# ImageMagic related files +IF (ImageMagick_FOUND) + SET ( OPENSHOT_SOURCE_FILES ${OPENSHOT_SOURCE_FILES} + ImageReader.cpp + ImageWriter.cpp + TextReader.cpp) +ENDIF (ImageMagick_FOUND) + +# BlackMagic related files +IF (BLACKMAGIC_FOUND) + SET ( OPENSHOT_SOURCE_FILES ${OPENSHOT_SOURCE_FILES} + DecklinkInput.cpp + DecklinkReader.cpp + DecklinkOutput.cpp + DecklinkWriter.cpp) +ENDIF (BLACKMAGIC_FOUND) - # ImageMagic related files - IF (ImageMagick_FOUND) - SET ( OPENSHOT_SOURCE_FILES ${OPENSHOT_SOURCE_FILES} - ImageReader.cpp - ImageWriter.cpp - TextReader.cpp) - ENDIF (ImageMagick_FOUND) - # BlackMagic related files - IF (BLACKMAGIC_FOUND) - SET ( OPENSHOT_SOURCE_FILES ${OPENSHOT_SOURCE_FILES} - DecklinkInput.cpp - DecklinkReader.cpp - DecklinkOutput.cpp - DecklinkWriter.cpp) - ENDIF (BLACKMAGIC_FOUND) - - # Get list of headers file(GLOB_RECURSE headers ${CMAKE_SOURCE_DIR}/include/*.h) @@ -254,44 +284,71 @@ SET(CMAKE_MACOSX_RPATH 0) ############### CREATE LIBRARY ################# # Create shared openshot library -add_library(openshot SHARED - ${OPENSHOT_SOURCE_FILES} - ${headers} ) +add_library(openshot SHARED + ${OPENSHOT_SOURCE_FILES} + ${headers} ) # Set SONAME and other library properties set_target_properties(openshot - PROPERTIES - VERSION ${PROJECT_VERSION} - SOVERSION ${SO_VERSION} - INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" - ) + PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${SO_VERSION} + INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" + ) ############### LINK LIBRARY ################# SET ( REQUIRED_LIBRARIES - ${FFMPEG_LIBRARIES} ${LIBOPENSHOT_AUDIO_LIBRARIES} ${QT_LIBRARIES} ${PROFILER} ${JSONCPP_LIBRARY} ${ZMQ_LIBRARIES} ) - - IF (OPENMP_FOUND) - SET ( REQUIRED_LIBRARIES ${REQUIRED_LIBRARIES} ${OpenMP_CXX_FLAGS} ) - ENDIF (OPENMP_FOUND) - - IF (ImageMagick_FOUND) - SET ( REQUIRED_LIBRARIES ${REQUIRED_LIBRARIES} ${ImageMagick_LIBRARIES} ) - ENDIF (ImageMagick_FOUND) - IF (BLACKMAGIC_FOUND) - SET ( REQUIRED_LIBRARIES ${REQUIRED_LIBRARIES} ${BLACKMAGIC_LIBRARY_DIR} ) - ENDIF (BLACKMAGIC_FOUND) +IF (AVCODEC_FOUND) + SET ( REQUIRED_LIBRARIES ${REQUIRED_LIBRARIES} ${AVCODEC_LIBRARIES} ) +ENDIF (AVCODEC_FOUND) +IF (AVDEVICE_FOUND) + SET ( REQUIRED_LIBRARIES ${REQUIRED_LIBRARIES} ${AVDEVICE_LIBRARIES} ) +ENDIF (AVDEVICE_FOUND) +IF (AVFORMAT_FOUND) + SET ( REQUIRED_LIBRARIES ${REQUIRED_LIBRARIES} ${AVFORMAT_LIBRARIES} ) +ENDIF (AVFORMAT_FOUND) +IF (AVFILTER_FOUND) + SET ( REQUIRED_LIBRARIES ${REQUIRED_LIBRARIES} ${AVFILTER_LIBRARIES} ) +ENDIF (AVFILTER_FOUND) +IF (AVUTIL_FOUND) + SET ( REQUIRED_LIBRARIES ${REQUIRED_LIBRARIES} ${AVUTIL_LIBRARIES} ) +ENDIF (AVUTIL_FOUND) +IF (POSTPROC_FOUND) + SET ( REQUIRED_LIBRARIES ${REQUIRED_LIBRARIES} ${POSTPROC_LIBRARIES} ) +ENDIF (POSTPROC_FOUND) +IF (SWSCALE_FOUND) + SET ( REQUIRED_LIBRARIES ${REQUIRED_LIBRARIES} ${SWSCALE_LIBRARIES} ) +ENDIF (SWSCALE_FOUND) +IF (SWRESAMPLE_FOUND) + SET ( REQUIRED_LIBRARIES ${REQUIRED_LIBRARIES} ${SWRESAMPLE_LIBRARIES} ) +ENDIF (SWRESAMPLE_FOUND) +IF (AVRESAMPLE_FOUND) + SET ( REQUIRED_LIBRARIES ${REQUIRED_LIBRARIES} ${AVRESAMPLE_LIBRARIES} ) +ENDIF (AVRESAMPLE_FOUND) - IF (WIN32) - # Required for exception handling on Windows - SET ( REQUIRED_LIBRARIES ${REQUIRED_LIBRARIES} "imagehlp" "dbghelp" ) - ENDIF(WIN32) +IF (OPENMP_FOUND) + SET ( REQUIRED_LIBRARIES ${REQUIRED_LIBRARIES} ${OpenMP_CXX_FLAGS} ) +ENDIF (OPENMP_FOUND) + +IF (ImageMagick_FOUND) + SET ( REQUIRED_LIBRARIES ${REQUIRED_LIBRARIES} ${ImageMagick_LIBRARIES} ) +ENDIF (ImageMagick_FOUND) + +IF (BLACKMAGIC_FOUND) + SET ( REQUIRED_LIBRARIES ${REQUIRED_LIBRARIES} ${BLACKMAGIC_LIBRARY_DIR} ) +ENDIF (BLACKMAGIC_FOUND) + +IF (WIN32) + # Required for exception handling on Windows + SET ( REQUIRED_LIBRARIES ${REQUIRED_LIBRARIES} "imagehlp" "dbghelp" ) +ENDIF(WIN32) # Link all referenced libraries target_link_libraries(openshot ${REQUIRED_LIBRARIES}) @@ -314,9 +371,9 @@ target_link_libraries(openshot-player openshot) ############### TEST BLACKMAGIC CAPTURE APP ################ IF (BLACKMAGIC_FOUND) # Create test executable - add_executable(openshot-blackmagic - examples/ExampleBlackmagic.cpp) - + add_executable(openshot-blackmagic + examples/ExampleBlackmagic.cpp) + # Link test executable to the new library target_link_libraries(openshot-blackmagic openshot) ENDIF (BLACKMAGIC_FOUND) @@ -330,13 +387,13 @@ set(LIB_INSTALL_DIR lib${LIB_SUFFIX}) # determine correct lib folder # Install primary library INSTALL( TARGETS openshot - ARCHIVE DESTINATION ${LIB_INSTALL_DIR} - LIBRARY DESTINATION ${LIB_INSTALL_DIR} - COMPONENT library ) - + ARCHIVE DESTINATION ${LIB_INSTALL_DIR} + LIBRARY DESTINATION ${LIB_INSTALL_DIR} + COMPONENT library ) + INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ - DESTINATION ${CMAKE_INSTALL_PREFIX}/include/libopenshot -FILES_MATCHING PATTERN "*.h") + DESTINATION ${CMAKE_INSTALL_PREFIX}/include/libopenshot + FILES_MATCHING PATTERN "*.h") ############### CPACK PACKAGING ############## IF(MINGW) diff --git a/src/Clip.cpp b/src/Clip.cpp index 63e77412..8e33f84c 100644 --- a/src/Clip.cpp +++ b/src/Clip.cpp @@ -671,6 +671,7 @@ std::shared_ptr Clip::GetOrCreateFrame(int64_t number) new_frame = std::make_shared(number, reader->info.width, reader->info.height, "#000000", samples_in_frame, reader->info.channels); new_frame->SampleRate(reader->info.sample_rate); new_frame->ChannelsLayout(reader->info.channel_layout); + new_frame->AddAudioSilence(samples_in_frame); return new_frame; } diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp index 912c1e2f..d78b7c8f 100644 --- a/src/FFmpegReader.cpp +++ b/src/FFmpegReader.cpp @@ -595,6 +595,11 @@ void FFmpegReader::UpdateAudioInfo() info.height = 480; } + // Fix invalid video lengths for certain types of files (MP3 for example) + if (info.has_video && ((info.duration * info.fps.ToDouble()) - info.video_length > 60)) { + info.video_length = info.duration * info.fps.ToDouble(); + } + // Add audio metadata (if any found) AVDictionaryEntry *tag = NULL; while ((tag = av_dict_get(aStream->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) { @@ -684,7 +689,7 @@ void FFmpegReader::UpdateVideoInfo() } // Override an invalid framerate - if (info.fps.ToFloat() > 240.0f || (info.fps.num == 0 || info.fps.den == 0)) { + if (info.fps.ToFloat() > 240.0f || (info.fps.num <= 0 || info.fps.den <= 0) || info.video_length <= 0) { // Calculate FPS, duration, video bit rate, and video length manually // by scanning through all the video stream packets CheckFPS(); @@ -928,6 +933,7 @@ std::shared_ptr FFmpegReader::ReadStream(int64_t requested_frame) } // end while } // end omp single + } // end omp parallel // Debug output @@ -1216,7 +1222,7 @@ void FFmpegReader::ProcessVideoPacket(int64_t requested_frame) AV_COPY_PICTURE_DATA(pFrameRGB, buffer, PIX_FMT_RGBA, width, height); SwsContext *img_convert_ctx = sws_getContext(info.width, info.height, AV_GET_CODEC_PIXEL_FORMAT(pStream, pCodecCtx), width, - height, PIX_FMT_RGBA, SWS_BILINEAR, NULL, NULL, NULL); + height, PIX_FMT_RGBA, SWS_LANCZOS, NULL, NULL, NULL); // Resize / Convert to RGB sws_scale(img_convert_ctx, my_frame->data, my_frame->linesize, 0, @@ -2173,6 +2179,7 @@ void FFmpegReader::CheckFPS() int forth_second_counter = 0; int fifth_second_counter = 0; int frames_detected = 0; + int64_t pts = 0; // Loop through the stream while (true) @@ -2192,7 +2199,7 @@ void FFmpegReader::CheckFPS() UpdatePTSOffset(true); // Get PTS of this packet - int64_t pts = GetVideoPTS(); + pts = GetVideoPTS(); // Remove pFrame RemoveAVFrame(pFrame); @@ -2223,7 +2230,7 @@ void FFmpegReader::CheckFPS() // Double check that all counters have greater than zero (or give up) if (second_second_counter != 0 && third_second_counter != 0 && forth_second_counter != 0 && fifth_second_counter != 0) { - // Calculate average FPS + // Calculate average FPS (average of first few seconds) int sum_fps = second_second_counter + third_second_counter + forth_second_counter + fifth_second_counter; int avg_fps = round(sum_fps / 4.0f); @@ -2232,22 +2239,32 @@ void FFmpegReader::CheckFPS() // Update Duration and Length info.video_length = frames_detected; - info.duration = frames_detected / round(sum_fps / 4.0f); + info.duration = frames_detected / (sum_fps / 4.0f); + + // Update video bit rate + info.video_bit_rate = info.file_size / info.duration; + } else if (second_second_counter != 0 && third_second_counter != 0) { + // Calculate average FPS (only on second 2) + int sum_fps = second_second_counter; + + // Update FPS + info.fps = Fraction(sum_fps, 1); + + // Update Duration and Length + info.video_length = frames_detected; + info.duration = frames_detected / float(sum_fps); // Update video bit rate info.video_bit_rate = info.file_size / info.duration; } else { - // Too short to determine framerate, just default FPS // Set a few important default video settings (so audio can be divided into frames) info.fps.num = 30; info.fps.den = 1; - info.video_timebase.num = info.fps.den; - info.video_timebase.den = info.fps.num; // Calculate number of frames info.video_length = frames_detected; - info.duration = frames_detected / info.video_timebase.ToFloat(); + info.duration = frames_detected / info.fps.ToFloat(); } } diff --git a/src/Frame.cpp b/src/Frame.cpp index 16a0d267..a00fc232 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -512,6 +512,8 @@ int Frame::GetSamplesPerFrame(int64_t number, Fraction fps, int sample_rate, int // Subtract the previous frame's total samples with this frame's total samples. Not all sample rates can // be evenly divided into frames, so each frame can have have different # of samples. int samples_per_frame = round(total_samples - previous_samples); + if (samples_per_frame < 0) + samples_per_frame = 0; return samples_per_frame; } diff --git a/src/FrameMapper.cpp b/src/FrameMapper.cpp index c4c68f5a..1817c049 100644 --- a/src/FrameMapper.cpp +++ b/src/FrameMapper.cpp @@ -376,6 +376,7 @@ std::shared_ptr FrameMapper::GetOrCreateFrame(int64_t number) new_frame = std::make_shared(number, info.width, info.height, "#000000", samples_in_frame, reader->info.channels); new_frame->SampleRate(reader->info.sample_rate); new_frame->ChannelsLayout(info.channel_layout); + new_frame->AddAudioSilence(samples_in_frame); return new_frame; } diff --git a/src/Timeline.cpp b/src/Timeline.cpp index 71805837..19ae8a6f 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -578,8 +578,13 @@ void Timeline::update_open_clips(Clip *clip, bool does_clip_intersect) // Add clip to 'opened' list, because it's missing open_clips[clip] = clip; - // Open the clip - clip->Open(); + try { + // Open the clip + clip->Open(); + + } catch (const InvalidFile & e) { + // ... + } } // Debug output @@ -719,8 +724,7 @@ std::shared_ptr Timeline::GetFrame(int64_t requested_frame) #pragma omp parallel { // Loop through all requested frames - // The scheduler has to be static! - #pragma omp for ordered schedule(static,1) firstprivate(nearby_clips, requested_frame, minimum_frames) + #pragma omp for ordered firstprivate(nearby_clips, requested_frame, minimum_frames) schedule(static,1) for (int64_t frame_number = requested_frame; frame_number < requested_frame + minimum_frames; frame_number++) { // Debug output diff --git a/tests/FrameMapper_Tests.cpp b/tests/FrameMapper_Tests.cpp index 2f61179d..053df31f 100644 --- a/tests/FrameMapper_Tests.cpp +++ b/tests/FrameMapper_Tests.cpp @@ -199,9 +199,9 @@ TEST(FrameMapper_resample_audio_48000_to_41000) // Check details CHECK_EQUAL(1, map.GetFrame(1)->GetAudioChannelsCount()); - CHECK_EQUAL(882, map.GetFrame(1)->GetAudioSamplesCount()); - CHECK_EQUAL(882, map.GetFrame(2)->GetAudioSamplesCount()); - CHECK_EQUAL(882, map.GetFrame(50)->GetAudioSamplesCount()); + CHECK_CLOSE(882, map.GetFrame(1)->GetAudioSamplesCount(), 10.0); + CHECK_CLOSE(882, map.GetFrame(2)->GetAudioSamplesCount(), 10.0); + CHECK_CLOSE(882, map.GetFrame(50)->GetAudioSamplesCount(), 10.0); // Close mapper map.Close();