Exemple #1
0
 def create_filters_for_keyframes(self, keyframes, mlt_profile):
     for i in range(0,
                    len(keyframes) -
                    1):  # Theres one less filter parts than keyframes
         mlt_filter = mlt.Filter(mlt_profile, str(self.info.mlt_service_id))
         mltrefhold.hold_ref(mlt_filter)
         self.mlt_filters.append(mlt_filter)
Exemple #2
0
 def add_track_pan_filter(self, track, value):
     # This method is used for master too, and called with tractor then
     pan_filter = mlt.Filter(self.profile, "panner")
     mltrefhold.hold_ref(pan_filter)
     pan_filter.set("start", value)
     track.attach(pan_filter)
     track.pan_filter = pan_filter 
Exemple #3
0
    def _mix_audio_for_track(self, track):
        # Create and add transition to combine track audios
        #
        # Audio transition objects are not saved and are thrown away when track count is changed so we don't
        # need to hold references to them in Sequence object, mltrefhold stuff is just very 
        # defencsive programming because MLT crashes are most related to deleting stuff, probably not needed at all.
        transition = mlt.Transition(self.profile, "mix")
        mltrefhold.hold_ref(transition) # look  to remove
        transition.set("a_track", int(AUDIO_MIX_DOWN_TRACK))
        transition.set("b_track", track.id)
        transition.set("always_active", 1)
        transition.set("combine", 1)
        self.field.plant_transition(transition, int(AUDIO_MIX_DOWN_TRACK), track.id)

        # Create and add gain filter
        gain_filter = mlt.Filter(self.profile, "volume")
        mltrefhold.hold_ref(gain_filter)
        gain_filter.set("gain", str(track.audio_gain))
        track.attach(gain_filter)
        track.gain_filter = gain_filter

        # Add pan filter if this track is panorated
        if track.audio_pan != NO_PAN:
            self.add_track_pan_filter(track, 0.5) 
            track.audio_pan = 0.5
def init(profile):
    audio_level_filter = mlt.Filter(profile, "audiolevel")

    global MONITORING_AVAILABLE
    if audio_level_filter != None:
        MONITORING_AVAILABLE = True
        editorstate.audio_monitoring_available = True
    else:
        MONITORING_AVAILABLE = False
        editorstate.audio_monitoring_available = False

    global CONTROL_SLOT_H, METER_SLOT_H, METER_LIGHTS, METER_HEIGHT
    if editorstate.screen_size_small_height() == True:
        if editorstate.SCREEN_HEIGHT > 902:
            METER_SLOT_H = 300
            CONTROL_SLOT_H = 240
            METER_LIGHTS = 100
            METER_HEIGHT = METER_LIGHTS * DASH_INK + (METER_LIGHTS -
                                                      1) * DASH_SKIP
        else:
            METER_SLOT_H = 275
            CONTROL_SLOT_H = 240
            METER_LIGHTS = 82
            METER_HEIGHT = METER_LIGHTS * DASH_INK + (METER_LIGHTS -
                                                      1) * DASH_SKIP

    # We want this to be always present when closing app or we'll need to handle it being missing.
    global _update_ticker
    _update_ticker = utils.Ticker(_audio_monitor_update, 0.04)
    _update_ticker.start_ticker()
    _update_ticker.stop_ticker()
Exemple #5
0
    def set_track_mute_state(self, track_index, mute_state):
        track = self.tracks[track_index]
        track.mute_state = mute_state

        # Some older projects might get here without a track gain filter existing
        if not hasattr(track, "gain_filter"):
            # Create and add gain filter
            gain_filter = mlt.Filter(self.profile, "volume")
            mltrefhold.hold_ref(gain_filter)
            gain_filter.set("gain", str(track.audio_gain))
            track.attach(gain_filter)
            track.gain_filter = gain_filter

        if mute_state == 2:  # TRACK_MUTE_AUDIO
            if track.id < self.first_video_index:
                # Audio tracks
                track.set("hide", 1)
                track.gain_filter.set("gain", str(0))
            else:
                # Video tracks
                track.set("hide", 0)
                track.gain_filter.set("gain", str(0))
        elif mute_state == 3:  # TRACK_MUTE_ALL
            track.set("hide", 1)
            track.gain_filter.set("gain", str(0))
        else:  # TRACK_MUTE_NOTHING, TRACK_MUTE_VIDEO
            track.set("hide", int(track.mute_state))
            track.gain_filter.set("gain", str(track.audio_gain))
Exemple #6
0
 def add_watermark(self, watermark_file_path):
     watermark = mlt.Filter(self.profile, "watermark")
     mltrefhold.hold_ref(watermark)
     watermark.set("resource", str(watermark_file_path))
     watermark.set("composite.always_active", 1)
     self.tractor.attach(watermark)
     self.watermark_filter = watermark
     self.watermark_file_path = watermark_file_path
