示例#1
0
def preview_audio(args):
    output_directory = args.output_directory

    audio_source = args.audio_source
    duration = args.duration
    audio_events_mode = args.audio_events_mode
    preview_mode = args.preview_mode

    # Prepare Inputs
    audio_file = get_audio_file(audio_source, duration)
    filename = paths.filename_from_path(audio_file) if audio_file else ''
    output_extension = '.wav' if preview_mode == PreviewMode.AUDIO else VideoWriter.VIDEO_EXTENSION
    output_path = os.path.join(
        output_directory, filename + "_marked_audio_preview_" +
        (audio_events_mode if audio_events_mode else "") + output_extension)

    generator = MusicVideoGenerator(audio_file, duration=duration)
    try:
        events = prepare_events(generator, args)
    except ParameterError as e:
        shutdown(str(e))

    message(
        f"Creating audio preview '{paths.filename_from_path(output_path)}'...")

    generator.preview_events(events, output_path, preview_mode)
示例#2
0
def test_music_video_generator__creates_preview():
    generator = MusicVideoGenerator(audio_file=f'{DATA_PATH}/audio/soft.mp3')
    preview_path = generator.preview_events(generator.audio.beats(),
                                            progress_bar=False)