samples_src = samples_src[:samples_bg.shape[0]] sample_start = int(round((t - arg.start) * pr.samp_sr)) n = samples_src.shape[0] inds = np.arange(sample_start, sample_start + n) ok = ~filled[inds] full_samples_fg[inds[ok]] = samples_fg[ok] full_samples_bg[inds[ok]] = samples_bg[ok] full_samples_src[inds[ok]] = samples_src[ok] filled[inds] = True full_samples_fg = np.clip(full_samples_fg, -1., 1.) full_samples_bg = np.clip(full_samples_bg, -1., 1.) full_samples_src = np.clip(full_samples_src, -1., 1.) full_ims = [x for x in full_ims if x is not None] table = [['start =', arg.start], 'fg:', imtable.Video(full_ims, pr.fps, Sound(full_samples_fg, pr.samp_sr)), 'bg:', imtable.Video(full_ims, pr.fps, Sound(full_samples_bg, pr.samp_sr)), 'src:', imtable.Video(full_ims, pr.fps, Sound(full_samples_src, pr.samp_sr))] if arg.out is not None: ut.mkdir(arg.out) vid_s = arg.vid_file.split('/')[-1].split('.mp4')[0] mask_s = '' if arg.mask is None else '_%s' % arg.mask cam_s = '' if not arg.cam else '_cam' suffix_s = '' if arg.suffix == '' else '_%s' % arg.suffix name = '%s%s%s_%s' % (suffix_s, mask_s, cam_s, vid_s) def snd(x): x = Sound(x, pr.samp_sr)
def make_vid(ims, samples): samples = np.clip(samples, -1, 1).astype('float64') snd = sound.Sound(samples, pr.samp_sr) return imtable.Video(ims, pr.fps, snd)