Exemple #7
0
    def init_mlt_objects(self):
        # MLT objects for multitrack sequence
        self.tractor = mlt.Tractor()

        self.tractor.mark_in = -1
        self.tractor.mark_out = -1

        # Only create and add pan filter if actual pan is applied
        # This method gets called on load and we only want to add a filter then if pan is applied,
        # and not on initial creation.
        # audiomonitoring.py calls add_track_pan_filter() when pan turned on for initial creation
        if self.master_audio_pan != NO_PAN:
            self.add_track_pan_filter(self.tractor, self.master_audio_pan)

        # Create and add gain filter
        gain_filter = mlt.Filter(self.profile, "volume")
        mltrefhold.hold_ref(gain_filter)
        gain_filter.set("gain", str(self.master_audio_gain))
        self.tractor.attach(gain_filter)
        self.tractor.gain_filter = gain_filter

        self.field = self.tractor.field()
        self.multitrack = self.tractor.multitrack()

        self.vectorscope = mlt.Filter(self.profile, "frei0r.vectorscope")
        mltrefhold.hold_ref(
            self.vectorscope
        )  # ?? is this just some anti-crash hack attempt that was not removed
        self.vectorscope.set("mix", str(SCOPE_MIX_VALUES[_scope_over_lay_mix]))
        self.vectorscope.set("overlay sides", "0.0")
        self.rgbparade = mlt.Filter(self.profile, "frei0r.rgbparade")
        mltrefhold.hold_ref(
            self.rgbparade
        )  # ?? is this just some anti-crash hack attempt that was not removed
        self.rgbparade.set("mix", str(SCOPE_MIX_VALUES[_scope_over_lay_mix]))
        self.rgbparade.set("overlay sides", "0.0")
        self.outputfilter = None
Exemple #8
0
def init(profile):
    audio_level_filter = mlt.Filter(profile, "audiolevel")

    global MONITORING_AVAILABLE
    if audio_level_filter != None:
        MONITORING_AVAILABLE = True
        editorstate.audio_monitoring_available = True
    else:
        MONITORING_AVAILABLE = False
        editorstate.audio_monitoring_available = False

    # We want this to be always present when closing app or we'll need to handle it being missing.
    global _update_ticker
    _update_ticker = utils.Ticker(_audio_monitor_update, 0.04)
    _update_ticker.start_ticker()
    _update_ticker.stop_ticker()    
Exemple #9
0
    def jack_output_on(self):
        # We're assuming that we are not rendering and consumer is SDL consumer
        self.producer.set_speed(0)
        self.ticker.stop_ticker()

        self.consumer.stop()

        self.create_sdl_consumer()

        self.jack_output_filter = mlt.Filter(self.profile, "jackrack")
        if editorpersistance.prefs.jack_output_type == appconsts.JACK_OUT_AUDIO:
            self.jack_output_filter.set("out_1", "system:playback_1")
            self.jack_output_filter.set("out_2", "system:playback_2")
        self.consumer.attach(self.jack_output_filter)
        self.consumer.set("audio_off", "1")
        self.consumer.set("frequency", str(editorpersistance.prefs.jack_frequency))

        self.consumer.connect(self.producer)
        self.consumer.start()
Exemple #10
0
def init(profile):
    audio_level_filter = mlt.Filter(profile, "audiolevel")

    global MONITORING_AVAILABLE
    if audio_level_filter != None:
        MONITORING_AVAILABLE = True
        editorstate.audio_monitoring_available = True
    else:
        MONITORING_AVAILABLE = False
        editorstate.audio_monitoring_available = False

    global CONTROL_SLOT_H, METER_SLOT_H
    if editorstate.screen_size_small_height() == True:
        METER_SLOT_H = 400
        CONTROL_SLOT_H = 220

    # We want this to be always present when closing app or we'll need to handle it being missing.
    global _update_ticker
    _update_ticker = utils.Ticker(_audio_monitor_update, 0.04)
    _update_ticker.start_ticker()
    _update_ticker.stop_ticker()
Exemple #11
0
    def _mix_audio_for_track(self, track):
        # Create and add transition to combine track audios
        transition = mlt.Transition(self.profile, "mix")
        mltrefhold.hold_ref(transition)
        transition.set("a_track", int(AUDIO_MIX_DOWN_TRACK))
        transition.set("b_track", track.id)
        transition.set("always_active", 1)
        transition.set("combine", 1)
        self.field.plant_transition(transition, int(AUDIO_MIX_DOWN_TRACK), track.id)

        # Create and ad gain filter
        gain_filter = mlt.Filter(self.profile, "volume")
        mltrefhold.hold_ref(gain_filter)
        gain_filter.set("gain", str(track.audio_gain))
        track.attach(gain_filter)
        track.gain_filter = gain_filter

        # Add pan filter if this track is panorated
        if track.audio_pan != NO_PAN:
            self.add_track_pan_filter(track, 0.5) 
            track.audio_pan = 0.5
