Fixes some bugs and adds unfinished command parser

This commit is contained in:
Kristian Knarvik 2019-06-14 13:08:08 +02:00
parent dbb5bc7f94
commit 104d9ccb4b
4 changed files with 753 additions and 10 deletions

580
.idea/workspace.xml Normal file
View File

@ -0,0 +1,580 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ArtifactsWorkspaceSettings">
<artifacts-to-build>
<artifact name="FFmpegConvert" />
</artifacts-to-build>
</component>
<component name="ChangeListManager">
<list default="true" id="e9b48a04-29ff-46ce-9630-42742dc34d68" name="Default" comment="Adds surround to stereo">
<change beforePath="$PROJECT_DIR$/src/ffmpegconverter/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ffmpegconverter/Main.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ffmpegconverter/converter/AnimeConverter.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ffmpegconverter/converter/AnimeConverter.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ffmpegconverter/converter/Converter.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ffmpegconverter/converter/Converter.java" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/META-INF/MANIFEST.MF">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="51">
<caret line="3" selection-start-line="3" selection-end-line="3" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/ffmpegconverter/converter/Converter.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2907">
<caret line="178" column="13" selection-start-line="178" selection-start-column="13" selection-end-line="178" selection-end-column="13" />
<folding>
<element signature="e#12992#12993#0" expanded="true" />
<element signature="e#13075#13076#0" expanded="true" />
<element signature="e#13124#13125#0" expanded="true" />
<element signature="e#13187#13188#0" expanded="true" />
<element signature="method#concatenate#0;class#Converter#0" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/ffmpegconverter/converter/AnimeConverter.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="65">
<caret line="14" column="59" selection-start-line="14" selection-start-column="59" selection-end-line="14" selection-end-column="59" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/ffmpegconverter/converter/AudioConverter.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="34">
<caret line="7" column="30" selection-start-line="7" selection-start-column="30" selection-end-line="7" selection-end-column="30" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/ffmpegconverter/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="272">
<caret line="25" column="10" selection-start-line="25" selection-start-column="10" selection-end-line="25" selection-end-column="10" />
<folding>
<element signature="method#testArgumentValue#0;class#converterArgument#0;class#Main#0" />
<element signature="method#tokenizer#0;class#Main#0" />
<element signature="method#animeConverter#0;class#Main#0" />
<element signature="method#getList#0;class#Main#0" />
<element signature="method#readInput#0;class#Main#0" />
<element signature="method#getChoice#0;class#Main#0" />
<element signature="method#getChoice#1;class#Main#0" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/ffmpegconverter/converter/VideoConverter.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="731">
<caret line="56" column="38" selection-start-line="56" selection-start-column="38" selection-end-line="56" selection-end-column="38" />
<folding>
<element signature="imports" expanded="true" />
<element signature="docComment;method#processFile#0;class#VideoConverter#0" />
<element signature="method#processFile#0;class#VideoConverter#0" />
</folding>
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>stripexten</find>
<find>System.out.</find>
<find>listSubtitlesRelative</find>
<find>debug</find>
<find>isimage</find>
</findStrings>
</component>
<component name="Git.Settings">
<option name="ROOT_SYNC" value="DONT_SYNC" />
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/src/ffmpegconverter/converter/VideoConverter.java" />
<option value="$PROJECT_DIR$/src/ffmpegconverter/Main.java" />
<option value="$PROJECT_DIR$/src/ffmpegconverter/converter/Converter.java" />
<option value="$PROJECT_DIR$/src/ffmpegconverter/converter/AnimeConverter.java" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="-8" />
<option name="y" value="-8" />
<option name="width" value="974" />
<option name="height" value="728" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="FFmpegConvert1" type="b2602c69:ProjectViewProjectNode" />
<item name="FFmpegConvert1" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="FFmpegConvert1" type="b2602c69:ProjectViewProjectNode" />
<item name="FFmpegConvert1" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="FFmpegConvert1" type="b2602c69:ProjectViewProjectNode" />
<item name="FFmpegConvert1" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="ffmpegconverter" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="FFmpegConvert1" type="b2602c69:ProjectViewProjectNode" />
<item name="FFmpegConvert1" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="ffmpegconverter" type="462c0819:PsiDirectoryNode" />
<item name="converter" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="Scope" />
<pane id="PackagesPane" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1559848538589" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/../rogue-one-oh-one" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="nodejs_package_manager_path" value="npm" />
<property name="project.structure.last.edited" value="Project" />
<property name="project.structure.proportion" value="0.15332031" />
<property name="project.structure.side.proportion" value="0.2" />
<property name="settings.editor.selected.configurable" value="vcs.Git" />
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="C:\Users\Kristian\IdeaProjects\FFmpegConvert1" />
</key>
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager">
<configuration name="Main" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="ffmpegconverter.Main" />
<module name="FFmpegConvert1" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="ffmpegconverter.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration default="true" type="Application" factoryName="Application">
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration default="true" type="JUnit" factoryName="JUnit">
<option name="TEST_OBJECT" value="class" />
<option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration default="true" type="TestNG">
<option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
<properties />
<listeners />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.Main" />
</list>
</recent_temporary>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="e9b48a04-29ff-46ce-9630-42742dc34d68" name="Default" comment="" />
<created>1538261009416</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1538261009416</updated>
<workItem from="1538261010802" duration="1312000" />
<workItem from="1538305844416" duration="234000" />
<workItem from="1538306114165" duration="22000" />
<workItem from="1538473299929" duration="2733000" />
<workItem from="1538701686924" duration="2951000" />
<workItem from="1539366793700" duration="978000" />
<workItem from="1539518274284" duration="1207000" />
<workItem from="1539652670425" duration="12000" />
<workItem from="1540077462430" duration="678000" />
<workItem from="1540289525699" duration="27000" />
<workItem from="1540546688988" duration="3065000" />
<workItem from="1540803435545" duration="470000" />
<workItem from="1540890041603" duration="17000" />
<workItem from="1541080155632" duration="1994000" />
<workItem from="1541370686228" duration="1377000" />
<workItem from="1541440722679" duration="603000" />
<workItem from="1541446539385" duration="1788000" />
<workItem from="1541502766248" duration="32000" />
<workItem from="1541862167823" duration="2297000" />
<workItem from="1541879330349" duration="3080000" />
<workItem from="1542063661865" duration="5207000" />
<workItem from="1542477955964" duration="1322000" />
<workItem from="1542567572829" duration="614000" />
<workItem from="1542764996067" duration="1320000" />
<workItem from="1542792684664" duration="781000" />
<workItem from="1543154558384" duration="2435000" />
<workItem from="1543231497156" duration="8583000" />
<workItem from="1543695540458" duration="627000" />
<workItem from="1543717952622" duration="653000" />
<workItem from="1544178702233" duration="1339000" />
<workItem from="1544265338810" duration="691000" />
<workItem from="1544370503492" duration="14000" />
<workItem from="1544392514407" duration="625000" />
<workItem from="1544703100915" duration="838000" />
<workItem from="1545090822083" duration="169000" />
<workItem from="1545091025691" duration="20000" />
<workItem from="1547458604849" duration="636000" />
<workItem from="1547567517843" duration="15000" />
<workItem from="1548004942668" duration="2143000" />
<workItem from="1548363813873" duration="1222000" />
<workItem from="1548532950666" duration="616000" />
<workItem from="1548598573963" duration="614000" />
<workItem from="1549193918003" duration="622000" />
<workItem from="1549758586148" duration="756000" />
<workItem from="1549878315673" duration="2543000" />
<workItem from="1550165974027" duration="1212000" />
<workItem from="1550243114655" duration="634000" />
<workItem from="1550317826949" duration="3756000" />
<workItem from="1550511529465" duration="625000" />
<workItem from="1550768108194" duration="608000" />
<workItem from="1551168781600" duration="41000" />
<workItem from="1552739936622" duration="215000" />
<workItem from="1552770909935" duration="1056000" />
<workItem from="1553203535796" duration="624000" />
<workItem from="1553256078273" duration="73000" />
<workItem from="1554589352446" duration="1441000" />
<workItem from="1556564750100" duration="687000" />
<workItem from="1556817189653" duration="837000" />
<workItem from="1556917090805" duration="590000" />
<workItem from="1557359278642" duration="1854000" />
<workItem from="1557572721027" duration="2589000" />
<workItem from="1557701234310" duration="6253000" />
<workItem from="1557994156392" duration="8429000" />
<workItem from="1558270332068" duration="1231000" />
<workItem from="1559411406801" duration="621000" />
<workItem from="1559765370819" duration="3857000" />
<workItem from="1560477751040" duration="642000" />
</task>
<task id="LOCAL-00001" summary="Adds missing files">
<created>1538261222377</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1538261222377</updated>
</task>
<task id="LOCAL-00002" summary="Hopefully fixes issues #1 and #2&#10;&#10;File collision handling similar to windows">
<created>1538475994282</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1538475994282</updated>
</task>
<task id="LOCAL-00003" summary="Adds hardsubbing of subtitles with same name as video file&#10;&#10;Better file collision detection&#10;Adds debug mode to only render part of the video">
<created>1542105228199</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1542105228199</updated>
</task>
<task id="LOCAL-00004" summary="Adds surround to stereo">
<created>1545090945641</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1545090945641</updated>
</task>
<option name="localTasksCounter" value="5" />
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="97157000" />
</component>
<component name="TodoView">
<todo-panel id="selected-file">
<is-autoscroll-to-source value="true" />
</todo-panel>
<todo-panel id="all">
<are-packages-shown value="true" />
<is-autoscroll-to-source value="true" />
</todo-panel>
</component>
<component name="ToolWindowManager">
<frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
<layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.1098081" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Image Layers" order="2" />
<window_info id="Designer" order="3" />
<window_info id="UI Designer" order="4" />
<window_info id="Capture Tool" order="5" />
<window_info id="Favorites" order="6" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info active="true" anchor="bottom" id="Run" order="2" sideWeight="0.75054705" visible="true" weight="0.7659805" />
<window_info anchor="bottom" id="Debug" order="3" sideWeight="0.49895614" weight="0.39869988" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" sideWeight="0.49946696" weight="0.32936078" />
<window_info anchor="bottom" id="Version Control" order="7" sideWeight="0.4989059" weight="0.32932165" />
<window_info anchor="bottom" id="Database Changes" order="8" show_stripe_button="false" />
<window_info anchor="bottom" id="Statistic" order="9" sideWeight="0.49946696" weight="0.32936078" />
<window_info anchor="bottom" id="Terminal" order="10" sideWeight="0.4989059" weight="0.32932165" />
<window_info anchor="bottom" id="Event Log" order="11" sideWeight="0.24945295" side_tool="true" weight="0.47811815" />
<window_info anchor="bottom" id="Messages" order="12" sideWeight="0.49840087" weight="0.33152762" />
<window_info anchor="bottom" id="Docker" order="13" show_stripe_button="false" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="right" id="Palette" order="3" />
<window_info anchor="right" id="Capture Analysis" order="4" />
<window_info anchor="right" id="Theme Preview" order="5" />
<window_info anchor="right" id="Database" order="6" />
<window_info anchor="right" id="Palette&#9;" order="7" />
<window_info anchor="right" id="Maven Projects" order="8" />
<window_info anchor="right" id="Maven" order="9" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="Adds missing files" />
<MESSAGE value="Hopefully fixes issues #1 and #2&#10;&#10;File collision handling similar to windows" />
<MESSAGE value="Adds hardsubbing of subtitles with same name as video file&#10;&#10;Better file collision detection&#10;Adds debug mode to only render part of the video" />
<MESSAGE value="Adds surround to stereo" />
<option name="LAST_COMMIT_MESSAGE" value="Adds surround to stereo" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/misc.xml" />
<entry file="file://$PROJECT_DIR$/uiDesigner.xml" />
<entry file="file://$PROJECT_DIR$/.gitignore">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="34">
<caret line="2" column="7" lean-forward="true" selection-start-line="2" selection-start-column="7" selection-end-line="2" selection-end-column="7" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/META-INF/MANIFEST.MF">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="51">
<caret line="3" selection-start-line="3" selection-end-line="3" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/ffmpegconverter/converter/Converter.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2907">
<caret line="178" column="13" selection-start-line="178" selection-start-column="13" selection-end-line="178" selection-end-column="13" />
<folding>
<element signature="e#12992#12993#0" expanded="true" />
<element signature="e#13075#13076#0" expanded="true" />
<element signature="e#13124#13125#0" expanded="true" />
<element signature="e#13187#13188#0" expanded="true" />
<element signature="method#concatenate#0;class#Converter#0" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/ffmpegconverter/converter/AudioConverter.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="34">
<caret line="7" column="30" selection-start-line="7" selection-start-column="30" selection-end-line="7" selection-end-column="30" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/ffmpegconverter/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="272">
<caret line="25" column="10" selection-start-line="25" selection-start-column="10" selection-end-line="25" selection-end-column="10" />
<folding>
<element signature="method#testArgumentValue#0;class#converterArgument#0;class#Main#0" />
<element signature="method#tokenizer#0;class#Main#0" />
<element signature="method#animeConverter#0;class#Main#0" />
<element signature="method#getList#0;class#Main#0" />
<element signature="method#readInput#0;class#Main#0" />
<element signature="method#getChoice#0;class#Main#0" />
<element signature="method#getChoice#1;class#Main#0" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/ffmpegconverter/converter/VideoConverter.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="731">
<caret line="56" column="38" selection-start-line="56" selection-start-column="38" selection-end-line="56" selection-end-column="38" />
<folding>
<element signature="imports" expanded="true" />
<element signature="docComment;method#processFile#0;class#VideoConverter#0" />
<element signature="method#processFile#0;class#VideoConverter#0" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/ffmpegconverter/converter/AnimeConverter.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="65">
<caret line="14" column="59" selection-start-line="14" selection-start-column="59" selection-end-line="14" selection-end-column="59" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
<component name="masterDetails">
<states>
<state key="ArtifactsStructureConfigurable.UI">
<settings>
<artifact-editor />
<last-edited>FFmpegConvert</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
<option value="0.5" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="FacetStructureConfigurable.UI">
<settings>
<last-edited>No facets are configured</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="GlobalLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="JdkListConfigurable.UI">
<settings>
<last-edited>1.8</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ModuleStructureConfigurable.UI">
<settings>
<last-edited>FFmpegConvert1</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
<option value="0.6" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>1.8</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ProjectLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>

