示例#1
0
def style_transfer():
    vfs = VideoFileSegments()

    if vfs.count_with_status('processing') != 1:
        print("Need to process exactly one video")
        sys.exit(1)

    processing = vfs.get_first_with_status('processing')
    video_filename = processing['video_file']

    default_style_image = 'https://upload.wikimedia.org/wikipedia/commons/0/0a/The_Great_Wave_off_Kanagawa.jpg'
    print(f"Leave blank for default style image {default_style_image}")

    style_image = prompt("Style image >>>> ")
    if style_image == '':
        style_image = default_style_image

    pi = ProcessingInformation()
    pi.set_style_transfer_image(style_image)
    pi.save()

    st = StyleTransfer(style_image=style_image)
    vid = VideoFileClip(video_filename)
    vid2 = vid.fl_image(st.transform_frame)

    tmp_file_name = '/tmp/tmp_video_style_transfer.mp4'
    vid2.write_videofile(tmp_file_name)

    os.rename(tmp_file_name, video_filename)
示例#2
0
def watch_video():
    vfs = VideoFileSegments()

    if vfs.count_with_status('processing') != 1:
        print("Need to process exactly one video")
        sys.exit(1)

    processing = vfs.get_first_with_status('processing')

    os.system("xdg-open {}".format(processing['video_file']))
示例#3
0
def upload_video():
    vfs = VideoFileSegments()
    pi = ProcessingInformation()

    if vfs.count_with_status('processing') != 1:
        print("Need to process exactly one video")
        sys.exit(1)

    processing = vfs.get_first_with_status('processing')
    video_filename = processing['video_file']

    print("Uploading video to YouTube")
    print("")

    title = prompt("Title >>> ")

    print("Uploading video", video_filename, "with title", title)

    youtube = YouTube()
    youtube.init()

    description = pi.get_description()

    youtube.upload_file(video_filename, title, description)

    vfs.update_status_from_to('processing', 'youtube')
    vfs.save()
    pi.done()
示例#4
0
def next_video():
    vfs = VideoFileSegments()

    if vfs.count_with_status('processing') > 0:
        print("Already procesising a video")
        sys.exit(1)

    unseen = vfs.get_first_unseen()

    if unseen is None:
        print("No more interesting pieces detected")
        sys.exit(1)

    video_file = VideoFile(unseen)
    video_filename = "output/video{}.mp4".format(unseen['index'])
    video_file.save_as(video_filename)

    vfs.set_status(unseen['index'], 'processing')
    vfs.set_video_filename(unseen['index'], video_filename)
    vfs.save()
示例#5
0
def cut_start():
    vfs = VideoFileSegments()

    if vfs.count_with_status('processing') != 1:
        print("Need to process exactly one video")
        sys.exit(1)

    validator = Validator.from_callable(
        lambda text: text.isdigit(),
        error_message='This input contains non-numeric characters',
        move_cursor_to_end=True)

    time_to_cut = prompt("Seconds to remove from start >>> ", validator=validator)
    time_to_cut = int(time_to_cut)

    processing = vfs.get_first_with_status('processing')
    video_filename = processing['video_file']

    clip = VideoFileClip(video_filename)
    subclip = clip.without_audio().subclip(t_start=time_to_cut)

    subclip.write_videofile('/tmp/video.mp4')
    os.rename('/tmp/video.mp4', video_filename)
示例#6
0
import sys

from lib.data import VideoFileSegments
from lib.data import VideoFile

vfs = VideoFileSegments()

if vfs.count_with_status('processing') > 0:
    print("Already procesising a video")
    sys.exit(1)

unseen = vfs.get_first_unseen()

if unseen is None:
    print("No more interesting pieces detected")
    sys.exit(1)

video_file = VideoFile(unseen)
video_filename = "output/video{}.mp4".format(unseen['index'])
video_file.save_as(video_filename)

vfs.set_status(unseen['index'], 'processing')
vfs.set_video_filename(unseen['index'], video_filename)
vfs.save()
示例#7
0
import os
import sys

from lib.data import VideoFileSegments

vfs = VideoFileSegments()

if vfs.count_with_status('processing') != 1:
    print("Need to process exactly one video")
    sys.exit(1)

processing = vfs.get_first_with_status('processing')

os.system("xdg-open {}".format(processing['video_file']))
示例#8
0
def list_videos():
    vfs = VideoFileSegments()

    with pd.option_context('display.max_rows', None, 'display.max_columns',
                           None):
        print(vfs.data)
示例#9
0
import argparse

from lib.data import VideoFileSegments

parser = argparse.ArgumentParser(
    description='Sets the status of all processing videos')
parser.add_argument('--status', help='new status', default='done')

args = parser.parse_args()

vfs = VideoFileSegments()

vfs.update_status_from_to('processing', args.status)

vfs.save()
示例#10
0
from lib.data import VideoFileSegments

vfs = VideoFileSegments()

print(vfs.data)
示例#11
0
fh.setFormatter(formatter)
log.addHandler(fh)

parser = argparse.ArgumentParser(
    description=
    'Adds to csv file with information about interesting parts in video')
parser.add_argument('--input', help='json file with object information')
parser.add_argument('--output',
                    help='csv file with interesting segments',
                    default='interesting_video_parts.csv')

args = parser.parse_args()

to_merge = [
    'Car', 'Wheel', 'Van', 'Land vehicle', 'Person', 'Motorcycle', 'Tire',
    'Train', 'Bicycle', 'Vehicle registration plate', 'Man', 'Bicycle wheel',
    'Footwear', 'Truck', 'Woman', 'Bicycle helmet', 'Clothing'
]

object_data = ObjectData()
object_data.load(args.input)

filename = os.path.split(args.input)[1]

segments = VideoFileSegments(filename=args.output)

for interval in object_data.intervals_not_containing(to_merge):
    segments.append_entry(filename, interval)

segments.save()
示例#12
0
from lib.data import VideoFileSegments
import argparse
import sys

parser = argparse.ArgumentParser(description='skips current video')
args = parser.parse_args()


vfs = VideoFileSegments()

if vfs.count_with_status('processing') != 1:
    print("Need to process exactly one video")
    sys.exit(1)

processing = vfs.get_first_with_status('processing')

print("Skipping video", processing['video_file'])

vfs.update_status_from_to('processing', 'skipped')
vfs.save()