00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "stdafx.h"
00026 #include "vsconv.h"
00027 #include "vsconvDlg.h"
00028 #include "..\..\subtitles\VobSubFile.h"
00029
00030 #ifdef _DEBUG
00031 #define new DEBUG_NEW
00032 #endif
00033
00034
00035
00036
00037 BEGIN_MESSAGE_MAP(CvsconvApp, CWinApp)
00038 ON_COMMAND(ID_HELP, CWinApp::OnHelp)
00039 END_MESSAGE_MAP()
00040
00041
00042
00043
00044 CvsconvApp::CvsconvApp()
00045 {
00046
00047
00048 }
00049
00050
00051
00052
00053 CvsconvApp theApp;
00054
00055
00056
00057
00058 BOOL CvsconvApp::InitInstance()
00059 {
00060
00061
00062
00063 InitCommonControls();
00064
00065 CWinApp::InitInstance();
00066
00067 AfxEnableControlContainer();
00068
00069
00070
00071 {
00072 CString in, out;
00073 CVobSubFile::SubFormat sf = CVobSubFile::None;
00074 int iLang = -1;
00075 bool fIgnoreForcedOnly = false;
00076 bool fForcedOnly = false;
00077
00078 try
00079 {
00080 for(int i = 1; i < __argc; i++)
00081 {
00082 if(__targv[i][0] == '-' || __targv[i][0] == '/')
00083 {
00084 CString sw(&__targv[i][1]);
00085
00086 if(sw == _T("f"))
00087 {
00088 if(++i < __argc && __targv[i][0] != '-' && __targv[i][0] != '/')
00089 {
00090 CString fmt = CString(__targv[i]).MakeLower();
00091
00092 if(fmt == _T("winsubmux"))
00093 sf = CVobSubFile::WinSubMux;
00094 else if(fmt == _T("scenarist"))
00095 sf = CVobSubFile::Scenarist;
00096 else if(fmt == _T("maestro"))
00097 sf = CVobSubFile::Maestro;
00098 else
00099 throw _T("Unrecognized conversion format");
00100 }
00101 else
00102 throw _T("No conversion format given");
00103 }
00104 else if(sw == _T("i"))
00105 {
00106 if(++i < __argc && __targv[i][0] != '-' && __targv[i][0] != '/')
00107 in = __targv[i];
00108 else
00109 throw _T("Missing input file");
00110 }
00111 else if(sw == _T("o"))
00112 {
00113 if(++i < __argc && __targv[i][0] != '-' && __targv[i][0] != '/')
00114 out = __targv[i];
00115 else
00116 throw _T("Missing output file");
00117 }
00118 else if(sw == _T("id"))
00119 {
00120 if(++i < __argc && __targv[i][0] != '-' && __targv[i][0] != '/')
00121 iLang = _tcstol(__targv[i], NULL, 10);
00122 else
00123 throw _T("Missing stream id");
00124 }
00125 else if(sw == _T("ignoreforcedonly"))
00126 {
00127 fIgnoreForcedOnly = true;
00128 }
00129 else if(sw == _T("forcedonly"))
00130 {
00131 fForcedOnly = true;
00132 }
00133 }
00134 }
00135
00136 if(!in.IsEmpty() && !out.IsEmpty() && sf != CVobSubFile::None)
00137 {
00138 CVobSubFile vsf(NULL);
00139
00140 if(!vsf.Open(in))
00141 throw _T("Can't open input");
00142
00143 if(iLang >= 0 && iLang < 32)
00144 vsf.m_iLang = iLang;
00145
00146 if(fForcedOnly)
00147 vsf.m_fOnlyShowForcedSubs = true;
00148
00149 if(fIgnoreForcedOnly)
00150 vsf.m_fOnlyShowForcedSubs = false;
00151
00152 if(!vsf.Save(out, sf))
00153 throw _T("Can't save output");
00154
00155 return FALSE;
00156 }
00157 }
00158 catch(LPCTSTR msg)
00159 {
00160 AfxMessageBox(CString(_T("Error: ")) + msg);
00161 }
00162
00163 AfxMessageBox(
00164 _T("Usage: vsconv.exe <switches>\n\n")
00165 _T("-f \"format\" (winsubmux, scenarist, maestro)\n")
00166 _T("-i \"input\"\n")
00167 _T("-o \"output\"\n")
00168 _T("-id 0-31 (optional)\n")
00169 _T("-ignoreforcedonly (optional)\n")
00170 _T("-forcedonly (optional)\n")
00171 );
00172
00173 return FALSE;
00174 }
00175
00176
00177 return FALSE;
00178
00179
00180 CvsconvDlg dlg;
00181 m_pMainWnd = &dlg;
00182 INT_PTR nResponse = dlg.DoModal();
00183 if (nResponse == IDOK)
00184 {
00185
00186
00187 }
00188 else if (nResponse == IDCANCEL)
00189 {
00190
00191
00192 }
00193
00194
00195
00196 return FALSE;
00197 }