Skip to content

Commit 93e45ed

Browse files
committed
added sox code for SVCD audio resampling, from Joseph A. Caputo <jcaputo1@comcast.net>
1 parent f2909c6 commit 93e45ed

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

trunk/export_SVCD.pm

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ package export_SVCD;
3030
};
3131
bless($self, $class);
3232
# Make sure that we have an mp2 encoder
33-
$Prog{mp2_encoder} = find_program('toolame', 'mp2enc');
34-
push @{$self->{errors}}, 'You need toolame or mp2enc to export an svcd.' unless ($Prog{mp2_encoder});
33+
$Prog{mp2_encoder} = find_program('toolame');
3534
# Make sure that we have an mplexer
3635
$Prog{mplexer} = find_program('tcmplex', 'mplex');
3736
push @{$self->{errors}}, 'You need tcmplex or mplex to export an svcd.' unless ($Prog{mplexer});
@@ -180,12 +179,18 @@ package export_SVCD;
180179
}
181180
# Now we fork off a process to encode the audio
182181
if ($Prog{mp2_encoder} =~ /\btoolame$/) {
183-
$sample = $nuv_info{audio_sample_rate} / 1000;
184-
$command = "nice -n 19 toolame -s $sample -m j -b $self->{a_bitrate} $self->{fifodir}/audout $self->{tmp_a}";
182+
# Resample audio?
183+
if ($nuv_info{audio_sample_rate} != 44100) {
184+
$command = "nice -n 19 sox -t raw -r $nuv_info{audio_sample_rate} -s -w -c 2 $self->{fifodir}/audout -t raw -r 44100 -s -w -c 2 - resample"
185+
." | nice -n 19 toolame -s 44.1 -m j -b $self->{a_bitrate} - $self->{tmp_a}";
186+
}
187+
# Audio is the proper sample rate
188+
else {
189+
$command = "nice -n 19 toolame -s 44.1 -m j -b $self->{a_bitrate} $self->{fifodir}/audout $self->{tmp_a}";
190+
}
185191
}
186192
else {
187-
$command = "nice -n 19 ffmpeg -f s16le -ar $nuv_info{audio_sample_rate} -ac 2 -i $self->{fifodir}/audout -vn -f wav -"
188-
." | nice -n 19 mp2enc -b $self->{a_bitrate} -r $nuv_info{audio_sample_rate} -s -o $self->{tmp_a}";
193+
$command = "nice -n 19 ffmpeg -f s16le -ar $nuv_info{audio_sample_rate} -ac 2 -i $self->{fifodir}/audout -ar 44100 -ab $self->{a_bitrate} -vn -f mp2 $self->{tmp_a}";
189194
}
190195
if ($DEBUG) {
191196
print "\ntoolame command:\n\n$command\n";

trunk/nuvexport

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ Super VideoCD's are an mpeg2 enhancement of the original VideoCD format.
4141
In order to encode an svcd, you need ffmpeg, yuvscaler, and mpeg2enc. Most of
4242
these come with the mjpeg package.
4343
44-
You will also need an mp2 audio encoder. mp2enc comes with mjpeg, but I strongly
45-
suggest that you grab toolame; it's a much better encoder.
44+
You will also need an mp2 audio encoder. I strongly suggest that you grab
45+
toolame, it's an excellent encoder based on the LAME engine. If you don't,
46+
nuvexport will use ffmpeg.
4647
4748
To multiplex the audio and video streams, you can use mjpeg's mplex program, but
4849
I've had bad luck with this, and suggest that you install transcode in order to
@@ -105,9 +106,9 @@ format and use Microsoft's Windows Media Encoder to encode a WMV file.
105106
use export_SVCD;
106107
use export_VCD;
107108
use export_WMV;
108-
use export_Trans_XviD;
109-
use export_Trans_VCD;
110-
use export_Trans_SVCD;
109+
use export_Trans_XviD;
110+
use export_Trans_VCD;
111+
use export_Trans_SVCD;
111112

112113
# Make sure that we have mythtranscode installed
113114
$Prog{mythtranscode} = find_program('mythtranscode');

0 commit comments

Comments
 (0)