示例#1
0
    def create_slideshow(self):
        video_list = self.meeting.source_dir / 'video_list.txt'
        f = video_list.open('w')
        ffmpeg.webm_to_mp4(self.meeting.deskshare_src_file,
                           self.meeting.deskshare_tmp_file)
        print("-=create_slideshow=-", file=sys.stderr)
        for i, slide in enumerate(self.meeting.slides):

            tmp_name = '%d.mp4' % i
            tmp_ts_name = '%d.ts' % i
            image = slide['full_path']

            duration = slide['duration']

            out_file = self.meeting.temp_dir / tmp_name
            out_ts_file = self.meeting.temp_dir / tmp_ts_name

            if "deskshare.png" == image.name:
                print(0, i, slide['in'], duration, file=sys.stderr)
                ffmpeg.trim_video_by_seconds(self.meeting.deskshare_tmp_file,
                                             slide['in'], duration, out_file)
                ffmpeg.mp4_to_ts(out_file, out_ts_file)
            else:
                print(1, i, slide['in'], duration, file=sys.stderr)
                ffmpeg.create_video_from_image(image, duration, out_ts_file)

            f.write('file ' + str(out_ts_file) + '\n')
        f.close()

        ffmpeg.concat_videos(video_list, self.meeting.slideshow_file)
        video_list.unlink()
示例#2
0
def main():
    sys.stderr = open(LOGFILE, 'a')
    print >> sys.stderr, "\n<-------------------" + time.strftime(
        "%c") + "----------------------->\n"

    bbb_version = bbbversion()
    print >> sys.stderr, "bbb_version: " + bbb_version

    os.chdir(source_dir)
    cleanup()
    # dictionary, length, dims = prepare(bbb_version)
    # audio = audio_path + 'audio.ogg'
    # audio_trimmed = temp_dir + 'audio_trimmed.m4a'
    # result = target_dir + 'meeting.mp4'
    # slideshow = temp_dir + 'slideshow.mp4'

    try:
        # create_slideshow(dictionary, length, slideshow, bbb_version)
        # ffmpeg.trim_audio_start(dictionary, length, audio, audio_trimmed)
        # ffmpeg.mux_slideshow_audio(slideshow, audio_trimmed, result)
        # serve_webcams()
        # zipdir('./download/')
        # copy_mp4(result, source_dir + meetingId + '.mp4')
        ffmpeg.webm_to_mp4(source_dir + "video/webcams.webm",
                           source_dir + meetingId + '.mp4')
    finally:
        print >> sys.stderr, "Cleaning up temp files..."
        cleanup()
        print >> sys.stderr, "Done"
示例#3
0
def create_slideshow(dictionary, length, result, bbb_version):
    try:
        video_list = 'video_list.txt'
        f = open(video_list, 'w')

        times = dictionary.keys()
        times.sort()

        ffmpeg.webm_to_mp4(SOURCE_DESKSHARE, TMP_DESKSHARE_FILE)

        print >> sys.stderr, "-=create_slideshow=-"
        for i, t in enumerate(times):
            print >> sys.stderr, (i, t)

            # if i < 1 and '2.0.0' > bbbversion:
            #   continue

            tmp_name = '%d.mp4' % i
            tmp_ts_name = '%d.ts' % i
            image = dictionary[t]
            print >> sys.stderr, times
            print >> sys.stderr, length

            if i == len(times) - 1:
                duration = length - t
            else:
                duration = times[i + 1] - t

            out_file = temp_dir + tmp_name
            out_ts_file = temp_dir + tmp_ts_name

            if "deskshare.png" in image:
                print >> sys.stderr, (0, i, t, duration)
                ffmpeg.trim_video_by_seconds(TMP_DESKSHARE_FILE, t, duration,
                                             out_file)
                ffmpeg.mp4_to_ts(out_file, out_ts_file)
            else:
                print >> sys.stderr, (1, i, t, duration)
                ffmpeg.create_video_from_image(image, duration, out_ts_file)

            f.write('file ' + out_ts_file + '\n')
        f.close()

        ffmpeg.concat_videos(video_list, result)
        os.remove(video_list)
    except:
        print >> sys.stderr, "Exception create_slideshow"
        print >> sys.stderr, dictionary.keys()
        print >> sys.stderr, image
