Exemplo n.º 1
0
def test_recoding1():
    a = Theora(test_files[1])
    b = TheoraEncoder(VIDEO_DIR + "/a.ogv", a.width, a.height)
    a.seek(time=0.75)
    while a.read_frame() and a.time < 0.90:
        A = a.get_frame_array()
        b.write_frame_array(A)
Exemplo n.º 2
0
def test_mpl():
    t = Theora(test_files[1])
    t.read_frame()
    A = t.get_frame_array()
    import pylab
    pylab.imshow(t.YCbCr2RGB(A))
    pylab.savefig(VIDEO_DIR + "/b.png")
Exemplo n.º 3
0
def test_recoding2():
    a = Theora(test_files[1])
    b = TheoraEncoder(VIDEO_DIR + "/b.ogv", a.width, a.height)
    a.seek(time=0.75)
    while a.read_frame() and a.time < 0.90:
        data = a.get_frame_data()
        b.write_frame_data(data)
Exemplo n.º 4
0
def convert(infile, outfile, start, end):
    print "converting %s to %s, between the times %d:%d" % \
            (infile, outfile, start, end)
    a = Theora(infile)
    b = TheoraEncoder(outfile, a.width, a.height, quality=63)
    a.seek(time=start)
    while a.read_frame() and a.time < end:
        print "frame: %d, time=%f" % (a.frame, a.time)
        A = a.get_frame_array()
        b.write_frame_array(A)
Exemplo n.º 5
0
def test_get_frame_data():
    t = Theora(test_files[1])
    t.read_frame()
    data = t.get_frame_data()
    assert isinstance(data, (list, tuple))
    assert len(data) == 3
    Y, Cb, Cr = data
    assert Y.shape == (240, 320)
    assert Cb.shape == (120, 160)
    assert Cr.shape == (120, 160)
def convertFiles(old_dir, new_dir, video_dir = "", fps = 25):
    """Converts the the subtitle files in old_dir and subdirectories
    from using fps to using the actual time
    @param old_dir The directory where the to be converted subtititle files are
    @param new_dir Where the changed files should go
    @param video_dir Directory where the video files, for which the 
    subtitles in old_dir where written, are. This is optional but recommended.
    @param fps This is the default fps used to calculate the time. 
    Will be overwritten by the actual fps of the video if video_dir is set    
    """
    import os
    use_video_fps = os.path.exists(video_dir)
    if use_video_fps:
        from theora import Theora
    if use_video_fps:
        print "Using fps values from the actual video files"
    else:
        print "Using the default fps: " + str(fps)
    for dirpath, dirnames, filenames in os.walk (old_dir):
        os.mkdir (os.path.join (new_dir, dirpath[1+len (old_dir):]))
        for filename in filenames:
            old_file = (os.path.join(dirpath, filename))
            new_file = (os.path.join(new_dir, dirpath[1+len (old_dir):], filename))
            if use_video_fps:
                video_file = os.path.join(video_dir, dirpath[1+len (old_dir):], os.path.splitext(filename)[0] + ".ogg")
                video = Theora(video_file)
                fps = int(video.fps_ratio[0] / video.fps_ratio[1])
            print old_file + "->" + new_file
            convertFile(old_file, new_file, fps)
Exemplo n.º 7
0
def test_seek3():
    t = Theora(test_files[1])
    t.seek(frame=23)
    assert t.time > 0.75
    assert t.frame == 23
Exemplo n.º 8
0
def test_seek2():
    t = Theora(test_files[1])
    t.seek(time=0.75)
    assert t.time > 0.75
    assert t.frame == 23
Exemplo n.º 9
0
def test_PIL_image():
    t = Theora(test_files[1])
    t.read_frame()
    img = t.get_frame_image()
    img.save(VIDEO_DIR + "/a.png")
Exemplo n.º 10
0
def test_read_frame():
    t = Theora(test_files[1])
    t.read_frame()