summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-06-08 01:49:27 +0200
committerJules Laplace <julescarbon@gmail.com>2018-06-08 01:49:27 +0200
commit1efd2b67127b7a1c1b3840e33304d4f22827a2eb (patch)
treec3b4b933b1a751195e61b8ee69ffc631125df851
parent1efe73d462e027bd9b234154b535a384dd1c55cb (diff)
get script working. also FREAKY changes to live-mogrify.
-rw-r--r--.gitignore3
-rwxr-xr-xget.pl21
-rw-r--r--live-mogrify.py33
-rw-r--r--options/dataset_options.py7
4 files changed, 56 insertions, 8 deletions
diff --git a/.gitignore b/.gitignore
index 78e80f5..515de8d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -45,4 +45,7 @@ test/data/legacy_serialized.pt
recursive/
mov/
*.swp
+*.mp4
+*.part
+*.ytdl
diff --git a/get.pl b/get.pl
index 5648aba..b51b07a 100755
--- a/get.pl
+++ b/get.pl
@@ -5,7 +5,7 @@ $SIG{TERM} = $SIG{INT} = sub { exit 1 };
sub sanitize ($) {
my $s = lc shift;
$s =~ s/\.[^.]+$//g;
- $s =~ s/\W//g;
+ $s =~ s/\W/_/g;
$s =~ s/\s+/_/g;
if (length($s) == 0) {
print "fn is empty";
@@ -63,18 +63,31 @@ elsif ($s =~ /(mov|mp4|webm|avi|mpe?g)$/i) {
else {
print "youtube-dl $s\n";
my $yt = `youtube-dl -o "%(title)s.%(ext)s" $s`;
+ # print $yt;
my @partz = split("\n", $yt);
foreach $part (@partz) {
- if ($part =~ /\[ffmpeg\] Destination\: ([^)]+)$/) {
+ print "$part\n";
+ if ($part =~ /\[download\] Destination\: ([^)]+)$/) {
$video_fn = $1;
+ print ">>> $video_fn\n";
+ }
+ if ($part =~ /\[download\] (.*) has already been downloaded and merged/) {
+ $video_fn = $1;
+ print ">>> $video_fn\n";
+ }
+ if ($part =~ /\[ffmpeg\] Merging formats into "(.*)"/) {
+ $video_fn = $1;
+ print ">>> $video_fn\n";
}
}
}
if ($video_fn) {
+ print "Video filename: $video_fn\n";
my $tag = sanitize($video_fn);
- mkdir('$tag');
- system('ffmpeg', '-i', $video_fn, "-filter:v", "crop=w:h:x:y, scale=256x256", $tag . '/frame_%05d.png');
+ print "creating dataset: $tag\n";
+ mkdir($tag);
+ system('ffmpeg', '-i', $video_fn, "-filter:v", "scale=256x256", $tag . '/frame_%05d.png');
print "created dataset: $tag\n";
}
diff --git a/live-mogrify.py b/live-mogrify.py
index 9330161..c106045 100644
--- a/live-mogrify.py
+++ b/live-mogrify.py
@@ -156,6 +156,23 @@ def list_sequences(module):
})
return results
+def load_frame(opt, index):
+ A_path = os.path.join(opt.render_dir, "frame_{:05d}.png".format(index))
+ if not os.path.exists(A_path):
+ return None
+ A_img = Image.open(A_path).convert('RGB')
+ A = self.transform(A_img)
+ # if self.opt.which_direction == 'BtoA':
+ # input_nc = self.opt.output_nc
+ # else:
+ # input_nc = self.opt.input_nc
+
+ # if input_nc == 1: # RGB to gray
+ # tmp = A[0, ...] * 0.299 + A[1, ...] * 0.587 + A[2, ...] * 0.114
+ # A = tmp.unsqueeze(0)
+
+ return {'A': A, 'A_paths': A_path}
+
def read_sequence(path):
print("> read sequence {}".format(path))
return sorted([f for f in glob.glob(os.path.join('./sequences/', module_name, path, '*.png'))])
@@ -238,8 +255,8 @@ def process_live_input(opt, data_opt, rpc_client, model):
if data_opt.processing:
print("Already processing...")
data_opt.processing = True
- data_loader = CreateRecursiveDataLoader(opt)
- dataset = data_loader.load_data()
+ # data_loader = CreateRecursiveDataLoader(opt)
+ # dataset = data_loader.load_data()
create_render_dir(opt)
sequence = read_sequence(data_opt.sequence_name)
@@ -260,9 +277,17 @@ def process_live_input(opt, data_opt, rpc_client, model):
print("generating...")
sequence_i = 1
- for i, data in enumerate(data_loader):
+ i = 0
+ #for i, data in enumerate(data_loader):
+ while True:
+ i += 1
if i >= opt.how_many:
break
+
+ data = load_frame(opt, i)
+ if data is None:
+ break
+
if data_opt.load_checkpoint is True:
model.save_dir = os.path.join(opt.checkpoints_dir, opt.module_name, data_opt.checkpoint_name)
model.load_network(model.netG, 'G', data_opt.epoch)
@@ -368,7 +393,7 @@ def process_live_input(opt, data_opt, rpc_client, model):
if data_opt.pause:
data_opt.pause = False
break
- gevent.sleep(0)
+ gevent.sleep(data_opt.frame_delay)
data_opt.processing = False
rpc_client.send_status('processing', False)
diff --git a/options/dataset_options.py b/options/dataset_options.py
index 454d576..d4ea36a 100644
--- a/options/dataset_options.py
+++ b/options/dataset_options.py
@@ -106,6 +106,13 @@ class DatasetOptions(BaseOptions):
help='what gets sent over the wire - JPEG or PNG'
)
+ self.parser.add_argument(
+ '--frame_delay',
+ type=float,
+ default=1.0,
+ help='delay per render, in seconds. inverse of frame rate'
+ )
+
## LOAD A NEW SEQUENCE
self.parser.add_argument(