예제 #1
0
    def test_timeline(self):
        try:
            temp = ramdisk.path
        except:
            temp = "/tmp/%s" % str(os.getpid())

        sp = videos["sp"]
        rc = videos["rc"]
        sp.freeze_in(3)
        text_time = sp.duration
        sp.freeze_out(3)
        t = Timeline(sp.duration + rc.duration, tmp_path=temp)
        t.asset_video(sp, start=0)
        t.asset_video(rc, start=sp.duration)

        text = Text("Hi Guys! Are You Feeling lucky? Hope you do, enjoy!", size=65, x=100, y=15, fit=True)

        # t.asset_fx(Blur(), start=0, end=3.1)
        # t.asset_fx(Blur(), start=text_time-0.1, end=sp.duration)
        t.asset_fx(text, start=0, end=3)

        text = Text("So, How was it? We hope you liked it, Thanks for Watching", size=65, x=100, y=15, fit=True)
        t.asset_fx(text, start=text_time, end=sp.duration)

        path = t.compile()

        print path
        # ramdisk.disk.umount()
        self.assertTrue(os.path.exists(path))
예제 #2
0
def parse_json(json_as_string):
    """
       Parses a json string and return a timeline instance.
       For more info abuot json format see README.rst
    """
    timeline_dic = json.loads(json_as_string)
    t = Timeline(timeline_dic["timeline"])
    for video in timeline_dic["videos"]:
        v = videos[video.pop("name")]
        for fx in video.pop("fx", []):
            name, time  = fx.pop("type"), fx.pop("time")
            v = v.call(name, time)
        t.asset_video(v, **video)

    for fx in timeline_dic["fx"]:
	fx_type = fx.pop("type")
	nested = fx.pop("fx", [])
        start = fx.pop("start", 0)
        end = fx.pop("end", 0)
        z = fx.pop("z_index", 2)
        final = None
        if fx_type == "text":
            text = Text(**fx)
            final = text
            for asset in nested:
                final = parse_sub_asset(final, asset)

        elif fx_type == "logo":
            logo = logos[fx.pop("name")]
            final = logo
            if "x" in fx.keys():
                final.x = fx.pop("x")
            if "y" in fx.keys():
                final.y = fx.pop("y")
            for asset in nested:
                final = parse_sub_asset(final, asset)
        
        elif fx_type == "blur":
            final = Blur(blur=fx.pop("blur", 4))

        asset = final
        t.asset_fx(asset, start=start, end=end, z_index=z)

    for audio in timeline_dic["audios"]:
        a = audios[audio.pop("name")]
        for fx in audio.pop("fx", []):
            a = a.call(fx.pop("type"), fx)
        t.asset_audio(a, **audio)

    return t