Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating static Image #6

Open
PeterPan123456 opened this issue Jul 11, 2023 · 1 comment
Open

Generating static Image #6

PeterPan123456 opened this issue Jul 11, 2023 · 1 comment

Comments

@PeterPan123456
Copy link

Hey I was wondering if there is a way to generate one image that shows the full length of the audio file. My goal ist to get a visual presentation of an audio file similar to soundcloud.

@PeterPan123456 PeterPan123456 changed the title Geberating static Image Generating static Image Jul 11, 2023
@PeterPan123456
Copy link
Author

PeterPan123456 commented Jul 12, 2023

my first approach looked liek this, but didn't work.

import os
import subprocess
from pydub.utils import mediainfo

# File paths
input_audio_file = 'input.wav'
output_video_file = 'output.mp4'
output_image_file = 'output.png'

# Get duration of audio file
audio_info = mediainfo(input_audio_file)
audio_duration = float(audio_info['duration'])

# Command to generate mp4 using seewav
seewav_command = f'seewav -r 1 -c 0.8,0.1,0.2 --white -B 350 -T {audio_duration} -S 1 -W 1920 -H 400 -d 1 {input_audio_file} {output_video_file}'

# Run the command
subprocess.run(seewav_command, shell=True)

# Command to extract first frame as png using ffmpeg
ffmpeg_command = f'ffmpeg -i {output_video_file} -vframes 1 {output_image_file}'

# Run the command
subprocess.run(ffmpeg_command, shell=True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant