001// 002// This file is auto-generated. Please don't modify it! 003// 004package org.opencv.videoio; 005 006import java.util.ArrayList; 007import java.util.List; 008import org.opencv.core.Mat; 009import org.opencv.core.MatOfInt; 010import org.opencv.core.Size; 011import org.opencv.utils.Converters; 012 013// C++: class VideoWriter 014/** 015 * Video writer class. 016 * 017 * The class provides C++ API for writing video files or image sequences. 018 */ 019public class VideoWriter { 020 021 protected final long nativeObj; 022 protected VideoWriter(long addr) { nativeObj = addr; } 023 024 public long getNativeObjAddr() { return nativeObj; } 025 026 // internal usage only 027 public static VideoWriter __fromPtr__(long addr) { return new VideoWriter(addr); } 028 029 // 030 // C++: cv::VideoWriter::VideoWriter() 031 // 032 033 /** 034 * Default constructors 035 * 036 * The constructors/functions initialize video writers. 037 * <ul> 038 * <li> 039 * On Linux FFMPEG is used to write videos; 040 * </li> 041 * <li> 042 * On Windows FFMPEG or MSWF or DSHOW is used; 043 * </li> 044 * <li> 045 * On MacOSX AVFoundation is used. 046 * </li> 047 * </ul> 048 */ 049 public VideoWriter() { 050 nativeObj = VideoWriter_0(); 051 } 052 053 054 // 055 // C++: cv::VideoWriter::VideoWriter(String filename, int fourcc, double fps, Size frameSize, bool isColor = true) 056 // 057 058 /** 059 * 060 * @param filename Name of the output video file. 061 * @param fourcc 4-character code of codec used to compress the frames. For example, 062 * VideoWriter::fourcc('P','I','M','1') is a MPEG-1 codec, VideoWriter::fourcc('M','J','P','G') 063 * is a motion-jpeg codec etc. List of codes can be obtained at 064 * [MSDN](https://docs.microsoft.com/en-us/windows/win32/medfound/video-fourccs) page 065 * or with this [archived page](https://web.archive.org/web/20220316062600/http://www.fourcc.org/codecs.php) 066 * of the fourcc site for a more complete list). FFMPEG backend with MP4 container natively uses 067 * other values as fourcc code: see [ObjectType](http://mp4ra.org/#/codecs), 068 * so you may receive a warning message from OpenCV about fourcc code conversion. 069 * @param fps Framerate of the created video stream. 070 * @param frameSize Size of the video frames. 071 * @param isColor If it is not zero, the encoder will expect and encode color frames, otherwise it 072 * will work with grayscale frames. 073 * 074 * <b>Tips</b>: 075 * <ul> 076 * <li> 077 * With some backends {@code fourcc=-1} pops up the codec selection dialog from the system. 078 * </li> 079 * <li> 080 * To save image sequence use a proper filename (eg. {@code img_%02d.jpg}) and {@code fourcc=0} 081 * OR {@code fps=0}. Use uncompressed image format (eg. {@code img_%02d.BMP}) to save raw frames. 082 * </li> 083 * <li> 084 * Most codecs are lossy. If you want lossless video file you need to use a lossless codecs 085 * (eg. FFMPEG FFV1, Huffman HFYU, Lagarith LAGS, etc...) 086 * </li> 087 * <li> 088 * If FFMPEG is enabled, using {@code codec=0; fps=0;} you can create an uncompressed (raw) video file. 089 * </li> 090 * </ul> 091 */ 092 public VideoWriter(String filename, int fourcc, double fps, Size frameSize, boolean isColor) { 093 nativeObj = VideoWriter_1(filename, fourcc, fps, frameSize.width, frameSize.height, isColor); 094 } 095 096 /** 097 * 098 * @param filename Name of the output video file. 099 * @param fourcc 4-character code of codec used to compress the frames. For example, 100 * VideoWriter::fourcc('P','I','M','1') is a MPEG-1 codec, VideoWriter::fourcc('M','J','P','G') 101 * is a motion-jpeg codec etc. List of codes can be obtained at 102 * [MSDN](https://docs.microsoft.com/en-us/windows/win32/medfound/video-fourccs) page 103 * or with this [archived page](https://web.archive.org/web/20220316062600/http://www.fourcc.org/codecs.php) 104 * of the fourcc site for a more complete list). FFMPEG backend with MP4 container natively uses 105 * other values as fourcc code: see [ObjectType](http://mp4ra.org/#/codecs), 106 * so you may receive a warning message from OpenCV about fourcc code conversion. 107 * @param fps Framerate of the created video stream. 108 * @param frameSize Size of the video frames. 109 * will work with grayscale frames. 110 * 111 * <b>Tips</b>: 112 * <ul> 113 * <li> 114 * With some backends {@code fourcc=-1} pops up the codec selection dialog from the system. 115 * </li> 116 * <li> 117 * To save image sequence use a proper filename (eg. {@code img_%02d.jpg}) and {@code fourcc=0} 118 * OR {@code fps=0}. Use uncompressed image format (eg. {@code img_%02d.BMP}) to save raw frames. 119 * </li> 120 * <li> 121 * Most codecs are lossy. If you want lossless video file you need to use a lossless codecs 122 * (eg. FFMPEG FFV1, Huffman HFYU, Lagarith LAGS, etc...) 123 * </li> 124 * <li> 125 * If FFMPEG is enabled, using {@code codec=0; fps=0;} you can create an uncompressed (raw) video file. 126 * </li> 127 * </ul> 128 */ 129 public VideoWriter(String filename, int fourcc, double fps, Size frameSize) { 130 nativeObj = VideoWriter_2(filename, fourcc, fps, frameSize.width, frameSize.height); 131 } 132 133 134 // 135 // C++: cv::VideoWriter::VideoWriter(String filename, int apiPreference, int fourcc, double fps, Size frameSize, bool isColor = true) 136 // 137 138 /** 139 * 140 * The {@code apiPreference} parameter allows to specify API backends to use. Can be used to enforce a specific reader implementation 141 * if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_GSTREAMER. 142 * @param filename automatically generated 143 * @param apiPreference automatically generated 144 * @param fourcc automatically generated 145 * @param fps automatically generated 146 * @param frameSize automatically generated 147 * @param isColor automatically generated 148 */ 149 public VideoWriter(String filename, int apiPreference, int fourcc, double fps, Size frameSize, boolean isColor) { 150 nativeObj = VideoWriter_3(filename, apiPreference, fourcc, fps, frameSize.width, frameSize.height, isColor); 151 } 152 153 /** 154 * 155 * The {@code apiPreference} parameter allows to specify API backends to use. Can be used to enforce a specific reader implementation 156 * if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_GSTREAMER. 157 * @param filename automatically generated 158 * @param apiPreference automatically generated 159 * @param fourcc automatically generated 160 * @param fps automatically generated 161 * @param frameSize automatically generated 162 */ 163 public VideoWriter(String filename, int apiPreference, int fourcc, double fps, Size frameSize) { 164 nativeObj = VideoWriter_4(filename, apiPreference, fourcc, fps, frameSize.width, frameSize.height); 165 } 166 167 168 // 169 // C++: cv::VideoWriter::VideoWriter(String filename, int fourcc, double fps, Size frameSize, vector_int params) 170 // 171 172 /** 173 * 174 * The {@code params} parameter allows to specify extra encoder parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) 175 * see cv::VideoWriterProperties 176 * @param filename automatically generated 177 * @param fourcc automatically generated 178 * @param fps automatically generated 179 * @param frameSize automatically generated 180 * @param params automatically generated 181 */ 182 public VideoWriter(String filename, int fourcc, double fps, Size frameSize, MatOfInt params) { 183 Mat params_mat = params; 184 nativeObj = VideoWriter_5(filename, fourcc, fps, frameSize.width, frameSize.height, params_mat.nativeObj); 185 } 186 187 188 // 189 // C++: cv::VideoWriter::VideoWriter(String filename, int apiPreference, int fourcc, double fps, Size frameSize, vector_int params) 190 // 191 192 public VideoWriter(String filename, int apiPreference, int fourcc, double fps, Size frameSize, MatOfInt params) { 193 Mat params_mat = params; 194 nativeObj = VideoWriter_6(filename, apiPreference, fourcc, fps, frameSize.width, frameSize.height, params_mat.nativeObj); 195 } 196 197 198 // 199 // C++: bool cv::VideoWriter::open(String filename, int fourcc, double fps, Size frameSize, bool isColor = true) 200 // 201 202 /** 203 * Initializes or reinitializes video writer. 204 * 205 * The method opens video writer. Parameters are the same as in the constructor 206 * VideoWriter::VideoWriter. 207 * @return {@code true} if video writer has been successfully initialized 208 * 209 * The method first calls VideoWriter::release to close the already opened file. 210 * @param filename automatically generated 211 * @param fourcc automatically generated 212 * @param fps automatically generated 213 * @param frameSize automatically generated 214 * @param isColor automatically generated 215 */ 216 public boolean open(String filename, int fourcc, double fps, Size frameSize, boolean isColor) { 217 return open_0(nativeObj, filename, fourcc, fps, frameSize.width, frameSize.height, isColor); 218 } 219 220 /** 221 * Initializes or reinitializes video writer. 222 * 223 * The method opens video writer. Parameters are the same as in the constructor 224 * VideoWriter::VideoWriter. 225 * @return {@code true} if video writer has been successfully initialized 226 * 227 * The method first calls VideoWriter::release to close the already opened file. 228 * @param filename automatically generated 229 * @param fourcc automatically generated 230 * @param fps automatically generated 231 * @param frameSize automatically generated 232 */ 233 public boolean open(String filename, int fourcc, double fps, Size frameSize) { 234 return open_1(nativeObj, filename, fourcc, fps, frameSize.width, frameSize.height); 235 } 236 237 238 // 239 // C++: bool cv::VideoWriter::open(String filename, int apiPreference, int fourcc, double fps, Size frameSize, bool isColor = true) 240 // 241 242 public boolean open(String filename, int apiPreference, int fourcc, double fps, Size frameSize, boolean isColor) { 243 return open_2(nativeObj, filename, apiPreference, fourcc, fps, frameSize.width, frameSize.height, isColor); 244 } 245 246 public boolean open(String filename, int apiPreference, int fourcc, double fps, Size frameSize) { 247 return open_3(nativeObj, filename, apiPreference, fourcc, fps, frameSize.width, frameSize.height); 248 } 249 250 251 // 252 // C++: bool cv::VideoWriter::open(String filename, int fourcc, double fps, Size frameSize, vector_int params) 253 // 254 255 public boolean open(String filename, int fourcc, double fps, Size frameSize, MatOfInt params) { 256 Mat params_mat = params; 257 return open_4(nativeObj, filename, fourcc, fps, frameSize.width, frameSize.height, params_mat.nativeObj); 258 } 259 260 261 // 262 // C++: bool cv::VideoWriter::open(String filename, int apiPreference, int fourcc, double fps, Size frameSize, vector_int params) 263 // 264 265 public boolean open(String filename, int apiPreference, int fourcc, double fps, Size frameSize, MatOfInt params) { 266 Mat params_mat = params; 267 return open_5(nativeObj, filename, apiPreference, fourcc, fps, frameSize.width, frameSize.height, params_mat.nativeObj); 268 } 269 270 271 // 272 // C++: bool cv::VideoWriter::isOpened() 273 // 274 275 /** 276 * Returns true if video writer has been successfully initialized. 277 * @return automatically generated 278 */ 279 public boolean isOpened() { 280 return isOpened_0(nativeObj); 281 } 282 283 284 // 285 // C++: void cv::VideoWriter::release() 286 // 287 288 /** 289 * Closes the video writer. 290 * 291 * The method is automatically called by subsequent VideoWriter::open and by the VideoWriter 292 * destructor. 293 */ 294 public void release() { 295 release_0(nativeObj); 296 } 297 298 299 // 300 // C++: void cv::VideoWriter::write(Mat image) 301 // 302 303 /** 304 * Writes the next video frame 305 * 306 * @param image The written frame. In general, color images are expected in BGR format. 307 * 308 * The function/method writes the specified image to video file. It must have the same size as has 309 * been specified when opening the video writer. 310 */ 311 public void write(Mat image) { 312 write_0(nativeObj, image.nativeObj); 313 } 314 315 316 // 317 // C++: bool cv::VideoWriter::set(int propId, double value) 318 // 319 320 /** 321 * Sets a property in the VideoWriter. 322 * 323 * @param propId Property identifier from cv::VideoWriterProperties (eg. cv::VIDEOWRITER_PROP_QUALITY) 324 * or one of REF: videoio_flags_others 325 * 326 * @param value Value of the property. 327 * @return {@code true} if the property is supported by the backend used by the VideoWriter instance. 328 */ 329 public boolean set(int propId, double value) { 330 return set_0(nativeObj, propId, value); 331 } 332 333 334 // 335 // C++: double cv::VideoWriter::get(int propId) 336 // 337 338 /** 339 * Returns the specified VideoWriter property 340 * 341 * @param propId Property identifier from cv::VideoWriterProperties (eg. cv::VIDEOWRITER_PROP_QUALITY) 342 * or one of REF: videoio_flags_others 343 * 344 * @return Value for the specified property. Value 0 is returned when querying a property that is 345 * not supported by the backend used by the VideoWriter instance. 346 */ 347 public double get(int propId) { 348 return get_0(nativeObj, propId); 349 } 350 351 352 // 353 // C++: static int cv::VideoWriter::fourcc(char c1, char c2, char c3, char c4) 354 // 355 356 /** 357 * Concatenates 4 chars to a fourcc code 358 * 359 * @return a fourcc code 360 * 361 * This static method constructs the fourcc code of the codec to be used in the constructor 362 * VideoWriter::VideoWriter or VideoWriter::open. 363 * @param c1 automatically generated 364 * @param c2 automatically generated 365 * @param c3 automatically generated 366 * @param c4 automatically generated 367 */ 368 public static int fourcc(char c1, char c2, char c3, char c4) { 369 return fourcc_0(c1, c2, c3, c4); 370 } 371 372 373 // 374 // C++: String cv::VideoWriter::getBackendName() 375 // 376 377 /** 378 * Returns used backend API name 379 * 380 * <b>Note:</b> Stream should be opened. 381 * @return automatically generated 382 */ 383 public String getBackendName() { 384 return getBackendName_0(nativeObj); 385 } 386 387 388 @Override 389 protected void finalize() throws Throwable { 390 delete(nativeObj); 391 } 392 393 394 395 // C++: cv::VideoWriter::VideoWriter() 396 private static native long VideoWriter_0(); 397 398 // C++: cv::VideoWriter::VideoWriter(String filename, int fourcc, double fps, Size frameSize, bool isColor = true) 399 private static native long VideoWriter_1(String filename, int fourcc, double fps, double frameSize_width, double frameSize_height, boolean isColor); 400 private static native long VideoWriter_2(String filename, int fourcc, double fps, double frameSize_width, double frameSize_height); 401 402 // C++: cv::VideoWriter::VideoWriter(String filename, int apiPreference, int fourcc, double fps, Size frameSize, bool isColor = true) 403 private static native long VideoWriter_3(String filename, int apiPreference, int fourcc, double fps, double frameSize_width, double frameSize_height, boolean isColor); 404 private static native long VideoWriter_4(String filename, int apiPreference, int fourcc, double fps, double frameSize_width, double frameSize_height); 405 406 // C++: cv::VideoWriter::VideoWriter(String filename, int fourcc, double fps, Size frameSize, vector_int params) 407 private static native long VideoWriter_5(String filename, int fourcc, double fps, double frameSize_width, double frameSize_height, long params_mat_nativeObj); 408 409 // C++: cv::VideoWriter::VideoWriter(String filename, int apiPreference, int fourcc, double fps, Size frameSize, vector_int params) 410 private static native long VideoWriter_6(String filename, int apiPreference, int fourcc, double fps, double frameSize_width, double frameSize_height, long params_mat_nativeObj); 411 412 // C++: bool cv::VideoWriter::open(String filename, int fourcc, double fps, Size frameSize, bool isColor = true) 413 private static native boolean open_0(long nativeObj, String filename, int fourcc, double fps, double frameSize_width, double frameSize_height, boolean isColor); 414 private static native boolean open_1(long nativeObj, String filename, int fourcc, double fps, double frameSize_width, double frameSize_height); 415 416 // C++: bool cv::VideoWriter::open(String filename, int apiPreference, int fourcc, double fps, Size frameSize, bool isColor = true) 417 private static native boolean open_2(long nativeObj, String filename, int apiPreference, int fourcc, double fps, double frameSize_width, double frameSize_height, boolean isColor); 418 private static native boolean open_3(long nativeObj, String filename, int apiPreference, int fourcc, double fps, double frameSize_width, double frameSize_height); 419 420 // C++: bool cv::VideoWriter::open(String filename, int fourcc, double fps, Size frameSize, vector_int params) 421 private static native boolean open_4(long nativeObj, String filename, int fourcc, double fps, double frameSize_width, double frameSize_height, long params_mat_nativeObj); 422 423 // C++: bool cv::VideoWriter::open(String filename, int apiPreference, int fourcc, double fps, Size frameSize, vector_int params) 424 private static native boolean open_5(long nativeObj, String filename, int apiPreference, int fourcc, double fps, double frameSize_width, double frameSize_height, long params_mat_nativeObj); 425 426 // C++: bool cv::VideoWriter::isOpened() 427 private static native boolean isOpened_0(long nativeObj); 428 429 // C++: void cv::VideoWriter::release() 430 private static native void release_0(long nativeObj); 431 432 // C++: void cv::VideoWriter::write(Mat image) 433 private static native void write_0(long nativeObj, long image_nativeObj); 434 435 // C++: bool cv::VideoWriter::set(int propId, double value) 436 private static native boolean set_0(long nativeObj, int propId, double value); 437 438 // C++: double cv::VideoWriter::get(int propId) 439 private static native double get_0(long nativeObj, int propId); 440 441 // C++: static int cv::VideoWriter::fourcc(char c1, char c2, char c3, char c4) 442 private static native int fourcc_0(char c1, char c2, char c3, char c4); 443 444 // C++: String cv::VideoWriter::getBackendName() 445 private static native String getBackendName_0(long nativeObj); 446 447 // native support for java finalize() 448 private static native void delete(long nativeObj); 449 450}