Fix encoder not flushing the frames properly

Thanks IRC!
This commit is contained in:
ArsenArsen 2017-06-28 11:12:34 +02:00
parent 951d5f99a7
commit 2ccc2ca0f9
3 changed files with 4 additions and 1 deletions

View File

@ -145,6 +145,7 @@ bool Encoder::end() {
if (!success) {
goto cleanup;
}
avcodec_send_frame(out->enc, NULL);
int ret;
AVPacket pkt;
pkt.size = 0;

View File

@ -31,7 +31,7 @@ RecordingFormats::RecordingFormats(formats::Recording f) {
path = tmpDir.absoluteFilePath("res." + formats::recordingFormatName(f).toLower());
finalizer = [&] {
delete enc;
if (interrupt) {
if (interrupt || !frameAdded) {
tmpDir.removeRecursively();
return QByteArray();
}
@ -66,6 +66,7 @@ RecordingFormats::RecordingFormats(formats::Recording f) {
};
consumer = [&](QImage img) {
if (!interrupt) try {
frameAdded = true;
enc->addFrame(img);
} catch (std::runtime_error e) {
// notifications::notify("KShare Video Encoder Error", e.what(),

View File

@ -31,6 +31,7 @@ private:
QString path;
Encoder *enc = NULL;
bool interrupt = false;
bool frameAdded = false;
QString anotherFormat;
};