Permalink
Browse files

fix use of deprecated functions

  • Loading branch information...
1 parent 4ed2b7d commit 940645706132fd3f90130fb9a5eeb48cc54beb79 @wandenberg committed Dec 7, 2011
Showing with 32 additions and 8 deletions.
  1. +22 −6 README.textile
  2. +10 −2 src/ngx_http_video_thumbextractor_module_utils.c
View
@@ -1,7 +1,7 @@
h1(#nginx_video_thumbextractor_module). Nginx Video Thumb Extractor Module
Video Thumb Extractor is a module to extract an image from a video frame from a specific second resizing/cropping it to a given size.
-The smallest generated image is 16x16 pixels.
+The smallest generated image is ==16x16== pixels.
_This module is not distributed with the Nginx source. See "the installation instructions":installation._
@@ -15,22 +15,38 @@ This module is considered production ready.
h1(#requirements). Requirements
-This module depends from some libraries which has to be installed before it, like:
+This module depends from some libraries (headers and shared objects) which has to be installed before it:
-* avformat - commonly distributed with "FFmpeg":http://ffmpeg.org
-* avcodec - commonly distributed with "FFmpeg":http://ffmpeg.org
-* swscale - commonly distributed with "FFmpeg":http://ffmpeg.org
+* avformat >= 53.4.0 (tested versions: 53.4.0, 53.5.0) - commonly distributed with "FFmpeg":http://ffmpeg.org
+* avcodec >= 53.7.0 (tested versions: 53.7.0, 53.8.0) - commonly distributed with "FFmpeg":http://ffmpeg.org
+* swscale >= 2.0.0 (tested versions: 2.0.0) - commonly distributed with "FFmpeg":http://ffmpeg.org
* jpeg - "libjpeg":http://libjpeg.sourceforge.net
* MagickWand - commonly distributed with "ImageMagick":http://www.imagemagick.org
-*If you don't install FFmpeg from source you need to be sure that you have headers files for the libs avformat, avcodev and swscale. On Ubuntu, for example you may install libavformat-dev, libavcodec-dev and libswscale-dev packages*
+To install FFmpeg from source with the specified versions follow the steps bellow:
+
+<pre>
+ git clone git://git.videolan.org/ffmpeg
+ cd ffmpeg
+ git checkout -b n0.8.7
+ ./configure --prefix=/usr --disable-ffserver --disable-ffplay --enable-shared
+ make clean && make
+ make install
+</pre>
+
h1(#recommendation). Recommendation
By default ImageMagick uses OpenMP to process images in threads.
I recommend to configure/compile ImageMagick using the option _--disable-openmp_ since that is not a good idea use threads inside workers.
+h1(#supported_video_formats). Supported Video Formats
+
+This module uses the libraries avcodec and avformat to read the video files. Any supported video format for these libraries will work.
+Tested formats was _mp4_, _mov_ and _flv_.
+
+
h1(#installation). Installation
Install the above requirements and follow the steps bellow.
@@ -42,14 +42,18 @@ ngx_http_video_thumbextractor_get_thumb(ngx_http_video_thumbextractor_loc_conf_t
MagickBooleanType mrc;
// Open video file
- if ((rc = av_open_input_file(&pFormatCtx, filename, NULL, 0, NULL)) != 0) {
+ if ((rc = avformat_open_input(&pFormatCtx, filename, NULL, NULL)) != 0) {
ngx_log_error(NGX_LOG_ERR, log, 0, "video thumb extractor module: Couldn't open file %s, error: %d", filename, rc);
- rc = (rc == AVERROR_NOENT) ? NGX_HTTP_VIDEO_THUMBEXTRACTOR_FILE_NOT_FOUND : NGX_ERROR;
+ rc = (rc == AVERROR(NGX_ENOENT)) ? NGX_HTTP_VIDEO_THUMBEXTRACTOR_FILE_NOT_FOUND : NGX_ERROR;
goto exit;
}
// Retrieve stream information
+#if LIBAVFORMAT_VERSION_INT <= AV_VERSION_INT(53, 5, 0)
if (av_find_stream_info(pFormatCtx) < 0) {
+#else
+ if (avformat_find_stream_info(pFormatCtx, NULL) < 0) {
+#endif
ngx_log_error(NGX_LOG_ERR, log, 0, "video thumb extractor module: Couldn't find stream information");
rc = NGX_ERROR;
goto exit;
@@ -87,7 +91,11 @@ ngx_http_video_thumbextractor_get_thumb(ngx_http_video_thumbextractor_loc_conf_t
}
// Open codec
+#if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(53, 8, 0)
if ((rc = avcodec_open(pCodecCtx, pCodec)) < 0) {
+#else
+ if ((rc = avcodec_open2(pCodecCtx, pCodec, NULL)) < 0) {
+#endif
ngx_log_error(NGX_LOG_ERR, log, 0, "video thumb extractor module: Could not open codec, error %d", rc);
rc = NGX_ERROR;
goto exit;

0 comments on commit 9406457

Please sign in to comment.