
Recherche avancée
Autres articles (43)
-
La file d’attente de SPIPmotion
28 novembre 2010, parUne file d’attente stockée dans la base de donnée
Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...) -
Contribute to documentation
13 avril 2011Documentation is vital to the development of improved technical capabilities.
MediaSPIP welcomes documentation by users as well as developers - including : critique of existing features and functions articles contributed by developers, administrators, content producers and editors screenshots to illustrate the above translations of existing documentation into other languages
To contribute, register to the project users’ mailing (...) -
Use, discuss, criticize
13 avril 2011, parTalk to people directly involved in MediaSPIP’s development, or to people around you who could use MediaSPIP to share, enhance or develop their creative projects.
The bigger the community, the more MediaSPIP’s potential will be explored and the faster the software will evolve.
A discussion list is available for all exchanges between users.
Sur d’autres sites (6985)
-
Decoding VP8 On A Sega Dreamcast
20 février 2011, par Multimedia Mike — Sega Dreamcast, VP8I got Google’s libvpx VP8 codec library to compile and run on the Sega Dreamcast with its Hitachi/Renesas SH-4 200 MHz CPU. So give Google/On2 their due credit for writing portable software. I’m not sure how best to illustrate this so please accept this still photo depicting my testbench Dreamcast console driving video to my monitor :
Why ? Because I wanted to try my hand at porting some existing software to this console and because I tend to be most comfortable working with assorted multimedia software components. This seemed like it would be a good exercise.
You may have observed that the video is blue. Shortest, simplest answer : Pure laziness. Short, technical answer : Path of least resistance for getting through this exercise. Longer answer follows.
Update : I did eventually realize that the Dreamcast can work with YUV textures. Read more in my followup post.
Process and Pitfalls
libvpx comes with a number of little utilities includingdecode_to_md5.c
. The first order of business was porting over enough source files to make the VP8 decoder compile along with the MD5 testbench utility.Again, I used the KallistiOS (KOS) console RTOS (aside : I’m still working to get modern Linux kernels compiled for the Dreamcast). I started by configuring and compiling libvpx on a regular desktop Linux system. From there, I was able to modify a number of configuration options to make the build more amenable to the embedded RTOS.
I had to create a few shim header files that mapped various functions related to threading and synchronization to their KOS equivalents. For example, KOS has a threading library cleverly named kthreads which is mostly compatible with the more common pthread library functions. KOS apparently also predates stdint.h, so I had to contrive a file with those basic types.So I got everything compiled and then uploaded the binary along with a small VP8 IVF test vector. Imagine my surprise when an MD5 sum came out of the serial console. Further, visualize my utter speechlessness when I noticed that the MD5 sum matched what my desktop platform produced. It worked !
Almost. When I tried to decode all frames in a test vector, the program would invariably crash. The problem was that the file that manages motion compensation (reconinter.c) needs to define MUST_BE_ALIGNED which compiles byte-wise block copy functions. This is necessary for CPUs like the SH-4 which can’t load unaligned data. Apparently, even ARM CPUs these days can handle unaligned memory accesses which is why this isn’t a configure-time option.
Showing The Work
I completed the first testbench application which ran the MD5 test on all 17 official IVF test vectors. The SH-4/Dreamcast version aces the whole suite.However, this is a video game console, so I had better be able to show the decoded video. The Dreamcast is strictly RGB— forget about displaying YUV data directly. I could take the performance hit to convert YUV -> RGB. Or, I could just display the intensity information (Y plane) rendered on a random color scale (I chose blue) on an RGB565 texture (the DC’s graphics hardware can also do paletted textures but those need to be rearranged/twiddled/swizzled).
Results
So, can the Dreamcast decode VP8 video in realtime ? Sure ! Well, I really need to qualify. In the test depicted in the picture, it seems to be realtime (though I wasn’t enforcing proper frame timings, just decoding and displaying as quickly as possible). Obviously, I wasn’t bothering to properly convert YUV -> RGB. Plus, that Big Buck Bunny test vector clip is only 176x144. Obviously, no audio decoding either.So, realtime playback, with a little fine print.
On the plus side, it’s trivial to get the Dreamcast video hardware to upscale that little blue image to fullscreen.
I was able to tally the total milliseconds’ worth of wall clock time required to decode the 17 VP8 test vectors. As you can probably work out from this list, when I try to play a 320x240 video, things start to break down.
- Processed 29 176x144 frames in 987 milliseconds.
- Processed 49 176x144 frames in 1809 milliseconds.
- Processed 49 176x144 frames in 704 milliseconds.
- Processed 29 176x144 frames in 255 milliseconds.
- Processed 49 176x144 frames in 339 milliseconds.
- Processed 48 175x143 frames in 2446 milliseconds.
- Processed 29 176x144 frames in 432 milliseconds.
- Processed 2 1432x888 frames in 2060 milliseconds.
- Processed 49 176x144 frames in 1884 milliseconds.
- Processed 57 320x240 frames in 5792 milliseconds.
- Processed 29 176x144 frames in 989 milliseconds.
- Processed 29 176x144 frames in 740 milliseconds.
- Processed 29 176x144 frames in 839 milliseconds.
- Processed 49 175x143 frames in 2849 milliseconds.
- Processed 260 320x240 frames in 29719 milliseconds.
- Processed 29 176x144 frames in 962 milliseconds.
- Processed 29 176x144 frames in 933 milliseconds.
-
Encode Frames to Video with C Library
31 juillet 2018, par NetherGraniteFor the sake of continuity, let us assume "RGB values" are the following :
typedef struct RGB {
uint8_t r, g, b;
} rgb;However, if you feel that a different color space is more appropriate for this question, please use that instead.
How might I go about writing 2D arrays of RGB values to a video in C given an output format and framerate ?
Before I continue, I should specify that I wish to be able to do this all within one program. I am trying to add functionality to an application that would allow it to compile videos frame by frame without having to leave it.
Additionally, my needs for this functionality are extremely basic ; I simply need to be able to set individual pixels to certain colors.
The closest I have come to a solution so far is the C library FFmpeg. Allow me to describe what I was able to learn on my own :
After looking through its documentation, I came across the function
avcodec_send_frame(avctx, frame)
, whose parameters are of the typesAVCodexContext*
andconst AVFrame*
respectively. If these are not the right tools for what I am trying to do, please ignore the rest of the question and instead point me towards what I should be using.However, I do not know which fields of
avctx
andframe
must be set manually and which do not. The reason I assume some do not is because both are extremely large structures, but correct me if I am wrong.Question 1 : What values of an
AVCodecContext
andAVFrame
must be set ? Of these, what is/are the recommended value(s) for each of them ?Additionally, I was only able to find instructions on how to initialize an
AVFrame
(usingav_frame_alloc()
andav_frame_get_buffer()
) but not for anAVCodexConstant
.Question 2 : Is there a proper way to initialize an
AVCodexConstant
? And just in case, is the method of initializing anAVFrame
described above correct ? Do any of the fields of either have a proper method of initialization ?Also, I was not able to find official documentation on how to take this
AVCodexConstant
(which I assume contains the video information) and turn it into a video. I apologize if the documentation for this is easy to find and I just missed it.Question 3 : How do I turn an
AVCodexConstant
into a file of a given format ?And, given my limited knowledge :
Question 4 : Are there any other parts to this process that I am missing, and do I have any of the above parts wrong ?
Please keep in mind that I found out about FFmpeg for the first time very recently, and as a result, I am a complete beginner to this. Additionally, my experience with C is very limited, so I would greatly appreciate it if you could note which files need to be included with
#include
.Feel free to even go as far as recommending something other than FFmpeg, just as long as it is written in C. I do not need power-user options, but I would greatly prefer flexibility in what audio and video file types the library can handle.
Addressing Potential Duplicates
I appologize for how long this section is ; I just want to have my bases covered. I heavily apologize, however, if this is in fact a duplicate of a question that I was just unable to find.
- ffmpeg C API documentation/tutorial [closed] — This question was too open-ended and received answers pointing the asker towards a tutorial at dranger.com, a tutorial that confusingly muddied the waters by focusing heavily on a graphics library of choice. Please do not take this as me saying it is bad ; I am just enough of a beginner that I could not wade through it all.
- Encoding frames to video with ffmpeg — Although this question seems to have been asking the same thing, it is geared towards Unreal Engine 4, and the asker provided sample code, making it difficult for me to understand which of parts of the accepted answer were necessary for me and which were not.
- How to write frames to a video file ? — While this also asked the same thing, the accepted answer simply provides a command instead of an explanation of code.
- YUV Raw frames to video stream — While the accepted answer for this question is a command, the question states that it is looking for a way to encode frames generated by C++ code. Is there some way to run commands in code that I haven’t been able to find ?
- Converting sequenced frames to video — Not only is the asker’s code written in Python, but it also seems to use already-existing image files as frames.
- How to write bitmaps as frames to H.264 with x264 in C\C++ ? — The accepted answer seems to describe a process that would take multiple applications, but I could be wrong as I am enough of a beginner that I am not sure exactly what it means other than Step 3.
- How to write bitmaps as frames to Ogg Theora in C\C++ ? — Although it isn’t a problem that the question specifies the ogg format, it is a problem that the accepted answer suggests libtheora, which appears to only work with ogg files.
-
Compile Shotdetect on CentOS 7
14 septembre 2015, par BitLegacy01I’m migrating a service from a Debian server to a CentOS 7 one.
The service needs the Shotdetect command (github , official site).
I could not make it work on CentOS though I followed all steps :
-
Compile ffmpeg compilation guide
# ffmpeg
ffmpeg version git-2015-08-21-7a806c6 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.8.3 (GCC) 20140911 (Red Hat 4.8.3-9)
configuration: --prefix=/root/ffmpeg_build --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --bindir=/root/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libfreetype --disable-libmp3lame --disable-libopus --disable-libvorbis --disable-libvpx --enable-libx264 --disable-libx265 --disable-lzma
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 58.100 / 56. 58.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 36.100 / 5. 36.100
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...-
Install needed packages
# yum install gd-devel libxml2-devel libxslt-devel clang libvpx libvorbis
-
Add pthread in the CMakeList file, in TARGET_LINK_LIBRARIES, because it throws an lpthread missing in linker error
-
Compile Shotdetect
# FFMPEG_DIR="/root/ffmpeg_build" ./compile.sh cmd
-
5.Lost in contemplation
-- avformat library found: /root/ffmpeg_build/lib/libavformat.a
-- avcodec library found: /root/ffmpeg_build/lib/libavcodec.a
-- avutil library found: /root/ffmpeg_build/lib/libavutil.a
-- swscale library found: /root/ffmpeg_build/lib/libswscale.a
Found all FFmpeg libraries in /root/ffmpeg_build/lib/libavformat.a;/root/ffmpeg_build/lib/libavdevice.a;/root/ffmpeg_build/lib/libavcodec.a;/root/ffmpeg_build/lib/libavutil.a;/root/ffmpeg_build/lib/libswscale.a.
-- Found GD: /usr/lib64/libgd.so
Found libgd: /usr/lib64/libgd.so;/usr/lib64/libpng.so;/usr/lib64/libz.so;/usr/lib64/libjpeg.so in /usr/include
Found libxml2: /usr/lib64/libxml2.so in /usr/include/libxml2
Found libxslt: /usr/lib64/libxslt.so in /usr/include
-- Configuring done
-- Generating done
-- Build files have been written to: /root/Shotdetect-master/build
[ 71%] Built target shotdetect
Linking CXX executable shotdetect-cmd
/root/ffmpeg_build/lib/libavcodec.a(libfdk-aacdec.o): in the function « fdk_aac_decode_frame »:
/root/ffmpeg_sources/ffmpeg/libavcodec/libfdk-aacdec.c:323: undefined reference to « aacDecoder_Fill »
/root/ffmpeg_sources/ffmpeg/libavcodec/libfdk-aacdec.c:329: undefined reference to « aacDecoder_DecodeFrame »
/root/ffmpeg_build/lib/libavcodec.a(libfdk-aacdec.o): in the function « get_stream_info »:
/root/ffmpeg_sources/ffmpeg/libavcodec/libfdk-aacdec.c:88: undefined reference to « aacDecoder_GetStreamInfo »
/root/ffmpeg_build/lib/libavcodec.a(libfdk-aacdec.o): in the function « fdk_aac_decode_close »:
/root/ffmpeg_sources/ffmpeg/libavcodec/libfdk-aacdec.c:201: undefined reference to « aacDecoder_Close »
/root/ffmpeg_build/lib/libavcodec.a(libfdk-aacdec.o): in the function « fdk_aac_decode_init »:
/root/ffmpeg_sources/ffmpeg/libavcodec/libfdk-aacdec.c:214: undefined reference to « aacDecoder_Open »
/root/ffmpeg_sources/ffmpeg/libavcodec/libfdk-aacdec.c:221: undefined reference to « aacDecoder_ConfigRaw »
/root/ffmpeg_sources/ffmpeg/libavcodec/libfdk-aacdec.c:228: undefined reference to « aacDecoder_SetParam »
/root/ffmpeg_sources/ffmpeg/libavcodec/libfdk-aacdec.c:252: undefined reference to « aacDecoder_SetParam »
/root/ffmpeg_sources/ffmpeg/libavcodec/libfdk-aacdec.c:270: undefined reference to « aacDecoder_SetParam »
/root/ffmpeg_sources/ffmpeg/libavcodec/libfdk-aacdec.c:277: undefined reference to « aacDecoder_SetParam »
/root/ffmpeg_sources/ffmpeg/libavcodec/libfdk-aacdec.c:284: undefined reference to « aacDecoder_SetParam »
/root/ffmpeg_build/lib/libavcodec.a(libfdk-aacdec.o):/root/ffmpeg_sources/ffmpeg/libavcodec/libfdk-aacdec.c:291: encore plus de références indéfinies suivent vers « aacDecoder_SetParam »
/root/ffmpeg_build/lib/libavcodec.a(libfdk-aacdec.o): in the function « fdk_aac_decode_init »:
/root/ffmpeg_sources/ffmpeg/libavcodec/libfdk-aacdec.c:261: undefined reference to « aacDecoder_AncDataInit »
/root/ffmpeg_build/lib/libavcodec.a(libfdk-aacdec.o): in the function « fdk_aac_decode_flush »:
/root/ffmpeg_sources/ffmpeg/libavcodec/libfdk-aacdec.c:367: undefined reference to « aacDecoder_SetParam »
/root/ffmpeg_build/lib/libavcodec.a(libfdk-aacenc.o): in the function « aac_encode_close »:
/root/ffmpeg_sources/ffmpeg/libavcodec/libfdk-aacenc.c:97: undefined reference to « aacEncClose »
/root/ffmpeg_build/lib/libavcodec.a(libfdk-aacenc.o): in the function « aac_encode_frame »:
/root/ffmpeg_sources/ffmpeg/libavcodec/libfdk-aacenc.c:357: undefined reference to « aacEncEncode »
/root/ffmpeg_build/lib/libavcodec.a(libfdk-aacenc.o): in the function « aac_encode_init »:
/root/ffmpeg_sources/ffmpeg/libavcodec/libfdk-aacenc.c:114: undefined reference to « aacEncOpen »
/root/ffmpeg_sources/ffmpeg/libavcodec/libfdk-aacenc.c:123: undefined reference to « aacEncoder_SetParam »
/root/ffmpeg_sources/ffmpeg/libavcodec/libfdk-aacenc.c:130: undefined reference to « aacEncoder_SetParam »
/root/ffmpeg_sources/ffmpeg/libavcodec/libfdk-aacenc.c:138: undefined reference to « aacEncoder_SetParam »
/root/ffmpeg_sources/ffmpeg/libavcodec/libfdk-aacenc.c:172: undefined reference to « aacEncoder_SetParam »
/root/ffmpeg_sources/ffmpeg/libavcodec/libfdk-aacenc.c:179: undefined reference to « aacEncoder_SetParam »
/root/ffmpeg_build/lib/libavcodec.a(libfdk-aacenc.o):/root/ffmpeg_sources/ffmpeg/libavcodec/libfdk-aacenc.c:197: encore plus de références indéfinies suivent vers « aacEncoder_SetParam »
/root/ffmpeg_build/lib/libavcodec.a(libfdk-aacenc.o): in the function « aac_encode_init »:
/root/ffmpeg_sources/ffmpeg/libavcodec/libfdk-aacenc.c:276: undefined reference to « aacEncEncode »
/root/ffmpeg_sources/ffmpeg/libavcodec/libfdk-aacenc.c:282: undefined reference to « aacEncInfo »
/root/ffmpeg_build/lib/libavcodec.a(libx264.o): in the function « X264_frame »:
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:260: undefined reference to « x264_picture_init »
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:262: undefined reference to « x264_bit_depth »
/root/ffmpeg_build/lib/libavcodec.a(libx264.o): in the function « reconfig_encoder »:
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:246: undefined reference to « x264_encoder_reconfig »
/root/ffmpeg_build/lib/libavcodec.a(libx264.o): in the function « X264_frame »:
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:283: undefined reference to « x264_encoder_encode »
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:289: undefined reference to « x264_encoder_delayed_frames »
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:283: undefined reference to « x264_encoder_encode »
/root/ffmpeg_build/lib/libavcodec.a(libx264.o): in the function « reconfig_encoder »:
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:173: undefined reference to « x264_encoder_reconfig »
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:178: undefined reference to « x264_encoder_reconfig »
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:185: undefined reference to « x264_encoder_reconfig »
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:205: undefined reference to « x264_encoder_reconfig »
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:211: undefined reference to « x264_encoder_reconfig »
/root/ffmpeg_build/lib/libavcodec.a(libx264.o):/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:191: encore plus de références indéfinies suivent vers « x264_encoder_reconfig »
/root/ffmpeg_build/lib/libavcodec.a(libx264.o): in the function « X264_init_static »:
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:806: undefined reference to « x264_bit_depth »
/root/ffmpeg_build/lib/libavcodec.a(libx264.o): in the function « X264_close »:
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:339: undefined reference to « x264_encoder_close »
/root/ffmpeg_build/lib/libavcodec.a(libx264.o): in the function « X264_init »:
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:413: undefined reference to « x264_param_default »
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:418: undefined reference to « x264_param_default_preset »
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:440: undefined reference to « x264_param_parse »
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:470: undefined reference to « x264_param_parse »
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:514: undefined reference to « x264_levels »
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:516: undefined reference to « x264_levels »
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:540: undefined reference to « x264_param_parse »
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:541: undefined reference to « x264_param_parse »
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:542: undefined reference to « x264_param_parse »
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:543: undefined reference to « x264_param_parse »
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:601: undefined reference to « x264_param_apply_fastfirstpass »
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:651: undefined reference to « x264_param_apply_profile »
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:703: undefined reference to « x264_param_parse »
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:705: undefined reference to « x264_param_parse »
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:717: undefined reference to « x264_param_parse »
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:735: undefined reference to « x264_encoder_open_148 »
/root/ffmpeg_sources/ffmpeg/libavcodec/libx264.c:744: undefined reference to « x264_encoder_headers »
/root/ffmpeg_build/lib/libavcodec.a(opusdec.o): in the function « opus_decode_subpacket »:
/root/ffmpeg_sources/ffmpeg/libavcodec/opusdec.c:379: undefined reference to « swr_is_initialized »
/root/ffmpeg_build/lib/libavcodec.a(opusdec.o): in the function « opus_decode_frame »:
/root/ffmpeg_sources/ffmpeg/libavcodec/opusdec.c:220: undefined reference to « swr_is_initialized »
/root/ffmpeg_build/lib/libavcodec.a(opusdec.o): in the function « opus_init_resample »:
/root/ffmpeg_sources/ffmpeg/libavcodec/opusdec.c:161: undefined reference to « swr_init »
/root/ffmpeg_sources/ffmpeg/libavcodec/opusdec.c:167: undefined reference to « swr_convert »
/root/ffmpeg_build/lib/libavcodec.a(opusdec.o): in the function « opus_decode_frame »:
/root/ffmpeg_sources/ffmpeg/libavcodec/opusdec.c:234: undefined reference to « swr_convert »
/root/ffmpeg_build/lib/libavcodec.a(opusdec.o): in the function « opus_flush_resample »:
/root/ffmpeg_sources/ffmpeg/libavcodec/opusdec.c:115: undefined reference to « swr_convert »
/root/ffmpeg_build/lib/libavcodec.a(opusdec.o): in the function « opus_decode_subpacket »:
/root/ffmpeg_sources/ffmpeg/libavcodec/opusdec.c:411: undefined reference to « swr_close »
/root/ffmpeg_build/lib/libavcodec.a(opusdec.o): in the function « opus_decode_flush »:
/root/ffmpeg_sources/ffmpeg/libavcodec/opusdec.c:614: undefined reference to « swr_close »
/root/ffmpeg_build/lib/libavcodec.a(opusdec.o): in the function « opus_decode_close »:
/root/ffmpeg_sources/ffmpeg/libavcodec/opusdec.c:638: undefined reference to « swr_free »
/root/ffmpeg_build/lib/libavcodec.a(opusdec.o): in the function « opus_decode_init »:
/root/ffmpeg_sources/ffmpeg/libavcodec/opusdec.c:705: undefined reference to « swr_alloc »
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [shotdetect-cmd] Error 1
make[1]: *** [CMakeFiles/shotdetect-cmd.dir/all] Error 2
make: *** [all] Error 2I’ve done a lot of research about the above errors but I didn’t find any clue.
How to compile successfully Shotdetect on CentOS7 ?
Thanks to tryp here is a working CMakelist file :
# CMake integration by Christian Frisson
cmake_minimum_required(VERSION 2.8)
PROJECT(shotdetect)
SET(CMAKE_C_COMPILER "/usr/bin/clang")
SET(CMAKE_CXX_COMPILER "/usr/bin/clang++")
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
# Get git version information for automatic embedding in version string:
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
# Take the first 12 characters of the SHA1 as short identifier:
STRING(SUBSTRING ${GIT_SHA1} 0 11 GIT_SHA1_SHORT)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/version.cc.in" "${CMAKE_CURRENT_BINARY_DIR}/version.cc" @ONLY)
list(APPEND SOURCES "${CMAKE_CURRENT_BINARY_DIR}/version.cc" src/version.h)
# Miscellaneous compilation options:
OPTION(USE_WXWIDGETS "Compile GUI app with wxWidgets, otherwise commandline app" ON)
OPTION(USE_POSTGRESQL "Compile with PostgreSQL support" OFF)
# Dependency: pkg-config (required if cross-compiling with MXE)
IF ( MINGW AND CMAKE_TOOLCHAIN_FILE)
FIND_PACKAGE (PkgConfig)
IF(NOT PKG_CONFIG_FOUND)
MESSAGE(FATAL_ERROR "pkgconfig required for cross-compiling with MXE for windows")
ENDIF()
SET(PKG_CONFIG_EXECUTABLE ${PKG_CONFIG_EXECUTABLE} CACHE STRING "pkg-config")
ENDIF()
# Dependency: FFmpeg (required)
FIND_PACKAGE( FFmpeg )
IF ( MINGW AND CMAKE_TOOLCHAIN_FILE)
PKG_CHECK_MODULES (FFMPEG_PKG REQUIRED libavcodec libavfilter libavutil libavdevice libavformat libavformat libswscale)
IF (FFMPEG_PKG_FOUND)
MESSAGE( "FFmpeg cflags found through pkg-config: ${FFMPEG_PKG_CFLAGS}" )
MESSAGE( "FFmpeg ldflags found through pkg-config: ${FFMPEG_PKG_LDFLAGS}" )
STRING(REGEX REPLACE ";" " " FFMPEG_PKG_CFLAGS "${FFMPEG_PKG_CFLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FFMPEG_PKG_CFLAGS}")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FFMPEG_PKG_CFLAGS}")
SET(FFMPEG_LIBRARIES ${FFMPEG_LIBRARY} ${FFMPEG_PKG_LDFLAGS})
MESSAGE("FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES}")
ELSE (FFMPEG_PKG_FOUND)
MESSAGE( FATAL_ERROR "FFmpeg cflags/ldflags not found through pkg-config." )
ENDIF (FFMPEG_PKG_FOUND)
ENDIF()
IF(FFMPEG_LIBAVFORMAT_FOUND)
MESSAGE(STATUS "avformat library found: ${FFMPEG_LIBAVFORMAT_LIBRARIES}")
ELSE()
MESSAGE(STATUS "avformat library not found.")
ENDIF()
IF(FFMPEG_LIBAVCODEC_FOUND)
MESSAGE(STATUS "avcodec library found: ${FFMPEG_LIBAVCODEC_LIBRARIES}")
ELSE()
MESSAGE(STATUS "avcodec library not found.")
ENDIF()
IF(FFMPEG_LIBAVUTIL_FOUND)
MESSAGE(STATUS "avutil library found: ${FFMPEG_LIBAVUTIL_LIBRARIES}")
ELSE()
MESSAGE(STATUS "avutil library not found.")
ENDIF()
IF(FFMPEG_LIBSWSCALE_FOUND)
MESSAGE(STATUS "swscale library found: ${FFMPEG_LIBSWSCALE_LIBRARIES}")
ELSE()
MESSAGE(STATUS "swscale library not found.")
ENDIF()
IF(FFMPEG_FOUND)
INCLUDE_DIRECTORIES(${FFMPEG_INCLUDE_DIR} ${FFMPEG_INCLUDE_DIRS})
SET(FFMPEG_LIBRARIES "${FFMPEG_LIBRARIES};/root/ffmpeg_build/lib/libswresample.a;/root/ffmpeg_build/lib/libx264.a;/lib64/libdl.so.2;/root/ffmpeg_build/lib/libfdk-aac.a;/root/ffmpeg_build/lib/libswresample.a")
MESSAGE("Found all FFmpeg libraries in ${FFMPEG_LIBRARIES}.")
ELSE()
MESSAGE(FATAL_ERROR "Some FFmpeg libraries are missing.")
ENDIF()
# Dependency: GD (required)
FIND_PACKAGE(GD REQUIRED)
IF ( MINGW AND CMAKE_TOOLCHAIN_FILE)
EXEC_PROGRAM(${CMAKE_FIND_ROOT_PATH}/bin/gdlib-config ARGS "--cflags" OUTPUT_VARIABLE GD_PKG_CFLAGS)
EXEC_PROGRAM(${CMAKE_FIND_ROOT_PATH}/bin/gdlib-config ARGS "--libs" OUTPUT_VARIABLE GD_PKG_LDFLAGS)
MESSAGE( "gd cflags found through gdlib-config: ${GD_PKG_CFLAGS}" )
MESSAGE( "gd ldflags found through gdlib-config: ${GD_PKG_LDFLAGS}" )
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GD_PKG_CFLAGS}")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GD_PKG_CFLAGS}")
SET(GD_LIBRARIES ${GD_LIBRARY} ${GD_PKG_LDFLAGS})
MESSAGE("GD_LIBRARIES ${GD_LIBRARIES}")
ENDIF()
IF(GD_FOUND)
INCLUDE_DIRECTORIES(${GD_INCLUDE_DIR})
MESSAGE("Found libgd: ${GD_LIBRARIES} in ${GD_INCLUDE_DIR}")
ELSE()
MESSAGE(FATAL_ERROR "Couldn't find libgd")
ENDIF()
# Dependency: libxml2 (required)
FIND_PACKAGE(LibXml2 2.7 REQUIRED)
IF ( MINGW AND CMAKE_TOOLCHAIN_FILE)
PKG_CHECK_MODULES (LIBXML2_PKG REQUIRED libxml-2.0)
IF (LIBXML2_PKG_FOUND)
MESSAGE( "LibXml2 cflags found through pkg-config: ${LIBXML2_PKG_CFLAGS}" )
MESSAGE( "LibXml2 ldflags found through pkg-config: ${LIBXML2_PKG_LDFLAGS}" )
STRING(REGEX REPLACE ";" " " LIBXML2_PKG_CFLAGS "${LIBXML2_PKG_CFLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBXML2_PKG_CFLAGS}")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBXML2_PKG_CFLAGS}")
SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARY} ${LIBXML2_PKG_LDFLAGS})
MESSAGE("LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES}")
ELSE (LIBXML2_PKG_FOUND)
MESSAGE( FATAL_ERROR "LibXml2 cflags/ldflags not found through pkg-config." )
ENDIF (LIBXML2_PKG_FOUND)
ENDIF()
IF(LIBXML2_FOUND)
MESSAGE("Found libxml2: ${LIBXML2_LIBRARIES} in ${LIBXML2_INCLUDE_DIR}")
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR})
ELSE()
MESSAGE(FATAL_ERROR "Couldn't find libxml2")
ENDIF()
# Dependency: libxslt (required)
FIND_PACKAGE(LibXslt REQUIRED)
IF(LIBXSLT_FOUND)
MESSAGE("Found libxslt: ${LIBXSLT_LIBRARIES} in ${LIBXSLT_INCLUDE_DIR}")
INCLUDE_DIRECTORIES(${LIBXSLT_INCLUDE_DIR})
ELSE()
MESSAGE(FATAL_ERROR "Couldn't find libxslt")
ENDIF()
# Dependency: wxWidgets (optional)
IF(USE_WXWIDGETS)
FIND_PACKAGE(wxWidgets)# COMPONENTS core base)
IF(wxWidgets_FOUND)
MESSAGE("Found wxWidgets: ${wxWidgets_LIBRARIES} in ${wxWidgets_INCLUDE_DIRS}")
INCLUDE_DIRECTORIES(${wxWidgets_INCLUDE_DIRS})
ADD_DEFINITIONS(-DWXWIDGETS)
INCLUDE("${wxWidgets_USE_FILE}")
ELSE()
MESSAGE(FATAL_ERROR "Couldn't find wxWidgets. Set USE_WXWIDGETS to OFF or install wxWidgets.")
ENDIF()
ENDIF()
# Dependency: PostgreSQL (optional)
IF(USE_POSTGRESQL)
FIND_PACKAGE(PostgreSQL)
IF(PostgreSQL_FOUND)
MESSAGE("Found PostgreSQL: ${PostgreSQL_LIBRARIES} in ${PostgreSQL_INCLUDE_DIR}")
INCLUDE_DIRECTORIES(${PostgreSQL_INCLUDE_DIR})
ELSE()
MESSAGE(FATAL_ERROR "Couldn't find PostgreSQL. Set USE_POSTGRESQL to OFF or install PostgreSQL.")
ENDIF()
ENDIF()
# shotdetect
SET(TARGET_NAME "shotdetect")
INCLUDE_DIRECTORIES(.)
# shotdetect library
SET(${TARGET_NAME}_LIBRARY_SRCS src/film.cc src/graph.cc src/image.cc src/shot.cc src/xml.cc)
SET(${TARGET_NAME}_LIBRARY_HDRS src/film.h src/graph.h src/image.h src/shot.h src/xml.h)
IF(USE_POSTGRESQL)
SET(${TARGET_NAME}_LIBRARY_SRCS ${${TARGET_NAME}_LIBRARY_SRCS} src/bdd.cc)
SET(${TARGET_NAME}_LIBRARY_HDRS ${${TARGET_NAME}_LIBRARY_HDRS} src/bdd.h)
ENDIF()
ADD_LIBRARY(${TARGET_NAME} ${${TARGET_NAME}_LIBRARY_SRCS} ${${TARGET_NAME}_LIBRARY_HDRS})
TARGET_LINK_LIBRARIES(${TARGET_NAME} ${FFMPEG_LIBRARIES} ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${GD_LIBRARIES} "pthread" "m" "z")
IF(USE_WXWIDGETS AND wxWidgets_FOUND)
TARGET_LINK_LIBRARIES(${TARGET_NAME} ${wxWidgets_LIBRARIES})
ENDIF()
IF(USE_POSTGRESQL AND PostgreSQL_FOUND)
TARGET_LINK_LIBRARIES(${TARGET_NAME} ${PostgreSQL_LIBRARY})
ENDIF()
# shotdetect application: gui or commandline
IF(APPLE)
SET(APP_TYPE "MACOSX_BUNDLE")
ELSEIF(WIN32)
SET(APP_TYPE "WIN32")
ENDIF()
IF(USE_WXWIDGETS AND wxWidgets_FOUND)
LIST(APPEND ${TARGET_NAME}_GUI_SRCS src/main.cc src/ui/dialog_help.cc src/ui/dialog_shotdetect.cc src/ui/process_video_thread.cc)
LIST(APPEND ${TARGET_NAME}_GUI_HDRS src/ui/dialog_help.h src/ui/dialog_shotdetect.h src/ui/process_video_thread.h)
ADD_EXECUTABLE(${TARGET_NAME}-gui ${APP_TYPE} ${SOURCES} ${${TARGET_NAME}_GUI_SRCS} ${${TARGET_NAME}_GUI_HDRS})
TARGET_LINK_LIBRARIES(${TARGET_NAME}-gui ${TARGET_NAME})
# Make this target optional to install:
SET(TARGETS_TO_INSTALL ${TARGET_NAME}-gui)
ELSE()
LIST(APPEND ${TARGET_NAME}_COMMANDLINE_SRCS src/commandline.cc)
ADD_EXECUTABLE(${TARGET_NAME}-cmd ${SOURCES} ${${TARGET_NAME}_COMMANDLINE_SRCS})
TARGET_LINK_LIBRARIES(${TARGET_NAME}-cmd ${TARGET_NAME})
# Make this target optional to install:
SET(TARGETS_TO_INSTALL ${TARGET_NAME}-cmd)
ENDIF()
# Routines for installing shotdetect.
# Taken from official documentation (http://www.cmake.org/cmake/help/cmake2.6docs.html#command:install)
install(
TARGETS ${TARGETS_TO_INSTALL}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/static
)the built binary will be in the built directory, you can move there and execute
make install
to make the binary system wide.
-