On Sun, 2009-08-16 at 15:17 -0500, Carl Karsten wrote:
> On Sat, Aug 15, 2009 at 1:20 AM, Francesco Romani<from...@gmail.com> wrote:
> > Hi there,
> >
> > Taking advantage of my (summer holydays, I started to (re)write a
> > candidate official GUI for transcode, as we discussed some time ago.
> >
> > The obligatory screenshot is here:
> >
> > http://tcforge.berlios.de/archives/2009/08/14/early_preview/index.html
> 
> There is a link to an image that is 404

Interesting, looks like the image wasn't get copied into the post
archives. It is accessible from the homepage,
(http://tcforge.berlios.de , last post) though.

There isn't much to see, anyway :)

> > Some quick facts/intentions
> > - coded in python
> I could really use python bindings to tcprobe or something that will
> let me calc start and duration correctly:
> 
>          files=os.listdir(dir)
>          for dv in files:
>              print dv
>              st = os.stat("%s/%s"%(dir,dv))
>              start = datetime.datetime.fromtimestamp( st.st_mtime )
>              duration = int(st.st_size/(120000*29.90)) ## seconds
>              end = start + datetime.timedelta(seconds=duration)

My idea (and implementation) is to use the tcprobe's raw output using
the subprocess module. Take a look to the attached snippet as sample
-but beware, it's still very rough-.
It will work with any transcode >= 1.1.0.

Of course tcprobe can fail but... That's a different bug :)

> I would also like to pull out jpegs from every 30 seconds - The goal
> is to be able to create a web page for a file that lets someone figure
> out if there it is the recording of a presentation or the minutes
> before while people get seated.  now that FF3.5 supports .ogg, a low
> quality ogg will help too if I can figure out how.

The upcoming 1.2.0 will support ogg, but the involved modules needs some
serious love (and testing).

After gtranscode2 will start to do something useful, I'll get back
to C :)

Bests,

-- 
Francesco Romani // Ikitt
http://fromani.exit1.org  ::: transcode homepage
http://tcforge.berlios.de ::: transcode experimental forge
import subprocess

def _cmd_output(cmd_args):
    p = subprocess.Popen(cmd_args, stdout=subprocess.PIPE)
    output = p.communicate()[0]
    retval = p.wait()
    return retval, output.strip()
    
class TranscodeError(Exception):
    def __init__(self, msg=""):
        super(TranscodeError, self).__init__()
        self._reason = msg
    def __str__(self):
        return str(self._reason)

class ProbeError(TranscodeError):
    def __init__(self, filename, reason="unsupported format"):
        msg = \
"""
Error while probing the input source `%s':\n
%s
""" %(filename, reason)
        super(ProbeError, self).__init__(msg)
    


# FIXME: hard to test
class TCSourceProbe(object):
    _remap = {
        "ID_FILENAME"      : "stream path",
        "ID_FILETYPE"      : "stream media",
        "ID_VIDEO_WIDTH"   : "video width",
        "ID_VIDEO_HEIGHT"  : "video height",
        "ID_VIDEO_FPS"     : "video fps",
        "ID_VIDEO_FRC"     : "video frc",
        "ID_VIDEO_ASR"     : "video asr",
        "ID_VIDEO_FORMAT"  : "video format",
        "ID_VIDEO_BITRATE" : "video bitrate (kbps)",
        "ID_AUDIO_CODEC"   : "audio format",
        "ID_AUDIO_BITRATE" : "audio bitrate (kbps)",
        "ID_AUDIO_RATE"    : "audio sample rate",
        "ID_AUDIO_NCH"     : "audio channels",
        "ID_AUDIO_BITS"    : "audio bits per sample",
        "ID_LENGTH"        : "stream length (frames)"
            }
    def _parse(self, probe_data):
        res = {}
        for line in probe_data.split('\n'):
            k, v = line.strip().split('=')
            try:
                k = TCSourceProbe._remap[k.strip()]
            except KeyError:
                continue
            res[k] = v.strip()
        return res
    def _get_info(self):
        ret, out = _cmd_output(["tcprobe", "-i", self.path, "-R"])
        if ret != 0:
            raise tcerrors.ProbeError(self.path)
        return self._parse(out)
    def __init__(self, path):
        self.path = path # FIXME!
        self.info = self._get_info()


Reply via email to