| 31 | bool FFVideoEncoder::ffmpegInitDone = false; |
| 32 | |
| 33 | FFVideoEncoder::FFVideoEncoder( |
| 34 | const std::string & _filepath, |
| 35 | double _fps, |
| 36 | const sibr::Vector2i & size, |
| 37 | bool forceResize |
| 38 | ) : filepath(_filepath), fps(_fps), _forceResize(forceResize) |
| 39 | { |
| 40 | #ifndef HEADLESS |
| 41 | /** Init FFMPEG, registering available codec plugins. */ |
| 42 | if (!ffmpegInitDone) { |
| 43 | SIBR_LOG << "[FFMPEG] Registering all." << std::endl; |
| 44 | // Ignore next line warning. |
| 45 | #pragma warning(suppress : 4996) |
| 46 | av_register_all(); |
| 47 | ffmpegInitDone = true; |
| 48 | } |
| 49 | |
| 50 | sibr::Vector2i sizeFix = size; |
| 51 | bool hadToFix = false; |
| 52 | if(sizeFix[0]%2 != 0) { |
| 53 | sizeFix[0] -= 1; |
| 54 | hadToFix = true; |
| 55 | } |
| 56 | if (sizeFix[1] % 2 != 0) { |
| 57 | sizeFix[1] -= 1; |
| 58 | hadToFix = true; |
| 59 | } |
| 60 | if(hadToFix) { |
| 61 | SIBR_WRG << "Non-even video dimensions, resized to " << sizeFix[0] << "x" << sizeFix[1] << "." << std::endl; |
| 62 | _forceResize = true; |
| 63 | } |
| 64 | |
| 65 | init(sizeFix); |
| 66 | #endif |
| 67 | } |
| 68 | |
| 69 | bool FFVideoEncoder::isFine() const |
| 70 | { |