X-Git-Url: https://git.distorted.org.uk/~mdw/autoys/blobdiff_plain/00eb0a5bd4137d3f9038c1910890bf777afc8d6b..00beb9e518942f3a4415498281a8d66639735274:/gremlin/gremlin.in diff --git a/gremlin/gremlin.in b/gremlin/gremlin.in old mode 100755 new mode 100644 index c029bc3..cca2789 --- a/gremlin/gremlin.in +++ b/gremlin/gremlin.in @@ -7,18 +7,20 @@ ###----- Licensing notice --------------------------------------------------- ### -### This program is free software; you can redistribute it and/or modify +### This file is part of the `autoys' audio tools collection. +### +### `autoys' is free software; you can redistribute it and/or modify ### it under the terms of the GNU General Public License as published by ### the Free Software Foundation; either version 2 of the License, or ### (at your option) any later version. ### -### This program is distributed in the hope that it will be useful, +### `autoys' is distributed in the hope that it will be useful, ### but WITHOUT ANY WARRANTY; without even the implied warranty of ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ### GNU General Public License for more details. ### ### You should have received a copy of the GNU General Public License -### along with this program; if not, write to the Free Software Foundation, +### along with `autoys'; if not, write to the Free Software Foundation, ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ###-------------------------------------------------------------------------- @@ -39,11 +41,11 @@ import shutil as SH import optparse as OP import threading as TH import shlex as L -from math import sqrt +from math import sqrt, ceil from contextlib import contextmanager ## eyeD3 tag fettling. -import eyeD3 as E3 +import eyed3 as E3 ## Gstreamer. It picks up command-line arguments -- most notably `--help' -- ## and processes them itself. Of course, its help is completely wrong. This @@ -245,7 +247,7 @@ class ProgressEyecandy (object): ## Work out -- well, guess -- the time remaining. if cur: t = T.time() - eta = me._fmt_time((t - me._start)*(max - cur)/cur) + eta = me._fmt_time(ceil((t - me._start)*(max - cur)/cur)) else: eta = '???' @@ -1100,13 +1102,15 @@ class OggVorbisFormat (AudioFormat): EXT = 'ogg' def encoder_chain(me): - for q, br in me.QMAP: - if br >= me.bitrate: - break - else: - raise ValueError, 'no suitable quality setting found' - return [make_element('vorbisenc', - quality = q/10.0), + encprops = {} + if me.bitrate is not None: + for q, br in me.QMAP: + if br >= me.bitrate: + break + else: + raise ValueError, 'no suitable quality setting found' + encprops['quality'] = q/10.0 + return [make_element('vorbisenc', **encprops), make_element('oggmux')] defformat('ogg-vorbis', OggVorbisFormat) @@ -1119,9 +1123,9 @@ class MP3Format (AudioFormat): EXT = 'mp3' def encoder_chain(me): - return [make_element('lame', - vbr_mean_bitrate = me.bitrate, - vbr = 4), + encprops = {} + if me.bitrate is not None: encprops['vbr_mean_bitrate'] = me.bitrate + return [make_element('lame', vbr = 4, **encprops), make_element('xingmux'), make_element('id3v2mux')] @@ -1132,13 +1136,16 @@ class MP3Format (AudioFormat): GStreamer produces ID3v2 tags, but not ID3v1. This seems unnecessarily unkind to stupid players. """ - tag = E3.Tag() - tag.link(path) - tag.setTextEncoding(E3.UTF_8_ENCODING) - try: - tag.update(E3.ID3_V1_1) - except (UnicodeEncodeError, E3.tag.GenreException): - pass + f = E3.load(path) + if f is None: return + t = f.tag + if t is None: return + for v in [E3.id3.ID3_V2_3, E3.id3.ID3_V1]: + try: f.tag.save(version = v) + except (UnicodeEncodeError, + E3.id3.GenreException, + E3.id3.TagException): + pass defformat('mp3', MP3Format) @@ -1236,7 +1243,7 @@ class JPEGFormat (ImageFormat): optimize If present, take a second pass to select optimal encoder settings. - progression + progressive If present, make a progressive file. quality Integer from 1--100 (worst to best); default is 75.