def main(input_filename, output_filename): if input_filename.startswith("http://"): av = video.loadavfromyoutube(input_filename) else: av = video.loadav(input_filename) collect = audio.AudioQuantumList() for bar in av.audio.analysis.bars: collect.append(bar.children()[0]) out = video.getpieces(av, collect) out.save(output_filename)
def main(input_filename, output_filename): if input_filename.startswith("http://") or input_filename.startswith("https://"): av = video.loadavfromyoutube(input_filename) else: av = video.loadav(input_filename) collect = audio.AudioQuantumList() for bar in av.audio.analysis.bars: collect.append(bar.children()[0]) out = video.getpieces(av, collect) out.save(output_filename)
def main(toReverse, inputFilename, outputFilename): if inputFilename.startswith("http://"): av = video.loadavfromyoutube(inputFilename) else: av = video.loadav(inputFilename) if toReverse == 'tatums': chunks = av.audio.analysis.tatums elif toReverse == 'beats': chunks = av.audio.analysis.beats chunks.reverse() out = video.getpieces(av, chunks) out.save(outputFilename)
def main(infile, outfile, choices=4): if infile.startswith("http://"): av = video.loadavfromyoutube(infile) else: av = video.loadav(infile) meter = av.audio.analysis.time_signature['value'] sections = av.audio.analysis.sections output = audio.AudioQuantumList() for section in sections: beats = [] bars = section.children() for bar in bars: beats.extend(bar.children()) if not bars or not beats: continue beat_array = [] for m in range(meter): metered_beats = [] for b in beats: if beats.index(b) % meter == m: metered_beats.append(b) beat_array.append(metered_beats) # Always start with the first beat output.append(beat_array[0][0]); for x in range(1, len(bars) * meter): meter_index = x % meter next_candidates = beat_array[meter_index] def sorting_function(chunk, target_chunk=output[-1]): timbre = chunk.mean_timbre() target_timbre = target_chunk.mean_timbre() timbre_distance = numpy.linalg.norm(numpy.array(timbre) - numpy.array(target_timbre)) return timbre_distance next_candidates = sorted(next_candidates, key=sorting_function) next_index = random.randint(0, min(choices, len(next_candidates) - 1)) output.append(next_candidates[next_index]) out = video.getpieces(av, output) out.save(outfile)
def run(self): st = modify.Modify() collect = audio.AudioQuantumList() for a in self.segs: seg_index = a.absolute_context()[0] distances = self.get_distance_from(a) distances[seg_index] = sys.maxint match_index = distances.index(min(distances)) match = self.segs[match_index] print seg_index, match_index # make the length of the new seg match the length # of the old seg collect.append(match) out = video.getpieces(self.av, collect) out.save(self.output_filename)