Exemple #12
0
def create_overlay_screen():
    global profile
    scene = mlt.Producer(profile, "colour:#E53B07")
    f = mlt.Filter(profile, "affine")
    f.set('transition.distort', 1)
    f.set('transitioLD_PRELOAD=n.fill', 1)
    f.set('transition.scale_y', 1)
    if profile.width() == 1920:
        f.set('transition.fix_rotate_x', 0)
        f.set('transition.fix_shear_y', 45)
        f.set(
            'transition.geometry',
            "0=-50%/0%:120%x100%;5=-10%/0:120%x100%;25=-10%/0:120%x100%;30=150%/0%:120%x100%;"
        )
    else:
        f.set('transition.fix_rotate_x', 40)
        f.set('transition.fix_shear_y', 60)
        f.set(
            'transition.geometry',
            "0=-0/-150%:160%x200%;5=0/-70%:160%x200%;25=0/-70%:160%x200%;35=50%/150%:150%x200%;"
        )
    scene.attach(f)
    scene.set('out', 30)
    return scene
Exemple #13
0
def textembedder(cc, cs, cf, ca, credit, deffontsize, scene, lindex,
                 title_screen, question_text, intro_screen, outro_screen):
    if cc:
        scp = cc.split(",")
        pleft, init_top = scp[0], int(scp[1])
    else:
        pleft, init_top = 0, 0
    if cs:
        pxsize = cs
    else:
        pxsize = deffontsize
    font = get_font(cf)
    lines = process_text(credit)
    height = 0
    align = ca
    rightpoint = 0
    centerpoint = 0
    maxwidth = 0
    widths = []
    for line in lines:
        if line.strip() != "" and line.strip() != "&nbsp;":
            tline = '<span font="' + str(
                pxsize) + '" face="' + font + '">' + line + '</span>'
            #print str(pleft)+ "  "+ tline+ "  "+ str(init_top)
            tf = tempfile.NamedTemporaryFile(mode='w+b',
                                             suffix='.png',
                                             prefix='tmp_' +
                                             str(int(time.time())),
                                             delete=False,
                                             dir=outdir)
            ftodel.append(tf.name)
            tf2 = tempfile.NamedTemporaryFile(mode='w+b',
                                              suffix='.txt',
                                              prefix='tmp_' +
                                              str(int(time.time())),
                                              delete=False,
                                              dir=outdir)
            ftodel.append(tf2.name)
            write_png2(tline, tf.name, tf2.name)
            try:
                img = Image.open(tf.name)
                width, height = img.size
            except:
                width, height = 0, 0
            widths.append(width)
    maxwidth = max(widths)
    rightpoint = int(pleft) + int(maxwidth)
    centerpoint = int(pleft) + int(maxwidth / 2)
    for line in lines:
        if line.strip() != "" and line.strip() != "&nbsp;":
            tline = '<span font="' + str(
                pxsize) + '" face="' + font + '">' + line + '</span>'
            #print str(pleft)+ "  "+ tline+ "  "+ str(init_top)
            tf = tempfile.NamedTemporaryFile(mode='w+b',
                                             suffix='.png',
                                             prefix='tmp_' +
                                             str(int(time.time())),
                                             delete=False,
                                             dir=outdir)
            ftodel.append(tf.name)
            tf2 = tempfile.NamedTemporaryFile(mode='w+b',
                                              suffix='.txt',
                                              prefix='tmp_' +
                                              str(int(time.time())),
                                              delete=False,
                                              dir=outdir)
            ftodel.append(tf2.name)
            write_png2(tline, tf.name, tf2.name)
            try:
                img = Image.open(tf.name)
                width, height = img.size
            except:
                width, height = 0, 0
            f = mlt.Filter(profile, "watermark:" + tf.name)
            if title_screen:
                if align == 'left' or lindex == 0:
                    f.set(
                        "composite.geometry",
                        str(pleft) + "/" + str(init_top) + ":0%x0%;10=" +
                        str(pleft) + "/" + str(init_top) + ":100%x100%;")
                elif align == 'right':
                    npleft = rightpoint - width
                    f.set(
                        "composite.geometry",
                        str(npleft) + "/" + str(init_top) + ":0%x0%;10=" +
                        str(npleft) + "/" + str(init_top) + ":100%x100%;")
                elif align == 'center':
                    npleft = centerpoint - int(width / 2)
                    f.set(
                        "composite.geometry",
                        str(npleft) + "/" + str(init_top) + ":0%x0%;10=" +
                        str(npleft) + "/" + str(init_top) + ":100%x100%;")
                f.set('in', ((lindex) * 20))

            elif outro_screen:
                if align == 'left' or lindex == 0:
                    f.set('composite.start',
                          str(pleft) + '/' + str(init_top) + ':100%x100%')
                elif align == 'right':
                    npleft = rightpoint - width
                    f.set('composite.start',
                          str(npleft) + '/' + str(init_top) + ':100%x100%')
                elif align == 'center':
                    npleft = centerpoint - int(width / 2)
                    f.set('composite.start',
                          str(npleft) + '/' + str(init_top) + ':100%x100%')
                f.set('in', 0)
            elif question_text:
                if align == 'left' or (rightpoint == 0 and centerpoint == 0):
                    f.set('composite.start',
                          str(pleft) + '/' + str(init_top) + ':100%x100%')
                elif align == 'right':
                    npleft = rightpoint - width
                    f.set('composite.start',
                          str(npleft) + '/' + str(init_top) + ':100%x100%')
                elif align == 'center':
                    npleft = centerpoint - int(width / 2)
                    f.set('composite.start',
                          str(npleft) + '/' + str(init_top) + ':100%x100%')
                f.set('in', 40)
            elif intro_screen:
                if init_top == 0:
                    if profile.width() < 1080:
                        init_top = int((profile.height() * 30) / 100)

                    else:
                        init_top = int((profile.height() * 20) / 100)
                    pleft = int((profile.width() - width) / 2)
                f.set('composite.start',
                      str(pleft) + '/' + str(init_top) + ':100%x100%')
                f.set('in', 10)
                f.set('out', 28)
            else:
                if rightpoint == 0 and centerpoint == 0:
                    f.set(
                        "composite.geometry",
                        "-1500/" + str(init_top) + ":0%x0%;20=" + str(pleft) +
                        "/" + str(init_top) + ":100%x100%;")
                    f.set('in', ((lindex + 2) * 20))
                else:
                    if align == 'left':
                        f.set(
                            "composite.geometry",
                            "-1500/" + str(init_top) + ":0%x0%;20=" +
                            str(pleft) + "/" + str(init_top) + ":100%x100%;")
                    elif align == 'right':
                        npleft = rightpoint - width
                        f.set(
                            "composite.geometry",
                            "-1500/" + str(init_top) + ":0%x0%;20=" +
                            str(npleft) + "/" + str(init_top) + ":100%x100%;")
                    elif align == 'center':
                        npleft = centerpoint - int(width / 2)
                        f.set(
                            "composite.geometry",
                            "-1500/" + str(init_top) + ":0%x0%;20=" +
                            str(npleft) + "/" + str(init_top) + ":100%x100%;")
                    f.set('in', (3 * 20) + 5 * lindex)
            init_top += height + 5
            scene.attach(f)
            lindex += 1
        else:

            try:
                init_top += height + 5
            except:
                try:
                    init_top += 50 + 5
                except:
                    pass
    return lindex
 def create_mlt_filter(self, mlt_profile):
     self.mlt_filter = mlt.Filter(mlt_profile,
                                  str(self.info.mlt_service_id))
     mltrefhold.hold_ref(self.mlt_filter)
     self.update_mlt_filter_properties_all()
