on Linux/Mac changed output Codec to MP4V (as MOV)

This commit is contained in:
lostjared
2017-02-21 11:53:34 -08:00
parent 9ca3de598c
commit d7fa2bdbfa

View File

@@ -331,9 +331,16 @@ bool AC_MainWindow::startCamera(int res, int dev, const QString &outdir, bool re
time_t t = time(0); time_t t = time(0);
struct tm *m; struct tm *m;
m = localtime(&t); m = localtime(&t);
QString ext;
#if defined(__APPLE__) || defined(__linux__)
ext = ".mov";
#else
ext = ".avi";
#endif
std::ostringstream time_stream; std::ostringstream time_stream;
time_stream << "-" << (m->tm_year + 1900) << "." << (m->tm_mon + 1) << "." << m->tm_mday << "_" << m->tm_hour << "." << m->tm_min << "." << m->tm_sec << "_"; time_stream << "-" << (m->tm_year + 1900) << "." << (m->tm_mon + 1) << "." << m->tm_mday << "_" << m->tm_hour << "." << m->tm_min << "." << m->tm_sec << "_";
stream_ << outdir << "/" << "Video." << time_stream.str().c_str() << "AC2.Output." << (++index) << ".avi"; stream_ << outdir << "/" << "Video." << time_stream.str().c_str() << "AC2.Output." << (++index) << ext;
switch(res) { switch(res) {
case 0: case 0:
res_w = 640; res_w = 640;
@@ -364,7 +371,8 @@ bool AC_MainWindow::startCamera(int res, int dev, const QString &outdir, bool re
if(recording) { if(recording) {
video_file_name = output_name; video_file_name = output_name;
#if defined(__linux__) || defined(__APPLE__) #if defined(__linux__) || defined(__APPLE__)
writer = cv::VideoWriter(output_name.toStdString(), CV_FOURCC('X','V','I','D'), video_fps, cv::Size(res_w, res_h), true); writer = cv::VideoWriter(output_name.toStdString(), CV_FOURCC('M', 'P', '4', 'V')
/*CV_FOURCC('X','V','I','D')*/, video_fps, cv::Size(res_w, res_h), true);
#else #else
writer = cv::VideoWriter(output_name.toStdString(), -1, video_fps, cv::Size(res_w, res_h), true); writer = cv::VideoWriter(output_name.toStdString(), -1, video_fps, cv::Size(res_w, res_h), true);
#endif #endif
@@ -428,15 +436,23 @@ bool AC_MainWindow::startVideo(const QString &filename, const QString &outdir, b
time_t t = time(0); time_t t = time(0);
struct tm *m; struct tm *m;
m = localtime(&t); m = localtime(&t);
QString ext;
#if defined(__APPLE__) || defined(__linux__)
ext = ".mov";
#else
ext = ".avi";
#endif
std::ostringstream time_stream; std::ostringstream time_stream;
time_stream << "-" << (m->tm_year + 1900) << "." << (m->tm_mon + 1) << "." << m->tm_mday << "_" << m->tm_hour << "." << m->tm_min << "." << m->tm_sec << "_"; time_stream << "-" << (m->tm_year + 1900) << "." << (m->tm_mon + 1) << "." << m->tm_mday << "_" << m->tm_hour << "." << m->tm_min << "." << m->tm_sec << "_";
stream_ << outdir << "/" << "Video." << time_stream.str().c_str() << "AC2.Output." << (++index) << ".avi"; stream_ << outdir << "/" << "Video." << time_stream.str().c_str() << "AC2.Output." << (++index) << ext;
if(recording) { if(recording) {
video_file_name = output_name; video_file_name = output_name;
#if defined(__linux__) || defined(__APPLE__) #if defined(__linux__) || defined(__APPLE__)
writer = cv::VideoWriter(output_name.toStdString(), CV_FOURCC('X','V','I','D'), video_fps, cv::Size(res_w, res_h), true); writer = cv::VideoWriter(output_name.toStdString(), /*CV_FOURCC('X','V','I','D')*/ CV_FOURCC('M', 'P', '4', 'V'), video_fps, cv::Size(res_w, res_h), true);
#else #else
writer = cv::VideoWriter(output_name.toStdString(), -1, video_fps, cv::Size(res_w, res_h), true); writer = cv::VideoWriter(output_name.toStdString(), -1, video_fps, cv::Size(res_w, res_h), true);
#endif #endif