Esempio n. 1
0
 def asLaunchArguments(self, workerContext):
     args = []
     local = workerContext.getLocal()
     args.append(utils.mkCmdArg(str(self._configPath), "config="))
     if self._niceLevel:
         args.append(utils.mkCmdArg(str(self._niceLevel), "nice-level="))
     if self._pathAttr:
         args.extend(self._pathAttr.asLaunchArguments())
     args.append("wait-acknowledge=True")
     args.extend(local.asLaunchArguments())
     return args
Esempio n. 2
0
 def asLaunchArguments(self, workerCtx):
     args = []
     local = workerCtx.getLocal()
     args.append(utils.mkCmdArg(str(self._profiles), "profile="))
     if self._scanPeriod:
         args.append(utils.mkCmdArg(str(self._scanPeriod), "scan-period="))
     if self._setup_callback:
         args.append(utils.mkCmdArg(str(self._setup_callback), "setup-callback="))
     if self._pathAttr:
         args.extend(self._pathAttr.asLaunchArguments())
     args.append(utils.mkCmdArg(str(self._port), "port="))
     args.extend(local.asLaunchArguments())
     return args
Esempio n. 3
0
    def start(self):
        context = self._context
        if (context == None):
            raise TranscoderError("Transcoding Job not properly setup",
                                  data=context)
        context.info("Starting transcoding job")
        context.reporter.time("start")

        sourceCtx = context.getSourceContext()

        # Initialize some report data
        inputPath = sourceCtx.getInputPath()
        if os.path.exists(inputPath):
            # The input file size
            sourceCtx.reporter.report.fileSize = os.stat(inputPath).st_size
            # The input file type (with the file command)
            try:
                arg = utils.mkCmdArg(inputPath)
                fileType = commands.getoutput("file -bL" + arg)
            except Exception, e:
                fileType = "ERROR: %s" % str(e)
            sourceCtx.reporter.report.fileType = fileType

            try:
                machineName = commands.getoutput("hostname")
            except Exception, e:
                machineName = "ERROR: %s" % str(e)
Esempio n. 4
0
    def __crashDiagnostic(self, diagnostic, workerName, corePath):
        if not workerName: return diagnostic
        diagnostic.append("CRASH DEBUG\n-----------")
        workerInfo = self.__lookupWorker(None, workerName)
        workerName, workerHost = workerInfo[1:3]

        diagnostic.append("Debug Core Inplace")
        if workerHost:
            diagnostic.append("    Login: ssh -At " + workerHost)
        arg = utils.mkCmdArg(corePath)
        diagnostic.append("    Debug: gdb python -c" + arg)

        diagnostic.append("Debug Core Locally")
        if workerHost:
            scpCmd = self.__buildSCPCommand(workerHost, corePath)
            diagnostic.append("    Copy:  " + scpCmd)
        arg = utils.mkCmdArg(os.path.basename(corePath))
        diagnostic.append("    Debug: gdb python -c" + arg)

        return diagnostic
Esempio n. 5
0
    def __cbGotReportForTranscoderDiagnostic(self, reportVirtPath, diagnostic,
                                             transPxy, workerPxy, workerName):
        props = self.__lookupProperties(transPxy)
        if not (props or reportVirtPath): return diagnostic
        workerCtx = workerPxy.getWorkerContext()
        workerLocal = workerCtx.getLocal()
        diagnostic.append("MANUAL LAUNCH\n-------------")
        if props:
            args = props.asLaunchArguments(workerCtx)
            origCmd = self.__buildSUCommand("GST_DEBUG=2 flumotion-launch -d 4 "
                                            "file-transcoder", args)
            diagnostic.append("  Original Command:")
            diagnostic.append("    " + origCmd)

        if reportVirtPath:
            reportPath = reportVirtPath.localize(workerLocal)
            args = [utils.mkCmdArg(reportPath, "diagnose=")]
            diagCmd = self.__buildSUCommand("GST_DEBUG=2 flumotion-launch -d 4 "
                                            "file-transcoder", args)
            diagnostic.append("  Diagnose Command:")
            diagnostic.append("    " + diagCmd)
        return diagnostic
Esempio n. 6
0
 def __buildSCPCommand(self, host, file, dest='.'):
     remote = utils.mkCmdArg(file, '')
     source = utils.mkCmdArg(remote, host + ':')
     dest = utils.mkCmdArg(dest)
     return "scp " + source + dest
Esempio n. 7
0
 def __buildSUCommand(self, command, args):
     cmd = "%s %s" % (command, " ".join(args))
     return "su -s /bin/bash - flumotion -c" + utils.mkCmdArg(cmd)
Esempio n. 8
0
 def asLaunchArguments(self):
     args = []
     args.append(utils.mkCmdArg(str(self._name), "local-name="))
     for root, value in self._roots.iteritems():
         args.append(utils.mkCmdArg("%s:%s" % (root, value), "local-root="))
     return args
Esempio n. 9
0
def magic_mimetype(path):
    try:
        arg = mkCmdArg(path)
        mime_type = commands.getoutput("file -biL" + arg)
    except Exception, e:
        mime_type = "ERROR: %s" % str(e)
