├── README.md ├── AutoSplitter ├── AutoSplitter.vcxproj.filters ├── auto_split.cpp └── AutoSplitter.vcxproj ├── AutoSplitter.sln ├── .gitattributes └── .gitignore /README.md: -------------------------------------------------------------------------------- 1 | # Auto Splitter (OBS-Studio plugin) 2 | 3 | A remake of the RecordingSplitter(Recording Stopper) for obs-studio. 4 | This plugin is timer for the recording. If time comes, recording is stopped/restarted. 5 | 6 | RecodingSplitter: https://github.com/adocilesloth/RecordingSplitter 7 | 8 | ## How to use 9 | 1. Copy "AutoSplitter.dll" to ".../obs-studio\obs-plugins\64bit" 10 | 2. Launch obs-studio and Select "File / Show settings folder" 11 | 3. Then , edit "plugin_config/AutoSplitter/settings.txt" 12 | 4. Restart obs. -------------------------------------------------------------------------------- /AutoSplitter/AutoSplitter.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | ソース ファイル 20 | 21 | 22 | -------------------------------------------------------------------------------- /AutoSplitter.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.24720.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AutoSplitter", "AutoSplitter\AutoSplitter.vcxproj", "{D247B61E-2418-47C6-9CB1-4655DAD7B370}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {D247B61E-2418-47C6-9CB1-4655DAD7B370}.Debug|x64.ActiveCfg = Debug|x64 17 | {D247B61E-2418-47C6-9CB1-4655DAD7B370}.Debug|x64.Build.0 = Debug|x64 18 | {D247B61E-2418-47C6-9CB1-4655DAD7B370}.Debug|x86.ActiveCfg = Debug|Win32 19 | {D247B61E-2418-47C6-9CB1-4655DAD7B370}.Debug|x86.Build.0 = Debug|Win32 20 | {D247B61E-2418-47C6-9CB1-4655DAD7B370}.Release|x64.ActiveCfg = Release|x64 21 | {D247B61E-2418-47C6-9CB1-4655DAD7B370}.Release|x64.Build.0 = Release|x64 22 | {D247B61E-2418-47C6-9CB1-4655DAD7B370}.Release|x86.ActiveCfg = Release|Win32 23 | {D247B61E-2418-47C6-9CB1-4655DAD7B370}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | 28 | # MSTest test Results 29 | [Tt]est[Rr]esult*/ 30 | [Bb]uild[Ll]og.* 31 | 32 | # NUNIT 33 | *.VisualState.xml 34 | TestResult.xml 35 | 36 | # Build Results of an ATL Project 37 | [Dd]ebugPS/ 38 | [Rr]eleasePS/ 39 | dlldata.c 40 | 41 | # DNX 42 | project.lock.json 43 | artifacts/ 44 | 45 | *_i.c 46 | *_p.c 47 | *_i.h 48 | *.ilk 49 | *.meta 50 | *.obj 51 | *.pch 52 | *.pdb 53 | *.pgc 54 | *.pgd 55 | *.rsp 56 | *.sbr 57 | *.tlb 58 | *.tli 59 | *.tlh 60 | *.tmp 61 | *.tmp_proj 62 | *.log 63 | *.vspscc 64 | *.vssscc 65 | .builds 66 | *.pidb 67 | *.svclog 68 | *.scc 69 | 70 | # Chutzpah Test files 71 | _Chutzpah* 72 | 73 | # Visual C++ cache files 74 | ipch/ 75 | *.aps 76 | *.ncb 77 | *.opensdf 78 | *.sdf 79 | *.cachefile 80 | 81 | # Visual Studio profiler 82 | *.psess 83 | *.vsp 84 | *.vspx 85 | 86 | # TFS 2012 Local Workspace 87 | $tf/ 88 | 89 | # Guidance Automation Toolkit 90 | *.gpState 91 | 92 | # ReSharper is a .NET coding add-in 93 | _ReSharper*/ 94 | *.[Rr]e[Ss]harper 95 | *.DotSettings.user 96 | 97 | # JustCode is a .NET coding add-in 98 | .JustCode 99 | 100 | # TeamCity is a build add-in 101 | _TeamCity* 102 | 103 | # DotCover is a Code Coverage Tool 104 | *.dotCover 105 | 106 | # NCrunch 107 | _NCrunch_* 108 | .*crunch*.local.xml 109 | 110 | # MightyMoose 111 | *.mm.* 112 | AutoTest.Net/ 113 | 114 | # Web workbench (sass) 115 | .sass-cache/ 116 | 117 | # Installshield output folder 118 | [Ee]xpress/ 119 | 120 | # DocProject is a documentation generator add-in 121 | DocProject/buildhelp/ 122 | DocProject/Help/*.HxT 123 | DocProject/Help/*.HxC 124 | DocProject/Help/*.hhc 125 | DocProject/Help/*.hhk 126 | DocProject/Help/*.hhp 127 | DocProject/Help/Html2 128 | DocProject/Help/html 129 | 130 | # Click-Once directory 131 | publish/ 132 | 133 | # Publish Web Output 134 | *.[Pp]ublish.xml 135 | *.azurePubxml 136 | ## TODO: Comment the next line if you want to checkin your 137 | ## web deploy settings but do note that will include unencrypted 138 | ## passwords 139 | #*.pubxml 140 | 141 | *.publishproj 142 | 143 | # NuGet Packages 144 | *.nupkg 145 | # The packages folder can be ignored because of Package Restore 146 | **/packages/* 147 | # except build/, which is used as an MSBuild target. 148 | !**/packages/build/ 149 | # Uncomment if necessary however generally it will be regenerated when needed 150 | #!**/packages/repositories.config 151 | 152 | # Windows Azure Build Output 153 | csx/ 154 | *.build.csdef 155 | 156 | # Windows Store app package directory 157 | AppPackages/ 158 | 159 | # Visual Studio cache files 160 | # files ending in .cache can be ignored 161 | *.[Cc]ache 162 | # but keep track of directories ending in .cache 163 | !*.[Cc]ache/ 164 | 165 | # Others 166 | ClientBin/ 167 | [Ss]tyle[Cc]op.* 168 | ~$* 169 | *~ 170 | *.dbmdl 171 | *.dbproj.schemaview 172 | *.pfx 173 | *.publishsettings 174 | node_modules/ 175 | orleans.codegen.cs 176 | 177 | # RIA/Silverlight projects 178 | Generated_Code/ 179 | 180 | # Backup & report files from converting an old project file 181 | # to a newer Visual Studio version. Backup files are not needed, 182 | # because we have git ;-) 183 | _UpgradeReport_Files/ 184 | Backup*/ 185 | UpgradeLog*.XML 186 | UpgradeLog*.htm 187 | 188 | # SQL Server files 189 | *.mdf 190 | *.ldf 191 | 192 | # Business Intelligence projects 193 | *.rdl.data 194 | *.bim.layout 195 | *.bim_*.settings 196 | 197 | # Microsoft Fakes 198 | FakesAssemblies/ 199 | 200 | # Node.js Tools for Visual Studio 201 | .ntvs_analysis.dat 202 | 203 | # Visual Studio 6 build log 204 | *.plg 205 | 206 | # Visual Studio 6 workspace options file 207 | *.opt 208 | 209 | # LightSwitch generated files 210 | GeneratedArtifacts/ 211 | _Pvt_Extensions/ 212 | ModelManifest.xml 213 | -------------------------------------------------------------------------------- /AutoSplitter/auto_split.cpp: -------------------------------------------------------------------------------- 1 | #define BOOST_ALL_STATIC_LINK 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | using namespace std; 15 | 16 | #ifdef _DEBUG 17 | #define DLOG(...) blog(LOG_INFO,(string("AutoSplitter: ") + string(__VA_ARGS__)).c_str()) 18 | #define FLOG(...) blog(LOG_INFO, (string("AutoSplitter: ") + (boost::format __VA_ARGS__).str()).c_str()) 19 | #else 20 | #define FLOG(...) __noop 21 | #define DLOG(...) __noop 22 | #endif 23 | 24 | 25 | 26 | thread plugin_main_thread; 27 | const chrono::milliseconds kWatchSpan = chrono::milliseconds(200); 28 | const string kSettingFilename = "/settings.ini"; 29 | const vector kOutputTypeTable{ "simple_file_output","adv_file_output","adv_ffmpeg_output" }; 30 | 31 | 32 | 33 | void LoadSettings(chrono::milliseconds &split_span,bool &enabled_stop,bool &enabled_restart) 34 | { 35 | auto dir = obs_module_config_path(NULL); 36 | auto filename = obs_module_config_path(kSettingFilename.c_str()); 37 | if (!boost::filesystem::exists(dir)) 38 | boost::filesystem::create_directories(boost::filesystem::path(dir)); 39 | if (!boost::filesystem::exists(filename)) 40 | { 41 | boost::property_tree::ptree default_conf; 42 | default_conf.put("feature.enable_stop", true); 43 | default_conf.put("feature.enable_restart", true); 44 | default_conf.put("split_timespan.hours", 0); 45 | default_conf.put("split_timespan.minutes", 10); 46 | default_conf.put("split_timespan.seconds", 0); 47 | 48 | boost::property_tree::write_ini(filename, default_conf); 49 | } 50 | 51 | boost::property_tree::ptree conf; 52 | boost::property_tree::read_ini(filename, conf); 53 | 54 | int hour, min, sec; 55 | enabled_stop = conf.get("feature.enable_stop"); 56 | enabled_restart = conf.get("feature.enable_restart"); 57 | hour = conf.get("split_timespan.hours"); 58 | min = conf.get("split_timespan.minutes"); 59 | sec = conf.get("split_timespan.seconds"); 60 | 61 | split_span = chrono::seconds(sec) + chrono::minutes(min) + chrono::hours(hour); 62 | 63 | FLOG( 64 | ("LoadSettings [enable_stop = %1% , enable_restart = %2% , stime_timespan h/m/s = %3%/%4%/%5% total = %6%]") 65 | % enabled_stop % enabled_restart 66 | % hour % min % sec % split_span.count() 67 | ); 68 | } 69 | 70 | obs_output_t* getActiveOutput() 71 | { 72 | obs_output_t* output; 73 | for (string type_name : kOutputTypeTable) 74 | { 75 | output = obs_get_output_by_name(type_name.c_str()); 76 | if (obs_output_active(output))return output; 77 | } 78 | return nullptr; 79 | } 80 | 81 | void ThreadEntryPoint() 82 | { 83 | DLOG("Watch thread is launched"); 84 | bool enabled_start = true; 85 | bool enabled_restart = true; 86 | chrono::milliseconds split_span; 87 | LoadSettings(split_span, enabled_start, enabled_restart); 88 | 89 | FLOG(("span: %1% / act %2% / rst %3%") % split_span.count() % enabled_start % enabled_restart); 90 | 91 | if (!enabled_start) return; 92 | auto started_time = chrono::system_clock::now(); 93 | 94 | string base_filename; 95 | bool prev_active = false; 96 | int split_count = 0; 97 | while (true) 98 | { 99 | obs_output_t* output = getActiveOutput(); 100 | bool is_active = obs_output_active(output); 101 | if (is_active && !prev_active) 102 | { 103 | // new record 104 | started_time = chrono::system_clock::now(); 105 | split_count = 0; 106 | auto out_settings = obs_output_get_settings(output); 107 | base_filename = string(obs_data_get_string(out_settings, "path")); 108 | FLOG(("set base filename (%1%)") % base_filename); 109 | obs_data_release(out_settings); 110 | } 111 | 112 | while (is_active && ((chrono::system_clock::now() - started_time) < split_span)) 113 | { 114 | // wait for split_span || wait until stop recording 115 | this_thread::sleep_for(kWatchSpan); 116 | is_active = obs_output_active(output); 117 | } 118 | 119 | if (is_active) 120 | { 121 | obs_output_stop(output); 122 | 123 | if (enabled_restart) 124 | { 125 | split_count++; 126 | auto split_count_str = (boost::format("%04d") % split_count).str(); 127 | auto new_path = boost::filesystem::path(base_filename); 128 | new_path.replace_extension("_" + split_count_str + new_path.extension().string()); 129 | auto out_settings = obs_output_get_settings(output); 130 | FLOG(("new filename (%1%)") % base_filename); 131 | 132 | obs_data_set_string(out_settings, "path", (new_path.string().c_str())); 133 | obs_output_update(output, out_settings); 134 | obs_data_release(out_settings); 135 | 136 | obs_output_start(output); 137 | started_time = chrono::system_clock::now(); 138 | } 139 | } 140 | prev_active = is_active; 141 | obs_output_release(output); 142 | this_thread::sleep_for(kWatchSpan); 143 | } 144 | 145 | } 146 | 147 | 148 | // ##################################################### 149 | 150 | OBS_DECLARE_MODULE() 151 | 152 | bool obs_module_load(void) 153 | { 154 | plugin_main_thread = thread(ThreadEntryPoint); 155 | return true; 156 | } 157 | 158 | void obs_module_unload(void) 159 | { 160 | plugin_main_thread.detach(); 161 | return; 162 | } 163 | 164 | const char* obs_module_author(void) 165 | { 166 | return "FODK"; 167 | } 168 | 169 | const char* obs_module_name(void) 170 | { 171 | return "AutoSplit"; 172 | } 173 | 174 | const char* obs_module_description(void) 175 | { 176 | return "Stop/Start when the time coming"; 177 | } 178 | -------------------------------------------------------------------------------- /AutoSplitter/AutoSplitter.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {D247B61E-2418-47C6-9CB1-4655DAD7B370} 23 | AutoSplitter 24 | 8.1 25 | 26 | 27 | 28 | DynamicLibrary 29 | true 30 | v140 31 | MultiByte 32 | 33 | 34 | DynamicLibrary 35 | false 36 | v140 37 | true 38 | MultiByte 39 | 40 | 41 | DynamicLibrary 42 | true 43 | v140 44 | MultiByte 45 | 46 | 47 | DynamicLibrary 48 | false 49 | v140 50 | true 51 | MultiByte 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | $(BOOST_ROOT)\;D:\temp\OSB-plugin\obs-studio\libobs;$(IncludePath) 73 | $(BOOST_ROOT)\stage\x64\lib;D:\temp\OSB-plugin\obs-studio\build\libobs\Debug;$(LibraryPath) 74 | 75 | 76 | $(BOOST_ROOT)\;D:\temp\OSB-plugin\obs-studio\libobs;$(IncludePath) 77 | $(BOOST_ROOT)\stage\x64\lib;D:\temp\OSB-plugin\obs-studio\build\libobs\Debug;$(LibraryPath) 78 | 79 | 80 | $(BOOST_ROOT)\;D:\temp\OSB-plugin\obs-studio\libobs;$(IncludePath) 81 | $(BOOST_ROOT)\stage\x64\lib;D:\temp\OSB-plugin\obs-studio\build\libobs\Debug;$(LibraryPath) 82 | 83 | 84 | $(BOOST_ROOT)\;D:\temp\OSB-plugin\obs-studio\libobs;$(IncludePath) 85 | $(BOOST_ROOT)\stage\x64\lib;D:\temp\OSB-plugin\obs-studio\build\libobs\Debug;$(LibraryPath) 86 | 87 | 88 | 89 | Level3 90 | Disabled 91 | true 92 | 93 | 94 | D:\temp\OSB-plugin\obs-studio\build\libobs\Debug\obs.lib;%(AdditionalDependencies) 95 | 96 | 97 | cmd /c copy /y "$(TargetPath)" "C:\Program Files (x86)\obs-studio\bin\64bit\obs-plugins\64bit" 98 | 99 | 100 | 101 | 102 | Level3 103 | Disabled 104 | true 105 | 106 | 107 | D:\temp\OSB-plugin\obs-studio\build\libobs\Debug\obs.lib;%(AdditionalDependencies) 108 | 109 | 110 | cmd /c copy /y "$(TargetPath)" "C:\Program Files (x86)\obs-studio\bin\64bit\obs-plugins\64bit" 111 | 112 | 113 | 114 | 115 | Level3 116 | MaxSpeed 117 | true 118 | true 119 | true 120 | 121 | 122 | true 123 | true 124 | D:\temp\OSB-plugin\obs-studio\build\libobs\Debug\obs.lib;%(AdditionalDependencies) 125 | 126 | 127 | cmd /c copy /y "$(TargetPath)" "C:\Program Files (x86)\obs-studio\bin\64bit\obs-plugins\64bit" 128 | 129 | 130 | 131 | 132 | Level3 133 | MaxSpeed 134 | true 135 | true 136 | true 137 | 138 | 139 | true 140 | true 141 | D:\temp\OSB-plugin\obs-studio\build\libobs\Debug\obs.lib;%(AdditionalDependencies) 142 | 143 | 144 | cmd /c copy /y "$(TargetPath)" "C:\Program Files (x86)\obs-studio\bin\64bit\obs-plugins\64bit" 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | --------------------------------------------------------------------------------