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) { if (!success) {
goto cleanup; goto cleanup;
} }
avcodec_send_frame(out->enc, NULL);
int ret; int ret;
AVPacket pkt; AVPacket pkt;
pkt.size = 0; pkt.size = 0;

View File

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

View File

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