From 22ff74a91f4a430b8a4279529cb736766b169a0e Mon Sep 17 00:00:00 2001 From: shawndfernandes Date: Wed, 22 Aug 2018 19:22:36 -0500 Subject: [PATCH 1/2] FFMPEG 16bit file support Added support for FFMPEG 16 bit channel support. --- modules/videoio/src/cap_ffmpeg.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/videoio/src/cap_ffmpeg.cpp b/modules/videoio/src/cap_ffmpeg.cpp index 14353ad13c11..83f77f5c6425 100644 --- a/modules/videoio/src/cap_ffmpeg.cpp +++ b/modules/videoio/src/cap_ffmpeg.cpp @@ -293,9 +293,15 @@ class CvVideoWriter_FFMPEG_proxy CV_FINAL : { if(!ffmpegWriter) return; - CV_Assert(image.depth() == CV_8U); + CV_Assert(image.depth() == CV_8U || image.depth() == CV_16U); - icvWriteFrame_FFMPEG_p(ffmpegWriter, (const uchar*)image.getMat().ptr(), (int)image.step(), image.cols(), image.rows(), image.channels(), 0); + if(image.depth() == CV_8U){ + icvWriteFrame_FFMPEG_p(ffmpegWriter, (const uchar*)image.getMat().ptr(), (int)image.step(), image.cols(), image.rows(), image.channels(), 0); + } + + if(image.depth() == CV_16U){ + icvWriteFrame_FFMPEG_p(ffmpegWriter, (const uchar*)image.getMat().ptr(), (int)image.step(), image.cols(), image.rows(), image.channels(), 0); + } } virtual bool open( const cv::String& filename, int fourcc, double fps, cv::Size frameSize, bool isColor ) { From d7af4f9c625a09309bc629549913ceb5565e3a61 Mon Sep 17 00:00:00 2001 From: shawndfernandes Date: Wed, 22 Aug 2018 20:42:10 -0500 Subject: [PATCH 2/2] Optimised change --- modules/videoio/src/cap_ffmpeg.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/modules/videoio/src/cap_ffmpeg.cpp b/modules/videoio/src/cap_ffmpeg.cpp index 83f77f5c6425..eb096ced86ff 100644 --- a/modules/videoio/src/cap_ffmpeg.cpp +++ b/modules/videoio/src/cap_ffmpeg.cpp @@ -294,14 +294,7 @@ class CvVideoWriter_FFMPEG_proxy CV_FINAL : if(!ffmpegWriter) return; CV_Assert(image.depth() == CV_8U || image.depth() == CV_16U); - - if(image.depth() == CV_8U){ - icvWriteFrame_FFMPEG_p(ffmpegWriter, (const uchar*)image.getMat().ptr(), (int)image.step(), image.cols(), image.rows(), image.channels(), 0); - } - - if(image.depth() == CV_16U){ - icvWriteFrame_FFMPEG_p(ffmpegWriter, (const uchar*)image.getMat().ptr(), (int)image.step(), image.cols(), image.rows(), image.channels(), 0); - } + icvWriteFrame_FFMPEG_p(ffmpegWriter, (const uchar*)image.getMat().ptr(), (int)image.step(), image.cols(), image.rows(), image.channels(), 0); } virtual bool open( const cv::String& filename, int fourcc, double fps, cv::Size frameSize, bool isColor ) {