Skip to content

Commit

Permalink
Handle stdout with mkv output
Browse files Browse the repository at this point in the history
Signed-off-by: Maxime Gervais <[email protected]>
  • Loading branch information
g-maxime committed Dec 4, 2023
1 parent 2c39ef3 commit 7345af4
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 7345af4

Please sign in to comment.