Le 26/07/2011 19:10, David Baelde a écrit :
> def mono_audio_enc(~samplerate=44100)
> if samplerate==48000 then
> %mp3(samplerate=48000)
> elsif samplerate==44100 then
> %mp3(samplerate=44100)
> elsif samplerate==22050 then
> %mp3(samplerate=22050)
> elsif samplerate==48000 then
> %mp3(samplerate=48000)
> else
> # There must be a default case
> print("Samplerate #{samplerate} is invalid, choosing 44100Hz.")
> %mp3
> end
> end
>
> The important point is that all the branches return an encoding format
> of the same type:
>
> mono_audio_enc : (?samplerate:int)->format(audio=2,video=0,midi=0)
>
> A full implementation would be longer, the full list of allowed values
> being [8000;11025;12000;16000;22050;24000;32000;44100;48000]. It gets
> worse when you combine this with the possibilities for bitrates, ie.
> [8;16;24;32;40;48;56;64;80;96;112;128;144;160;192;224;256;320]. We
> already have 9 x 18 possibilities, and even more parameters may be
> taken into account... It's stupid, but that's the kind of code you can
> automatically generate once and for all, and share with the world
> until there is a simpler builtin solution ;)
>
> Hope this helps,
>
> David
Hi Naomi and David,
I've come to this kind of issue too, with bitrate.
I've adapted the code that David provided above, it works like a charm:
def mp3_bitrate_enc(~bitrate=128)
if bitrate==48 then
%mp3(bitrate=48)
elsif bitrate==64 then
%mp3(bitrate=64)
elsif bitrate==96 then
%mp3(bitrate=96)
elsif .................(...)
(...)
else
# There must be a default case
print("bitrate #{bitrate} is invalid, choosing 128.")
%mp3
end
end
# the interesting part, how to use it ? :) :
out =
if stream_format == "mp3" then
# yay ! this time I can use a variable :)
out(mp3_bitrate_enc(bitrate=int_of_string("#{stream_bitrate}")))
elsif stream_format == "vorbis" then
....
else
...
end
Cheers !
------------------------------------------------------------------------------
Got Input? Slashdot Needs You.
Take our quick survey online. Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users