示例#4
0
def create_slideshow(dictionary, length, result):
    video_list = 'video_list.txt'
    video_list_tmp = []
    video_list_fn = []
    f = open(video_list, 'w')

    times = list(dictionary.keys())
    times.sort()

    ffmpeg.webm_to_mp4(SOURCE_DESKSHARE, TMP_DESKSHARE_FILE)

    print("-=create_slideshow=-")
    for i, t in enumerate(times):
        tmp_name = '%d.mp4' % i
        tmp_ts_name = '%d.ts' % i
        image = dictionary[t]

        if i == len(times) - 1:
            duration = length - t
        else:
            duration = times[i + 1] - t

        out_file = temp_dir + tmp_name
        out_ts_file = temp_dir + tmp_ts_name

        if "deskshare.png" in image:
            print(sys.stderr, (0, i, t, duration))
            ffmpeg.trim_video_by_seconds(TMP_DESKSHARE_FILE, t, duration,
                                         out_file)
            ffmpeg.mp4_to_ts(out_file, out_ts_file)
        else:
            print(sys.stderr, (1, i, t, duration))
            ffmpeg.create_video_from_image(image, duration, out_ts_file)
        video_list_fn.append(out_ts_file)
        f.write('file ' + out_ts_file + '\n')
        video_list_tmp.append(out_ts_file)
    f.close()
    height = 1080
    # Scale video files
    with open(video_list, 'w') as f:
        for entry in video_list_fn:
            out_file = temp_dir + entry.split('/')[-1].split(
                '.')[0] + '_new.ts'
            ffmpeg.scale_fixed(entry, out_file)
            f.write('file ' + out_file + '\n')
    ffmpeg.concat_videos(video_list, result)
    return height
示例#5
0
def main():
    sys.stderr = open(LOGFILE, 'a')
    print >> sys.stderr, "\n<-------------------" + time.strftime(
        "%c") + "----------------------->\n"

    bbb_version = bbbversion()
    print >> sys.stderr, "bbb_version: " + bbb_version

    os.chdir(source_dir)
    print >> sys.stderr, "Verifying record"
    try:
        if not video_exists(source_dir + meetingId + '_presentation.mp4'):
            dictionary, length, dims = prepare(bbb_version)
            audio = audio_path + 'audio.ogg'
            audio_trimmed = temp_dir + 'audio_trimmed.m4a'
            result = target_dir + 'meeting.mp4'
            slideshow = temp_dir + 'slideshow.mp4'
            try:
                print >> sys.stderr, "Creating presentation's .Mp4 video..."
                print >> sys.stderr, "Slideshow"
                create_slideshow(dictionary, length, slideshow, bbb_version)
                print >> sys.stderr, "audio"
                ffmpeg.trim_audio_start(dictionary, length, audio,
                                        audio_trimmed)
                print >> sys.stderr, "Slideshow + audio"
                ffmpeg.mux_slideshow_audio(slideshow, audio_trimmed, result)

                serve_webcams()
                # zipdir('./download/')
                copy_mp4(result, source_dir + meetingId + '_presentation.mp4')
                print >> sys.stderr, "Presentation's Mp4 Creation Done"
            except:
                print >> sys.stderr, "Presentation's Mp4 Creation Failed"
        else:
            print >> sys.stderr, "Presentation record already exists: " + source_dir + meetingId + '_presentation.mp4'

        if not video_exists(source_dir + meetingId + '_cams.mp4'):
            try:
                print >> sys.stderr, "Converting Webcam to .mp4..."
                ffmpeg.webm_to_mp4(source_dir + "video/webcams.webm",
                                   source_dir + meetingId + '_cams.mp4')
                print >> sys.stderr, "Webcams' Mp4 Creation Done"
            except:
                print >> sys.stderr, "Webcams' Mp4 Creation Failed"
        else:
            print >> sys.stderr, "Webcam record already exists: " + source_dir + meetingId + "_cams.mp4"

        if not video_exists(source_dir + meetingId + '_overlayed.mp4'):
            if (video_exists(source_dir + meetingId + '_presentation.mp4')
                    and video_exists(source_dir + meetingId + '_cams.mp4')):
                try:
                    print >> sys.stderr, "Overlayig Presentation and webcams..."
                    ffmpeg.overlay_video(
                        source_dir + meetingId + '_presentation.mp4',
                        source_dir + meetingId + '_cams.mp4',
                        source_dir + meetingId + '_overlayed.mp4')
                    print >> sys.stderr, "Overlaying is done"
                except:
                    print >> sys.stderr, "Overlaying is Failed"
            else:
                print >> sys.stderr, "Overlaying is not possible"
        else:
            print >> sys.stderr, "Webcam record already exists: " + meetingId + '_overlayed.mp4'
    finally:
        print >> sys.stderr, "Cleaning up temp files..."
        cleanup()
        print >> sys.stderr, "Process finished"