Skip to content
Newer
Older
100644 206 lines (124 sloc) 6.18 KB
6fdd9a6 @wandenberg updating documentation
authored
1 h1(#nginx_video_thumbextractor_module). Nginx Video Thumb Extractor Module
fe9f810 @wandenberg Initial version of nginx module to extract thumbs from a video file
authored
2
6fdd9a6 @wandenberg updating documentation
authored
3 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.
9406457 @wandenberg fix use of deprecated functions
authored
4 The smallest generated image is ==16x16== pixels.
fe9f810 @wandenberg Initial version of nginx module to extract thumbs from a video file
authored
5
6fdd9a6 @wandenberg updating documentation
authored
6 _This module is not distributed with the Nginx source. See "the installation instructions":installation._
fe9f810 @wandenberg Initial version of nginx module to extract thumbs from a video file
authored
7
6fdd9a6 @wandenberg updating documentation
authored
8 Available on github at "nginx-video-thumbextractor-module":repository
fe9f810 @wandenberg Initial version of nginx module to extract thumbs from a video file
authored
9
10
6fdd9a6 @wandenberg updating documentation
authored
11 h1(#status). Status
12
13 This module is considered production ready.
14
15
16 h1(#requirements). Requirements
17
9406457 @wandenberg fix use of deprecated functions
authored
18 This module depends from some libraries (headers and shared objects) which has to be installed before it:
6fdd9a6 @wandenberg updating documentation
authored
19
9406457 @wandenberg fix use of deprecated functions
authored
20 * avformat >= 53.4.0 (tested versions: 53.4.0, 53.5.0) - commonly distributed with "FFmpeg":http://ffmpeg.org
21 * avcodec >= 53.7.0 (tested versions: 53.7.0, 53.8.0) - commonly distributed with "FFmpeg":http://ffmpeg.org
c2d3298 @wandenberg turn explicitly the library avutil dependancy
authored
22 * avutil >= 51.9.1 (tested versions: 51.9.1, 51.30.0) - commonly distributed with "FFmpeg":http://ffmpeg.org
9406457 @wandenberg fix use of deprecated functions
authored
23 * swscale >= 2.0.0 (tested versions: 2.0.0) - commonly distributed with "FFmpeg":http://ffmpeg.org
6fdd9a6 @wandenberg updating documentation
authored
24 * jpeg - "libjpeg":http://libjpeg.sourceforge.net
25 * MagickWand - commonly distributed with "ImageMagick":http://www.imagemagick.org
26
9406457 @wandenberg fix use of deprecated functions
authored
27 To install FFmpeg from source with the specified versions follow the steps bellow:
28
29 <pre>
30 git clone git://git.videolan.org/ffmpeg
31 cd ffmpeg
992df26 @wandenberg make install command of ffmpeg more reliable
authored
32 git checkout n0.8.7 -b tag_n0.8.7
9406457 @wandenberg fix use of deprecated functions
authored
33 ./configure --prefix=/usr --disable-ffserver --disable-ffplay --enable-shared
34 make clean && make
35 make install
36 </pre>
37
6fdd9a6 @wandenberg updating documentation
authored
38
223ca26 @wandenberg adding recomendation about ImageMagick
authored
39 h1(#recommendation). Recommendation
40
41 By default ImageMagick uses OpenMP to process images in threads.
42 I recommend to configure/compile ImageMagick using the option _--disable-openmp_ since that is not a good idea use threads inside workers.
43
44
9406457 @wandenberg fix use of deprecated functions
authored
45 h1(#supported_video_formats). Supported Video Formats
46
47 This module uses the libraries avcodec and avformat to read the video files. Any supported video format for these libraries will work.
48 Tested formats was _mp4_, _mov_ and _flv_.
49
50
6fdd9a6 @wandenberg updating documentation
authored
51 h1(#installation). Installation
52
53 Install the above requirements and follow the steps bellow.
54
55 <pre>
56 # clone the project
57 git clone http://github.com/wandenberg/nginx-video-thumbextractor-module.git
58 NGINX_VIDEO_THUMBEXTRACTOR_MODULE_PATH=$PWD/nginx-video-thumbextractor-module
59
60 # get desired nginx version (tested with 1.0.x series)
61 wget http://nginx.org/download/nginx-1.0.10.tar.gz
62
63 # unpack, configure and build
64 tar xzvf nginx-1.0.10.tar.gz
65 cd nginx-1.0.10
66 # configure nginx specifying the path where are MagickWand headers
67 ./configure --add-module=../nginx-video-thumbextractor-module --with-cc-opt='-I /usr/include/ImageMagick'
68 make
69
70 # install and finish
71 sudo make install
72
73 # check
74 sudo /usr/local/nginx/sbin/nginx -v
75 nginx version: nginx/1.0.10
76
77 # test configuration
78 sudo /usr/local/nginx/sbin/nginx -c $NGINX_VIDEO_THUMBEXTRACTOR_MODULE_PATH/nginx.conf -t
79 the configuration file $NGINX_VIDEO_THUMBEXTRACTOR_MODULE_PATH/nginx.conf syntax is ok
80 configuration file $NGINX_VIDEO_THUMBEXTRACTOR_MODULE_PATH/nginx.conf test is successful
81
82 # run
83 sudo /usr/local/nginx/sbin/nginx -c $NGINX_VIDEO_THUMBEXTRACTOR_MODULE_PATH/nginx.conf
84 </pre>
85
86 h1(#basic-configuration). Basic Configuration
87
88 <pre>
89 location ~ /thumbs(.*) {
90 video_thumbextractor;
91 video_thumbextractor_video_filename $1;
92 video_thumbextractor_video_second $arg_second;
93 video_thumbextractor_image_width $arg_width;
94 video_thumbextractor_image_height $arg_height;
95 }
96 </pre>
97
98
99 h1(#basic-usage). Basic Usage
100
101 Assuming that you have a file called _video.mp4_ on your root folder use a browser to test the following urls:
102
103 <pre>
104 # get an image from second 10 with the original size
105 http://localhost/thumbs/video.mp4?second=10
106
107 # get an image from second 20 with a 50px of height and proportional width keeping video scale
108 http://localhost/thumbs/video.mp4?second=10&height=50
109
110 # get an image from second 30 with a 50px of height and 100px of width, the image will be cropped to keep video scale
111 http://localhost/thumbs/video.mp4?second=20&height=50&width=100
112 </pre>
113
114
115 h1(#directives). Directives
116
117
118 h2(#video_thumbextractor). video_thumbextractor
119
120 *syntax:* _video_thumbextractor_
121
122 *context:* _location_
123
124 *release version:* _0.1.0_
125
126 Set Video Thumb Extractor as the request handler for the location.
127
128
129 h2(#video_thumbextractor_video_filename). video_thumbextractor_video_filename
130
131 *syntax:* _video_thumbextractor_video_filename filename_
132
133 *default:* _none_
134
135 *context:* _http_
136
137 *release version:* _0.1.0_
138
139 The video filename relative to root folder.
140 This directive is required.
141 Return a 404 if the video is not found.
142
143
144 h2(#video_thumbextractor_video_second). video_thumbextractor_video_second
145
146 *syntax:* _video_thumbextractor_video_second second_
147
148 *default:* _none_
149
150 *context:* _http_
151
152 *release version:* _0.1.0_
153
154 The time in seconds where the image should be extracted. The nearest key frame will be used to get the image.
155 This directive is required.
156 Return a 400 if the value is not specified.
157 Return a 404 if the second is not found (the video is shorter than the time specified).
158
159
160 h2(#video_thumbextractor_image_width). video_thumbextractor_image_width
161
162 *syntax:* _video_thumbextractor_image_width width_
163
164 *default:* _0_
165
166 *context:* _http_
167
168 *release version:* _0.1.0_
169
170 The width used to generate the image.
171 This directive is optional.
172 If only the width is specified the video size will be used as image size.
173
174
175 h2(#video_thumbextractor_image_height). video_thumbextractor_image_height
176
177 *syntax:* _video_thumbextractor_image_height height_
178
179 *default:* _0_
180
181 *context:* _http_
182
183 *release version:* _0.1.0_
184
185 The height used to generate the image.
186 This directive is optional.
187 If only the height is specified the width will be determined using video scale to keep the aspect.
188 If both, width and height, are specified the image will suffers a resize and an eventual crop to keep the aspect.
189
190
191 h1(#contributors). Contributors
192
193 "People":contributors
194
195
196 h1(#changelog). Changelog
197
198 h2(#0_1_0). v0.1.0
199
200 * Initial release
201
202
203 [repository]https://github.com/wandenberg/nginx-video-thumbextractor-module
204 [installation]#instalation
205 [contributors]https://github.com/wandenberg/nginx-video-thumbextractor-module/contributors
Something went wrong with that request. Please try again.