mirror of
https://github.com/Ponce/slackbuilds
synced 2024-11-25 10:03:03 +01:00
8793f23fa4
Signed-off-by: B. Watson <yalhcru@gmail.com> Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
129 lines
4.5 KiB
Diff
129 lines
4.5 KiB
Diff
diff -Naur wargus-2.4.1/wartool.cpp wargus-2.4.1.patched/wartool.cpp
|
|
--- wargus-2.4.1/wartool.cpp 2016-11-08 10:26:25.000000000 -0500
|
|
+++ wargus-2.4.1.patched/wartool.cpp 2021-11-19 15:04:56.300380502 -0500
|
|
@@ -1901,25 +1901,27 @@
|
|
int ConvertMusic(void)
|
|
{
|
|
struct stat st;
|
|
- char buf[1024];
|
|
+ char buf[8192] = {'\0'};
|
|
char *cmd;
|
|
+ int cmdlen;
|
|
int ret, i;
|
|
int count = 0;
|
|
|
|
for ( i = 0; MusicNames[i]; ++i ) {
|
|
- sprintf(buf, "%s/%s/%s.wav", Dir, MUSIC_PATH, MusicNames[i]);
|
|
+ snprintf(buf, 4095, "%s/%s/%s.wav", Dir, MUSIC_PATH, MusicNames[i]);
|
|
CheckPath(buf);
|
|
|
|
if (stat(buf, &st))
|
|
continue;
|
|
|
|
- cmd = (char*) calloc(strlen("ffmpeg2theora --optimize \"") + strlen(buf) + strlen("\" -o \"") + strlen(buf) + strlen("\"") + 1, 1);
|
|
+ cmdlen = strlen("ffmpeg -y -i \"") + strlen(buf) + strlen("\" \"") + strlen(buf) + strlen("\" ");
|
|
+ cmd = (char*) calloc(cmdlen + 1, 1);
|
|
if (!cmd) {
|
|
fprintf(stderr, "Memory error\n");
|
|
exit(-1);
|
|
}
|
|
|
|
- sprintf(cmd, "ffmpeg2theora --optimize \"%s\" -o \"%s/%s/%s.ogg\"", buf, Dir, MUSIC_PATH, MusicNames[i]);
|
|
+ snprintf(cmd, cmdlen, "ffmpeg -y -i \"%s\" \"%s/%s/%s.ogg\"", buf, Dir, MUSIC_PATH, MusicNames[i]);
|
|
|
|
ret = system(cmd);
|
|
|
|
@@ -1927,7 +1929,7 @@
|
|
remove(buf);
|
|
|
|
if (ret != 0) {
|
|
- printf("Can't convert wav sound %s to ogv format. Is ffmpeg2theora installed in PATH?\n", MusicNames[i]);
|
|
+ printf("Can't convert wav sound %s to ogg format. Is ffmpeg installed in PATH?\n", MusicNames[i]);
|
|
fflush(stdout);
|
|
}
|
|
|
|
@@ -1941,13 +1943,14 @@
|
|
if (stat(buf, &st))
|
|
continue;
|
|
|
|
- cmd = (char*) calloc(strlen("ffmpeg2theora --optimize \"") + strlen(buf) + strlen("\" -o \"") + strlen(buf) + strlen("\"") + 1, 1);
|
|
+ cmdlen = strlen("ffmpeg -y -i \"") + strlen(buf) + strlen("\" \"") + strlen(buf) + strlen("\" ");
|
|
+ cmd = (char*) calloc(cmdlen + 1, 1);
|
|
if (!cmd) {
|
|
fprintf(stderr, "Memory error\n");
|
|
exit(-1);
|
|
}
|
|
|
|
- sprintf(cmd, "ffmpeg2theora --optimize \"%s\" -o \"%s/%s/%s.ogg\"", buf, Dir, MUSIC_PATH, BNEMusicNames[i]);
|
|
+ snprintf(cmd, cmdlen, "ffmpeg -y -i \"%s\" \"%s/%s/%s.ogg\"", buf, Dir, MUSIC_PATH, BNEMusicNames[i]);
|
|
|
|
ret = system(cmd);
|
|
|
|
@@ -1955,7 +1958,7 @@
|
|
remove(buf);
|
|
|
|
if (ret != 0) {
|
|
- printf("Can't convert wav sound %s to ogv format. Is ffmpeg2theora installed in PATH?\n", BNEMusicNames[i]);
|
|
+ printf("Can't convert wav sound %s to ogg format. Is ffmpeg installed in PATH?\n", BNEMusicNames[i]);
|
|
fflush(stdout);
|
|
}
|
|
|
|
@@ -1979,13 +1982,15 @@
|
|
int ConvertVideo(const char* file, int video, bool justconvert = false)
|
|
{
|
|
unsigned char* vidp;
|
|
- char buf[1024];
|
|
+ char buf[8192] = {'\0'};
|
|
char* cmd;
|
|
FILE* f;
|
|
size_t l;
|
|
int ret;
|
|
+ int cmdlen;
|
|
+ char outputfile[8192] = {'\0'};
|
|
|
|
- sprintf(buf,"%s/%s.smk", Dir, file);
|
|
+ snprintf(buf,4095,"%s/%s.smk", Dir, file);
|
|
CheckPath(buf);
|
|
if (justconvert == false) {
|
|
vidp = ExtractEntry(ArchiveOffsets[video], &l);
|
|
@@ -2005,21 +2010,36 @@
|
|
fclose(f);
|
|
}
|
|
|
|
- cmd = (char*) calloc(strlen("ffmpeg2theora --optimize \"") + strlen(buf) + strlen("\" -o \"") + strlen(buf) + strlen("\"") + 1, 1);
|
|
+ if (CDType & CD_BNE) {
|
|
+ cmdlen = strlen("ffmpeg -y -i \"") + strlen(buf) + strlen("\" -codec:v libtheora -qscale:v 31 -codec:a libvorbis -qscale:a 15 -pix_fmt yuv420p -aspect 4:3 -vf scale=640x0,setsar=1:1 \"") + strlen(buf) + strlen("\" ");
|
|
+ } else {
|
|
+ cmdlen = strlen("ffmpeg -y -i \"") + strlen(buf) + strlen("\" -codec:v libtheora -qscale:v 31 -codec:a libvorbis -qscale:a 15 -pix_fmt yuv420p \"") + strlen(buf) + strlen("\" ");
|
|
+ }
|
|
+ cmd = (char*) calloc(cmdlen + 1, 1);
|
|
if (!cmd) {
|
|
fprintf(stderr, "Memory error\n");
|
|
exit(-1);
|
|
}
|
|
|
|
- sprintf(cmd, "ffmpeg2theora --optimize \"%s/%s.smk\" -o \"%s/%s.ogv\"", Dir, file, Dir, file);
|
|
-
|
|
+ if (CDType & CD_BNE) {
|
|
+ snprintf(cmd, cmdlen, "ffmpeg -y -i \"%s/%s.smk\" -codec:v libtheora -qscale:v 31 -codec:a libvorbis -qscale:a 15 -pix_fmt yuv420p -aspect 4:3 -vf scale=640:0,setsar=1:1 \"%s/%s.ogv\"", Dir, file, Dir, file);
|
|
+ } else {
|
|
+ snprintf(cmd, cmdlen, "ffmpeg -y -i \"%s/%s.smk\" -codec:v libtheora -qscale:v 31 -codec:a libvorbis -qscale:a 15 -pix_fmt yuv420p \"%s/%s.ogv\"", Dir, file, Dir, file);
|
|
+ }
|
|
+ printf("%s\n", cmd);
|
|
ret = system(cmd);
|
|
|
|
free(cmd);
|
|
remove(buf);
|
|
|
|
if (ret != 0) {
|
|
- printf("Can't convert video %s to ogv format. Is ffmpeg2theora installed in PATH?\n", file);
|
|
+ sprintf(outputfile, "%s/%s.ogv", Dir, file);
|
|
+#ifdef WIN32
|
|
+ _unlink(outputfile);
|
|
+#else
|
|
+ unlink(outputfile);
|
|
+#endif
|
|
+ printf("Can't convert video %s to ogv format. Is ffmpeg installed in PATH?\n", file);
|
|
fflush(stdout);
|
|
return ret;
|
|
}
|