Ejemplo n.º 1
0
    def handleStream(self, fileName, audioFormat, videoFormat, **desc):
        print("-- dispatcher/handleStream")

        audioName = os.path.join(self.tempFilePath, fileName + '.audio' + audioFormat)
        videoName = os.path.join(self.tempFilePath, fileName + '.video' + videoFormat)
        fileName = os.path.join(self.videoFilePath, fileName + '.mp4')

        self.downloader.saveStream(audioName, videoName, **desc)
        tools.mergeAudio2Video([audioName], [videoName], fileName)
        self.saveTempFile or tools.removeFiles([audioName, videoName])
        print('完成\n')
Ejemplo n.º 2
0
    def _downloadDash(self, audioUrls, videoUrls, fileName, headers={}):
        print("-- dispatcher/downloadDash")

        tempAudioBase = tools.join(self.tempFilePath, fileName + '.audio')
        tempVideoBase = tools.join(self.tempFilePath, fileName + '.video')
        audioNames = tools.generateFileNames(audioUrls, tempAudioBase)
        videoNames = tools.generateFileNames(videoUrls, tempVideoBase)
        targetFileName = tools.join(self.videoFilePath, fileName + '.mp4')

        self.downloader.multiThreadDownloadAll(audioUrls, audioNames, headers, \
            self.fragThreadCnt, self.fragmentCnt)
        self.downloader.multiThreadDownloadAll(videoUrls, videoNames, headers, \
            self.fragThreadCnt, self.fragmentCnt)
        tools.mergeAudio2Video(audioNames, videoNames, targetFileName)

        self.saveTempFile or tools.removeFiles(audioNames + videoNames)
        return targetFileName
    def _downloadDash(self, audioUrls, videoUrls, fileName, headers={}):
        print("-- dispatcher/downloadDash")
        print('匹配到%d段音频和%d段视频,开始下载' % (len(audioUrls), len(videoUrls)))

        tempAudioBase = os.path.join(self.tempFilePath, fileName + '.audio')
        tempVideoBase = os.path.join(self.tempFilePath, fileName + '.video')
        audioNames = tools.generateFileNames(audioUrls, tempAudioBase)
        videoNames = tools.generateFileNames(videoUrls, tempVideoBase)
        fileName = os.path.join(self.videoFilePath, fileName + '.mp4')

        self.downloader.multiThreadDownloadAll(audioUrls, audioNames, headers, \
            self.fragThreadCnt, self.fragmentCnt)
        self.downloader.multiThreadDownloadAll(videoUrls, videoNames, headers, \
            self.fragThreadCnt, self.fragmentCnt)
        tools.mergeAudio2Video(audioNames, videoNames, fileName)
        self.saveTempFile or tools.removeFiles(audioNames + videoNames)
        print('完成\n')