View File

@ -15,12 +15,16 @@ import java.util.function.Predicate;
* Converts a files or files in a folder to a web playable mp4. * Converts a files or files in a folder to a web playable mp4.
*/ */
public class Main { public class Main {
private static final String FFPROBE_PATH = "C:\\Users\\Kristian\\Nextcloud\\Programming\\AutoIt\\FFMPEGConvert\\ffmpeg\\bin\\ffprobe"; //Can be just ffprobe if it's in the path private static final String FFPROBE_PATH = "C:\\Users\\Kristian\\Downloads\\ffmpeg-20190427-8019395-win64-static\\bin\\ffprobe.exe"; //Can be just ffprobe if it's in the path
private static final String FFMPEG_PATH = "C:\\Users\\Kristian\\Nextcloud\\Programming\\AutoIt\\FFMPEGConvert\\ffmpeg\\bin\\ffmpeg"; //Can be just ffmpeg if it's in the path private static final String FFMPEG_PATH = "C:\\Users\\Kristian\\Downloads\\ffmpeg-20190427-8019395-win64-static\\bin\\ffmpeg.exe"; //Can be just ffmpeg if it's in the path
private static Scanner in = new Scanner(System.in); private static Scanner in = new Scanner(System.in);
private static Converter con = null; private static Converter con = null;
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
//System.out.println(tokenizer("AnimeConverter -audiolang jap,eng -sublang eng,nor,* \"C:\\Users\\Kristian\\Downloads\\Anime\\[Kametsu] ERASED (BD 1080p Hi10 FLAC)\""));
//parser(tokenizer("AnimeConverter \"C:\\Users\\Kristian\\Downloads\\Anime\\[Kametsu] ERASED (BD 1080p Hi10 FLAC)\""));
//System.exit(1);
int choice = getChoice("Which converter do you want do use?\n1. Anime to web mp4\n2. Audio converter\n3. Video converter", 1, 3); int choice = getChoice("Which converter do you want do use?\n1. Anime to web mp4\n2. Audio converter\n3. Video converter", 1, 3);
System.out.println("Input for this converter:"); System.out.println("Input for this converter:");
@ -69,6 +73,111 @@ public class Main {
} }
} }
private enum converterArgumentValueType {
BOOLEAN,
COMMA_SEPARATED_LIST,
SINGLE_VALUE,
INT
}
private static class converterArgument {
private String name;
private boolean valueRequired;
private converterArgumentValueType valueType;
private converterArgument(String name, boolean valueRequired, converterArgumentValueType valueType) {
this.name = name;
this.valueRequired = valueRequired;
this.valueType = valueType;
}
private boolean testArgumentValue(String value) {
if (value.length() == 0) {
return !valueRequired;
}
if (valueRequired && value.startsWith("-")) {
return false;
}
switch (valueType) {
case BOOLEAN:
String lower = value.toLowerCase();
return lower.equals("true") || lower.equals("false");
case COMMA_SEPARATED_LIST:
return !value.contains(" ");
case SINGLE_VALUE:
return !value.contains(" ");
case INT:
Integer.parseInt(value);
return true;
}
return false;
}
}
private static void parser(List<String> tokens) {
String[] types = {"animeconverter", "audioconverter", "videoconverter"};
converterArgument[] commonArgs = {
new converterArgument("-recursions", true, converterArgumentValueType.INT)
};
converterArgument[] animeArgs = {
};
converterArgument[] audioArgs = {
new converterArgument("-outext", true, converterArgumentValueType.SINGLE_VALUE)
};
converterArgument[] videoArgs = {
new converterArgument("-outext", true, converterArgumentValueType.SINGLE_VALUE)
};
String type = tokens.get(0).toLowerCase();
if (!listContains(types, s -> s.equals(type))) {
throw new IllegalArgumentException("Unknown converter type chosen.");
}
if (tokens.size() < 2) {
throw new IllegalArgumentException("No file/folder path in argument.");
}
for (int i = 1; i < tokens.size() - 1; i++) {
//TODO: Find the type of argument and check the value
//TODO: Find an executable way to represent the chain of commands parsed
}
}
private static List<String> tokenizer(String input) {
List<String> tokens = new ArrayList<>();
Boolean startedQuote = false;
StringBuilder currentToken = new StringBuilder();
for (int i = 0; i < input.length(); i++) {
char c = input.charAt(i);
if (c == ' ') {
if (!startedQuote) {
if (!currentToken.toString().trim().equals("")) {
tokens.add(currentToken.toString());
currentToken = new StringBuilder();
} else {
currentToken = new StringBuilder();
}
} else {
currentToken.append(c);
}
} else if (c == '"') {
if (startedQuote) {
if (!currentToken.toString().trim().equals("")) {
tokens.add(currentToken.toString());
currentToken = new StringBuilder();
}
startedQuote = false;
} else {
startedQuote = true;
currentToken = new StringBuilder();
}
} else {
currentToken.append(c);
if (i == input.length() - 1) {
tokens.add(currentToken.toString());
}
}
}
return tokens;
}
private static void animeConverter() { private static void animeConverter() {
System.out.println("[Audio languages jap,eng,ger,fre] [Subtitle languages eng,ger,fre] [Convert to stereo if necessary true/false] [Prevent signs&songs subtitles true/false]\nYour input: "); System.out.println("[Audio languages jap,eng,ger,fre] [Subtitle languages eng,ger,fre] [Convert to stereo if necessary true/false] [Prevent signs&songs subtitles true/false]\nYour input: ");
List<String> input = readInput(4); List<String> input = readInput(4);

View File

@ -9,6 +9,7 @@ public class AnimeConverter extends Converter {
private String[] subtitleLang; private String[] subtitleLang;
private boolean toStereo; private boolean toStereo;
private boolean preventSignsAndSongs; private boolean preventSignsAndSongs;
private boolean debug = false;
/** /**
* @param ffprobePath Path/command to ffprobe * @param ffprobePath Path/command to ffprobe
@ -58,6 +59,11 @@ public class AnimeConverter extends Converter {
*/ */
private String[] builderCommand(String executable, String fileName, String[] streams, String outFile) { private String[] builderCommand(String executable, String fileName, String[] streams, String outFile) {
List<String> command = ffmpegWebVideo(executable, fileName); List<String> command = ffmpegWebVideo(executable, fileName);
if (this.debug) {
addDebug(command, 50, 120);
}
for (String lang : audioLang) { for (String lang : audioLang) {
List<Integer> audioStreams = listAudio(streams, lang); List<Integer> audioStreams = listAudio(streams, lang);
if (audioStreams.size() > 0) { if (audioStreams.size() > 0) {
@ -84,21 +90,28 @@ public class AnimeConverter extends Converter {
private void addSubtitles(String[] streams, List<Integer> videoStreams, List<String> command, String fileName) { private void addSubtitles(String[] streams, List<Integer> videoStreams, List<String> command, String fileName) {
for (String lang : subtitleLang) { for (String lang : subtitleLang) {
List<Integer> subtitleStreams = listSubtitles(streams, lang); List<Integer> subtitleStreams;
if (subtitleStreams.size() > 0 && videoStreams.size() > 0 && isImageSub(streams, subtitleStreams.get(0))) { List<Integer> subtitleStreamsAbsolute;
if (lang.equals("*")) {
subtitleStreams = listSubtitlesRelative(streams);
subtitleStreamsAbsolute = listSubtitles(streams);
} else if (preventSignsAndSongs) {
subtitleStreams = listSubtitlesRelative(streams, lang, new String[]{"title=Signs"});
subtitleStreamsAbsolute = listSubtitles(streams, lang, new String[]{"title=Signs"});
} else {
subtitleStreams = listSubtitlesRelative(streams, lang);
subtitleStreamsAbsolute = listSubtitles(streams, lang);
}
if (subtitleStreams.size() > 0 && videoStreams.size() > 0 && isImageSub(streams, subtitleStreamsAbsolute.get(0))) {
command.add("-filter_complex"); command.add("-filter_complex");
command.add("[0:v:" + listVideo(streams).get(0) + "][0:" + subtitleStreams.get(0) + "]overlay"); command.add("[0:v:" + listVideo(streams).get(0) + "][0:" + subtitleStreamsAbsolute.get(0) + "]overlay");
break; break;
} else if (subtitleStreams.size() > 0) { } else if (subtitleStreams.size() > 0) {
if (videoStreams.size() > 0) { if (videoStreams.size() > 0) {
command.add("-map"); command.add("-map");
command.add("0:" + listVideo(streams).get(0)); command.add("0:" + listVideo(streams).get(0));
} }
if (preventSignsAndSongs) {
subtitleStreams = listSubtitlesRelative(streams, lang, new String[]{"title=Signs"});
} else {
subtitleStreams = listSubtitlesRelative(streams, lang);
}
if (subtitleStreams.size() > 0) { if (subtitleStreams.size() > 0) {
command.add("-vf"); command.add("-vf");
command.add("subtitles='" + fileName.replace("'", "\'") + "':si=" + subtitleStreams.get(0)); command.add("subtitles='" + fileName.replace("'", "\'") + "':si=" + subtitleStreams.get(0));

View File

@ -162,6 +162,31 @@ public abstract class Converter {
return listIndexes(list, (string) -> string.contains("codec_type=audio") && string.contains("language=" + lang)); return listIndexes(list, (string) -> string.contains("codec_type=audio") && string.contains("language=" + lang));
} }
/**
* Lists all subtitle streams of a certain language relatively to the number of subtitle streams.
* 0-based.
* Filters out all indexes containing anything in illegal
*
* @param list A list of ffprobe indexes
* @param lang The wanted language
* @param illegal A list of strings not to allow (Songs & Signs for example)
* @return An integer list containing just the wanted indexes
*/
static List<Integer> listSubtitles(String[] list, String lang, String[] illegal) {
List<Integer> subtitles = listIndexes(list, (string) -> string.contains("codec_type=subtitle")
&& string.contains("language=" + lang));
List<Integer> notWanted = listIndexes(list, (string) -> {
for (String s : illegal) {
if (string.contains(s)) {
return true;
}
}
return false;
});
subtitles.removeAll(notWanted);
return subtitles;
}
/** /**
* Lists all subtitle streams of a certain language. * Lists all subtitle streams of a certain language.
* *
@ -227,6 +252,22 @@ public abstract class Converter {
return wanted; return wanted;
} }
/**
* Lists all subtitle streams relatively to the number of subtitle streams.
* 0-based.
*
* @param list A list of ffprobe indexes
* @return An integer list containing just the wanted indexes
*/
static List<Integer> listSubtitlesRelative(String[] list) {
list = subList(list, (string) -> string.contains("codec_type=subtitle"));
List<Integer> wanted = new ArrayList<>();
for (int i = 0; i < list.length; i++) {
wanted.add(i);
}
return wanted;
}
/** /**
* Lists all indexes fulfilling a predicate. * Lists all indexes fulfilling a predicate.
* *