From 9b3ed756c136e952474a937b5e774b6e31f36c13 Mon Sep 17 00:00:00 2001 From: n-a-c-h <> Date: Thu, 2 Mar 2006 02:24:29 +0000 Subject: [PATCH] Added compressed audio support. Uses LAME by default. --- zsnes/src/md.psr | 9 ++++++--- zsnes/src/zmovie.c | 37 +++++++++++++++++++++++++++++++------ 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/zsnes/src/md.psr b/zsnes/src/md.psr index 5065d749..78d1811c 100644 --- a/zsnes/src/md.psr +++ b/zsnes/src/md.psr @@ -1,5 +1,6 @@ md_raw_file times 50 db "rawvideo.bin" @ Only for Raw Video md_pcm_audio times 50 db "audio.wav" @ AVI dumping always dumps audio seperatly +md_compressed_audio times 50 db "audio.mp3" @ For when selecting compressed md_ntsc times 20 db "59649/995" md_pal times 5 db "50/1" @@ -14,12 +15,14 @@ md_x264 times 100 db "-ovc x264 -x264encopts qp_constant=0:frameref=15" md_ffv1 times 100 db "-ovc lavc -lavcopts vcodec=ffv1:vstrict=-2:aspect=4/3" md_xvid times 100 db "-ovc xvid -xvidencopts fixed_quant=2" -@Valid variables to use in the next two lines are: -@$md_file, $md_prog, $md_raw, $md_other, $md_no_sound, $md_sound, $md_pcm_audio +@Valid variables to use in the next four lines are: +@$md_file, $md_prog, $md_raw, $md_other, $md_no_sound, $md_sound, $md_pcm_audio, $md_compressed_audio @and $md_video_rate, $md_vcodec @These variables are defined above. @$md_video_rate is $md_ntsc or $md_pal depending on the game as needed @$md_vcodec is $md_x264, $md_ffv1, or $md_xvid depending on the codec selected md_command times 150 db "$md_prog $md_other $md_no_sound $md_raw:fps=$md_video_rate $md_vcodec -o $md_file -" -md_merge times 150 db "$md_prog $md_other $md_sound -audiofile $md_pcm_audio -force-avi-aspect 4:3 -ovc copy -o merged.avi $md_file" \ No newline at end of file +md_merge times 150 db "$md_prog $md_other $md_sound -audiofile $md_pcm_audio -force-avi-aspect 4:3 -ovc copy -o merged.avi $md_file" +md_audio_compress times 150 db "lame -m j --preset 64 -q 0 - $md_compressed_audio" +md_merge_compressed times 150 db "$md_prog $md_other -oac copy -audiofile $md_compressed_audio -force-avi-aspect 4:3 -ovc copy -o merged.avi $md_file" diff --git a/zsnes/src/zmovie.c b/zsnes/src/zmovie.c index cd03dff3..aab10a34 100644 --- a/zsnes/src/zmovie.c +++ b/zsnes/src/zmovie.c @@ -1881,6 +1881,7 @@ unsigned char AudioLogging; extern unsigned char MovieVideoMode; extern unsigned char MovieAudio; extern unsigned char MovieVideoAudio; +extern unsigned char MovieAudioCompress; extern char ZStartPath[PATH_MAX]; @@ -1895,8 +1896,7 @@ static char *pick_var(char **str) PICK_HELP(md_sound); PICK_HELP(md_no_sound); PICK_HELP(md_pcm_audio); - - + PICK_HELP(md_compressed_audio); if (!strncmp(*str, "$md_video_rate", strlen("$md_video_rate"))) { @@ -1995,7 +1995,14 @@ static void raw_video_close() //The 4 bytes needed to hold the data size fwrite4(file_size - (raw_vid.aud_dsize_pos+4), raw_vid.ap); } - fclose(raw_vid.ap); + if (MovieAudioCompress) + { + pclose(raw_vid.ap); + } + else + { + fclose(raw_vid.ap); + } raw_vid.ap = 0; AudioLogging = 0; } @@ -2003,10 +2010,19 @@ static void raw_video_close() if (audio_and_video && MovieVideoAudio) { chdir(ZStartPath); - if (mencoderExists) system(encode_command(md_merge)); + if (MovieAudioCompress) + { + if (mencoderExists) { system(encode_command(md_merge_compressed)); } + remove(md_compressed_audio); + } + else + { + if (mencoderExists) { system(encode_command(md_merge)); } + remove(md_pcm_audio); + } remove(md_file); - remove(md_pcm_audio); } + signal(SIGPIPE, SIG_IGN); } static bool raw_video_open() @@ -2041,7 +2057,16 @@ static bool raw_video_open() if ((!MovieVideoMode || raw_vid.vp) && MovieAudio) { - if ((raw_vid.ap = fopen(md_pcm_audio, "wb"))) + if (MovieAudioCompress) + { + signal(SIGPIPE, broken_pipe); + raw_vid.ap = popen(encode_command(md_audio_compress), WRITE_BINARY); + } + else + { + raw_vid.ap = fopen(md_pcm_audio, "wb"); + } + if (raw_vid.ap) { fputs("RIFF", raw_vid.ap); //header fwrite4(~0, raw_vid.ap); //file size - unknown till file close