mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
Add global hardware acceleration codec switch
This commit is contained in:
@@ -4,16 +4,9 @@
|
||||
|
||||
#include "log.h"
|
||||
|
||||
#define SAVE_ENCODER_STREAM 0
|
||||
#define SAVE_ENCODER_STREAM 1
|
||||
|
||||
FFmpegVideoEncoder::FFmpegVideoEncoder() {
|
||||
if (SAVE_ENCODER_STREAM) {
|
||||
file_ = fopen("encode_stream.h264", "w+b");
|
||||
if (!file_) {
|
||||
LOG_WARN("Fail to open stream.h264");
|
||||
}
|
||||
}
|
||||
}
|
||||
FFmpegVideoEncoder::FFmpegVideoEncoder() {}
|
||||
FFmpegVideoEncoder::~FFmpegVideoEncoder() {
|
||||
if (SAVE_ENCODER_STREAM && file_) {
|
||||
fflush(file_);
|
||||
@@ -21,12 +14,14 @@ FFmpegVideoEncoder::~FFmpegVideoEncoder() {
|
||||
file_ = nullptr;
|
||||
}
|
||||
|
||||
av_packet_free(&packet_);
|
||||
|
||||
if (nv12_data_) {
|
||||
free(nv12_data_);
|
||||
nv12_data_ = nullptr;
|
||||
}
|
||||
|
||||
if (packet_) {
|
||||
av_packet_free(&packet_);
|
||||
}
|
||||
}
|
||||
|
||||
int FFmpegVideoEncoder::Init() {
|
||||
@@ -82,6 +77,13 @@ int FFmpegVideoEncoder::Init() {
|
||||
|
||||
packet_ = av_packet_alloc();
|
||||
|
||||
if (SAVE_ENCODER_STREAM) {
|
||||
file_ = fopen("encode_stream.h264", "w+b");
|
||||
if (!file_) {
|
||||
LOG_WARN("Fail to open stream.h264");
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user