Skip to content

Commit

Permalink
Merge pull request mipops#776 from g-maxime/decklink-stdout
Browse files Browse the repository at this point in the history
Handle stdout with mkv output
  • Loading branch information
dericed authored Dec 4, 2023
2 parents 2c39ef3 + 7345af4 commit d59c7dc
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions Source/Common/DecklinkWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "Common/Merge.h"

#include <DeckLinkAPIDispatch.cpp>
#include <iostream>
#include <ctime>

using namespace std;
Expand Down Expand Up @@ -594,8 +595,13 @@ void DecklinkWrapper::CreateCaptureSession(FileWrapper* Wrapper_)
uint32_t Den = DeckLinkVideoMode == bmdModeNTSC ? 1001 : 1;

output Output;
Output.Output = new ofstream(OutputFile, ios_base::binary | ios_base::trunc);
Output.Writer = new matroska_writer(Output.Output, 720, Lines, Num, Den, DeckLinkTimecodeFormat != (uint32_t)-1);
if (OutputFile == "-")
Output.Writer = new matroska_writer(&cout, 720, Lines, Num, Den, DeckLinkTimecodeFormat != (uint32_t)-1);
else
{
Output.Output = new ofstream(OutputFile, ios_base::binary | ios_base::trunc);
Output.Writer = new matroska_writer(Output.Output, 720, Lines, Num, Den, DeckLinkTimecodeFormat != (uint32_t)-1);
}
Outputs.push_back(Output);
}

Expand Down Expand Up @@ -667,10 +673,17 @@ void DecklinkWrapper::StopCaptureSession()

for (output Output: Outputs)
{
Output.Writer->close(Output.Output);
Output.Output->close();
delete Output.Writer;
delete Output.Output;
if (Output.Writer)
{
Output.Writer->close(Output.Output);
delete Output.Writer;
}

if (Output.Output)
{
Output.Output->close();
delete Output.Output;
}
}
Outputs.clear();

Expand Down

0 comments on commit d59c7dc

Please sign in to comment.