Esempio n. 10
0
 def changeLoc(s, f):
     l = utils.mkCmdArg(f, "location=")
     return s.replace("location=$FILE_PATH", l)
Esempio n. 11
0
def __buildPipeline(sourceInfo, targetsInfo=[], withAudio=True, withVideo=True):

    def changeLoc(s, f):
        l = utils.mkCmdArg(f, "location=")
        return s.replace("location=$FILE_PATH", l)

    sourceDemuxer = sourceInfo.get("demuxer", None)
    sourceVideo = sourceInfo.get("video", None)
    sourceAudio = sourceInfo.get("audio", None)

    if len(targetsInfo) > 0:
        # Transcoding Pipeline
        hasAudioTarget = reduce(bool.__or__, [bool(t.get("audio", None))
                                              for t in targetsInfo])
        hasVideoTarget = reduce(bool.__or__, [bool(t.get("video", None))
                                              for t in targetsInfo])
        isMultiTarget = len(targetsInfo) > 1
        isTranscodingPipline = True
    else:
        # Playing Pipeline
        hasAudioTarget = True
        hasVideoTarget = True
        isMultiTarget = False
        isTranscodingPipline = False

    audioReference = None
    videoReference = None
    muxerReference = "muxer."
    lastReference = None
    pipe = " ! "
    space = " "
    vplay = "ffmpegcolorspace ! videoscale ! autovideosink"
    aplay = "audioconvert ! autoaudiosink"
    pipeline = ""

    sourceFile = sourceInfo['filename']
    if sourceDemuxer:
        pipeline += changeLoc(sourceDemuxer, sourceFile)
        if sourceAudio and withAudio and sourceVideo and withVideo:
            pipeline += " name=demuxer"
            demuxerReference = "demuxer."
        if sourceVideo and withVideo:
            videoReference = ""
            pipeline += pipe + sourceVideo
            if isTranscodingPipline:
                if hasVideoTarget:
                    if isMultiTarget:
                        pipeline += pipe + "tee name=vtee"
                        videoReference = "vtee."
                    elif sourceAudio:
                        pipeline += " name=vsrc"
                        videoReference = "vsrc."
                lastReference = videoReference
            else:
                pipeline += pipe + vplay
        if sourceAudio and withAudio:
            audioReference = ""
            if sourceVideo:
                pipeline += space + demuxerReference
            pipeline += pipe + sourceAudio
            if isTranscodingPipline:
                if hasAudioTarget:
                    if isMultiTarget:
                        pipeline += pipe + "tee name=atee"
                        audioReference = "atee."
                    elif sourceVideo:
                        pipeline += " name=asrc"
                        audioReference = "asrc."
                lastReference = audioReference
            else:
                pipeline += pipe + aplay
    else:
        audioReference = ""
        videoReference = ""
        sourceLocation = utils.mkCmdArg(sourceFile, "location=")
        pipeline += "filesrc " + sourceLocation + " ! decodebin2"
        if not isTranscodingPipline:
            if withVideo:
                if withAudio:
                    pipeline += " name=decoder"
                pipeline += pipe + vplay
            if withAudio:
                if withVideo:
                    pipeline += space + "decoder."
                pipeline += pipe + aplay
        elif isMultiTarget:
            if hasAudioTarget and withAudio and hasVideoTarget and withVideo:
                pipeline += " name=decoder"
            if hasVideoTarget and withVideo:
                pipeline += pipe + "'video/x-raw-yuv;video/x-raw-rgb'"
                pipeline += pipe + "tee name=vtee"
                videoReference = "vtee."
                lastReference = videoReference
            if hasAudioTarget and withAudio:
                if hasVideoTarget:
                    pipeline += space + "decoder."
                pipeline += pipe + "'audio/x-raw-int;audio/x-raw-float'"
                pipeline += pipe + "tee name=atee"
                audioReference = "atee."
                lastReference = audioReference
        elif hasAudioTarget and withAudio and hasVideoTarget and withVideo:
            pipeline += " name=decoder"
            videoReference = "decoder."

    if not isTranscodingPipline:
        return pipeline

    for targetInfo in targetsInfo:
        muxerName = "muxer"
        tag = targetInfo.get("tag", None)
        if isMultiTarget and tag:
            muxerName = "muxer-%s" % tag
        muxerReference = muxerName + "."

        targMuxer = targetInfo.get("muxer", None)
        targVideo = targetInfo.get("video", None)
        targAudio = targetInfo.get("audio", None)
        targFile = targetInfo['filename']

        if targAudio and withAudio:
            if audioReference and (lastReference != audioReference):
                pipeline += space + audioReference
            pipeline += pipe + changeLoc(targAudio, targFile)
            if targVideo and targMuxer:
                pipeline += pipe + muxerReference
            lastReference = None

        if targVideo and withVideo:
            if videoReference and (lastReference != videoReference):
                pipeline += space + videoReference
            pipeline += pipe + changeLoc(targVideo, targFile)
            lastReference = None

        if targMuxer:
            if targAudio and targVideo:
                targMuxer = targMuxer.replace(" ! ", " name=%s ! " % muxerName, 1)
            pipeline += pipe + changeLoc(targMuxer, targFile)
            lastReference = None

    return pipeline