def _add_audio_level_filter(producer, profile):
    audio_level_filter = mlt.Filter(profile, "audiolevel")
    mltrefhold.hold_ref(audio_level_filter)
    producer.attach(audio_level_filter)
    return audio_level_filter
 def _mlt_watermark(self, producer):
     filt = mlt.Filter(self.profile,
                       'watermark:/home/phed/Playout/stills/screenbug.png')
     filt.connect(producer)
     return filt
Exemple #17
0
outroshow = int(config["27"][4]["display_outro__27"])
outrocol = config["27"][9]["background_color_outro__27"]
outrologo = config["27"][14]["logo_outro__27"]
outrovideo = config["27"][19]["video_outro__27"]

logo = config["24"][4]["main_logo__24"]
dark_filter = config["25"][4]["dark_filter_footages__25"]

music = config["26"][4]["music_file__26"]
music_or_footage = config["26"][9]["music_type__26"]
footage_vol = int(config["26"][19]["audio_level__26"])
music_vol = int(config["26"][14]["music_level__26"])

if music_or_footage == 'music_only':
    scenes.set('hide', 2)
gain_filter = mlt.Filter(profile, "avfilter.volume")
gain_filter.set("av.volume", str(footage_vol / 100))
scenes.attach(gain_filter)

media = config["1"][9]["media__1"]
media = media.strip()
title = config["1"][4]["title__1"]
scene = create_scene(str(media))
if scene.get_out() == 14999:
    scene.set('out', 150)

t_length += scene.get_out()
process_scene(config["1"][0]["coordinate_title__1"],
              config["1"][1]["font_size_title__1"],
              config["1"][2]["font_family_title__1"],
              config["1"][3]["text_alignment_title__1"], title,