Files

66 lines
2.2 KiB
C++
Raw Permalink Normal View History

--- src/FFmpegWriter.cpp.orig 2024-06-20 01:25:10 UTC
2019-06-28 15:49:00 +00:00
+++ src/FFmpegWriter.cpp
2022-12-25 16:38:21 +00:00
@@ -166,7 +166,7 @@ void FFmpegWriter::SetVideoOptions(bool has_video, std
const AVCodec *new_codec;
2019-06-28 15:49:00 +00:00
// Check if the codec selected is a hardware accelerated codec
2021-07-08 09:47:04 +02:00
#if USE_HW_ACCEL
2019-12-08 11:28:16 +00:00
-#if defined(__linux__)
2019-06-28 15:49:00 +00:00
+#if defined(__unix__)
2019-12-08 11:28:16 +00:00
if (strstr(codec.c_str(), "_vaapi") != NULL) {
2019-06-28 15:49:00 +00:00
new_codec = avcodec_find_encoder_by_name(codec.c_str());
hw_en_on = 1;
2022-12-25 16:38:21 +00:00
@@ -216,7 +216,7 @@ void FFmpegWriter::SetVideoOptions(bool has_video, std
2019-06-28 15:49:00 +00:00
}
2021-02-25 18:57:40 +00:00
#else // unknown OS
2019-06-28 15:49:00 +00:00
new_codec = avcodec_find_encoder_by_name(codec.c_str());
2021-02-25 18:57:40 +00:00
-#endif //__linux__/_WIN32/__APPLE__
+#endif //__unix__/_WIN32/__APPLE__
2021-07-08 09:47:04 +02:00
#else // USE_HW_ACCEL
2019-06-28 15:49:00 +00:00
new_codec = avcodec_find_encoder_by_name(codec.c_str());
2021-07-08 09:47:04 +02:00
#endif // USE_HW_ACCEL
2022-12-25 16:38:21 +00:00
@@ -563,6 +563,7 @@ void FFmpegWriter::SetOption(StreamType stream, std::s
2020-06-27 15:42:35 +00:00
else {
av_opt_set_int(c->priv_data, "crf", std::min(std::stoi(value),63), 0);
}
+ break;
case AV_CODEC_ID_HEVC :
c->bit_rate = 0;
if (strstr(info.vcodec.c_str(), "svt_hevc") != NULL) {
2022-12-25 16:38:21 +00:00
@@ -571,6 +572,8 @@ void FFmpegWriter::SetOption(StreamType stream, std::s
2020-06-27 15:42:35 +00:00
av_opt_set_int(c->priv_data, "forced-idr",1,0);
}
break;
+ default:
+ break;
}
2021-02-25 18:57:40 +00:00
#endif // FFmpeg 4.0+
2020-06-27 15:42:35 +00:00
} else {
@@ -1434,21 +1437,25 @@ void FFmpegWriter::open_video(AVFormatContext *oc, AVS
2019-06-28 15:49:00 +00:00
adapter_num = openshot::Settings::Instance()->HW_EN_DEVICE_SET;
2021-02-25 18:57:40 +00:00
std::clog << "Encoding Device Nr: " << adapter_num << "\n";
2019-06-28 15:49:00 +00:00
if (adapter_num < 3 && adapter_num >=0) {
-#if defined(__linux__)
+#if defined(__unix__)
snprintf(adapter,sizeof(adapter),"/dev/dri/renderD%d", adapter_num+128);
// Maybe 127 is better because the first card would be 1?!
adapter_ptr = adapter;
2021-02-25 18:57:40 +00:00
#elif defined(_WIN32) || defined(__APPLE__)
2019-06-28 15:49:00 +00:00
adapter_ptr = NULL;
+#else
+ adapter_ptr = NULL;
#endif
}
else {
adapter_ptr = NULL; // Just to be sure
}
// Check if it is there and writable
-#if defined(__linux__)
+#if defined(__unix__)
if( adapter_ptr != NULL && access( adapter_ptr, W_OK ) == 0 ) {
2021-02-25 18:57:40 +00:00
#elif defined(_WIN32) || defined(__APPLE__)
2019-06-28 15:49:00 +00:00
+ if( adapter_ptr != NULL ) {
+#else
if( adapter_ptr != NULL ) {
#endif
2022-12-25 16:38:21 +00:00
ZmqLogger::Instance()->AppendDebugMethod(