Last active
December 10, 2016 14:08
-
-
Save m13253/8298996 to your computer and use it in GitHub Desktop.
Convert Xunlei XV media file to FLV media file. Origin: http://hi.baidu.com/naylonslain/item/9586125a9f5979dbd58bac47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int convert_file(char *szSourceFile, int bIsFastConv) | |
{ | |
char szNewFileName[256] = {0}; | |
int buffer[0x400]; | |
int i; | |
char flag; | |
char data; | |
if (bIsFastConv) { // 一秒转换模式 | |
FILE *fp = fopen(szSourceFile, "rb+"); | |
if (!fp) { | |
printf("未找到文件.\n\n"); | |
return 0; | |
} | |
fseek(fp, 0x200000, 0); | |
for (i = 0; i < 0x400; i++) { | |
buffer[i] = fgetc(fp); | |
} | |
flag = 0x4C - (char)buffer[1]; | |
if (flag + (char)buffer[2] == 0x56) { | |
// 开始解码 | |
fseek(fp, 0x200000, 0); | |
fputc(0x46, fp); | |
for (i = 0; i < 3; i++) { | |
data = (char)buffer[1 + i] + flag; | |
fputc(data, fp); | |
} | |
for (i = 0; i < 0x3FC; i++) { | |
data = (char)buffer[4 + i] + flag; | |
fputc(data, fp); | |
} | |
fseek(fp, 0x20000A, 0); | |
fputc(32, fp); | |
// 修正文件头 | |
fseek(fp, 0, 0); | |
fputc(70, fp); | |
fputc(76, fp); | |
fputc(86, fp); | |
fputc(1, fp); | |
fputc(5, fp); | |
fputc(0, fp); | |
fputc(0, fp); | |
fputc(0, fp); | |
fputc(9, fp); | |
fputc(0, fp); | |
fputc(0, fp); | |
fputc(0, fp); | |
fputc(0, fp); | |
fputc(255, fp); | |
fputc(31, fp); | |
fputc(255, fp); | |
fputc(241, fp); | |
fclose(fp); | |
sprintf(&szNewFileName[0], "%s.flv", szSourceFile); | |
rename(szSourceFile, &szNewFileName[0]); | |
printf("转换完成.\n输出文件: %s\n\n", szNewFileName); | |
} else { | |
printf("文件格式不正确.\n\n"); | |
return 0; | |
} | |
} /*else { // 常规模式(未完成) | |
}*/ | |
return 1; | |
} | |
int main(int argc, char **argv) | |
{ | |
char szFileName[256] = {0}; | |
printf("迅雷XV格式转换器 XVE7s 秒速转换逆向版本\n Code by Naylon\n http://hi.baidu.com/naylonslain"); | |
if (argc > 1) { | |
convert_file(argv[1], 1); | |
} else { | |
// Test Input: "D:\Downloads\000.xv" | |
while (1) { | |
scanf("%s", &szFileName[0]); | |
convert_file(szFileName, 1); | |
memset(&szFileName[0], 0, 256); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment