support load audio codec param and video codec param from merge_av.cfg
正在显示
1 个修改的文件
包含
50 行增加
和
0 行删除
| @@ -6,6 +6,7 @@ | @@ -6,6 +6,7 @@ | ||
| 6 | #include <vector> | 6 | #include <vector> |
| 7 | #include <string.h> | 7 | #include <string.h> |
| 8 | 8 | ||
| 9 | + | ||
| 9 | bool only_print = false; | 10 | bool only_print = false; |
| 10 | using namespace std; | 11 | using namespace std; |
| 11 | 12 | ||
| @@ -214,10 +215,59 @@ int readfile(char * filename) | @@ -214,10 +215,59 @@ int readfile(char * filename) | ||
| 214 | return 0; | 215 | return 0; |
| 215 | } | 216 | } |
| 216 | 217 | ||
| 218 | +#ifdef WIN32 | ||
| 219 | +#include <Windows.h> | ||
| 220 | + | ||
| 221 | +char exe_path[MAX_PATH] = { 0 }; | ||
| 222 | + | ||
| 223 | +int GetExePath() | ||
| 224 | +{ | ||
| 225 | + char path_buffer[MAX_PATH] = ""; | ||
| 226 | + char drive[32] = ""; | ||
| 227 | + char dir[256] = ""; | ||
| 228 | + char fname[64] = ""; | ||
| 229 | + char ext[32] = ""; | ||
| 230 | + | ||
| 231 | + GetModuleFileNameA(NULL, path_buffer, 256); | ||
| 232 | + _splitpath(path_buffer, drive, dir, fname, ext); | ||
| 233 | + | ||
| 234 | + strcpy(exe_path, drive); | ||
| 235 | + strcat(exe_path, dir); | ||
| 236 | + return 0; | ||
| 237 | +} | ||
| 238 | +#endif | ||
| 239 | + | ||
| 217 | void load_codec_param() | 240 | void load_codec_param() |
| 218 | { | 241 | { |
| 219 | strcpy(acodec_param, default_acodec_param); | 242 | strcpy(acodec_param, default_acodec_param); |
| 220 | strcpy(vcodec_param, default_vcodec_param); | 243 | strcpy(vcodec_param, default_vcodec_param); |
| 244 | + | ||
| 245 | + char cfgfile[1024]; | ||
| 246 | +#ifdef WIN32 | ||
| 247 | + GetExePath(); | ||
| 248 | + strcpy(cfgfile, exe_path); | ||
| 249 | +#else | ||
| 250 | + strcpy(cfgfile , "~/"; | ||
| 251 | +#endif | ||
| 252 | + strcat(cfgfile, "merge_av.cfg"); | ||
| 253 | + ifstream fin(cfgfile); | ||
| 254 | + if (!fin) { | ||
| 255 | + return; | ||
| 256 | + } | ||
| 257 | + const int LINE_LENGTH = 1000; | ||
| 258 | + char str[LINE_LENGTH]; | ||
| 259 | + str[0] = 0; | ||
| 260 | + if (fin.getline(str, LINE_LENGTH)) | ||
| 261 | + { | ||
| 262 | + printf("\nload video codec from %s: %s\n", cfgfile, str); | ||
| 263 | + strcpy(vcodec_param, str); | ||
| 264 | + } | ||
| 265 | + str[0] = 0; | ||
| 266 | + if (fin.getline(str, LINE_LENGTH)) | ||
| 267 | + { | ||
| 268 | + printf("load audio codec from %s: %s\n", cfgfile, str); | ||
| 269 | + strcpy(acodec_param, str); | ||
| 270 | + } | ||
| 221 | } | 271 | } |
| 222 | 272 | ||
| 223 | int main(int argc, char * argv[]) | 273 | int main(int argc, char * argv[]) |
-
请 注册 或 登录 后发表评论