-
-
Save TimothyGu/c1eeb95ca2c706fc5ac3 to your computer and use it in GitHub Desktop.
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
// xv2flv | |
// Found on http://hi.baidu.com/naylonslain/item/9586125a9f5979dbd58bac47 | |
#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("File not found.\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) { | |
// Start demuxing | |
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); | |
// Fix file header | |
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("Conversion done.\nOutputted file: %s\n\n", szNewFileName); | |
} else { | |
printf("File format incorrect.\n\n"); | |
return 0; | |
} | |
} /*else { // Regular mode (not done) | |
}*/ | |
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\n"); | |
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