diff --git a/Source/Common/Output_Mkv.h b/Source/Common/Output_Mkv.h index 8b1ae0a2..d918a7dc 100644 --- a/Source/Common/Output_Mkv.h +++ b/Source/Common/Output_Mkv.h @@ -14,6 +14,16 @@ #include "Common/ProcessFileWrapper.h" #include "ThirdParty/TimeCode/TimeCode.h" +//*************************************************************************** +//enums +//*************************************************************************** + +enum video_format +{ + v210, + UYVY, +}; + //*************************************************************************** // Class matroska_writer //*************************************************************************** diff --git a/Source/Common/ProcessFile.cpp b/Source/Common/ProcessFile.cpp index a97d2ab9..3a0241a6 100644 --- a/Source/Common/ProcessFile.cpp +++ b/Source/Common/ProcessFile.cpp @@ -417,7 +417,6 @@ void file::Parse(const String& FileName) #if defined(ENABLE_SIMULATOR) || defined(ENABLE_DECKLINK) if (CaptureMode == Capture_Mode_DeckLink) { - video_format VideoFormat = v210; uint32_t Width = 720; uint32_t Height = DeckLinkVideoMode == Decklink_Video_Mode_NTSC ? 486 : 576; uint32_t Num = DeckLinkVideoMode == Decklink_Video_Mode_NTSC ? 30000 : 25; @@ -425,7 +424,7 @@ void file::Parse(const String& FileName) uint32_t SampleRate = 48000; uint8_t Channels = 2; - Wrapper = new FileWrapper(VideoFormat, Width, Height, Num, Den, SampleRate, Channels, DeckLinkTimecodeFormatPixel_Format) FramesInfo.pixel_format = Frame->Pixel_Format; + if (!Merge_OutputFileNames.empty() && Outputs.empty()) + { + video_format Format = v210; + if (FramesInfo.pixel_format == Decklink_Pixel_Format_8BitYUV) + Format = UYVY; + + for (string OutputFile : Merge_OutputFileNames) + { + matroska_output Output; + if (OutputFile == "-") + Output.Writer = new matroska_writer(&cout, Format, FramesInfo.video_width, FramesInfo.video_height, FramesInfo.video_rate_num, FramesInfo.video_rate_den, HasTimecode); + else + { + Output.Output = new ofstream(OutputFile, ios_base::binary | ios_base::trunc); + Output.Writer = new matroska_writer(Output.Output, Format, FramesInfo.video_width, FramesInfo.video_height, FramesInfo.video_rate_num, FramesInfo.video_rate_den, HasTimecode); + } + Outputs.push_back(Output); + } + } + for (matroska_output& Output : Outputs) { Output.Writer->write_frame((const char*)Frame->Video_Buffer, (uint32_t)Frame->Video_Buffer_Size, diff --git a/Source/Common/ProcessFileWrapper.h b/Source/Common/ProcessFileWrapper.h index b2ae589c..ac3a1b7c 100644 --- a/Source/Common/ProcessFileWrapper.h +++ b/Source/Common/ProcessFileWrapper.h @@ -73,16 +73,6 @@ struct matroska_output }; #endif -//*************************************************************************** -//enums -//*************************************************************************** - -enum video_format -{ - v210, - UYVY, -}; - //*************************************************************************** // Class FileWrapper //*************************************************************************** @@ -91,7 +81,7 @@ class FileWrapper { public: FileWrapper(file* File); // Constructor for DV/MediaInfo Interface #if defined(ENABLE_DECKLINK) || defined(ENABLE_SIMULATOR) - FileWrapper(video_format vid_fmt, int Width, int Height, int Framerate_Num, int Framerate_Den, int SampleRate, int Channels, bool Has_Timecode = false); // Constructor for Decklink/Matroska Interface + FileWrapper(int Width, int Height, int Framerate_Num, int Framerate_Den, int SampleRate, int Channels, bool Has_Timecode = false); // Constructor for Decklink/Matroska Interface ~FileWrapper(); #endif void Parse_Buffer(const uint8_t* Buffer, std::size_t Buffer_Size); @@ -104,6 +94,7 @@ class FileWrapper { file* File; #if defined(ENABLE_DECKLINK) || defined(ENABLE_SIMULATOR) bool IsMatroska = false; + bool HasTimecode = false; std::vector Outputs; size_t FrameCount = 0; #endif