[GH-ISSUE #6] Generating static Image #6

Open
opened 2026-03-01 14:33:49 +03:00 by kerem · 1 comment
Owner

Originally created by @PeterPan123456 on GitHub (Jul 11, 2023).
Original GitHub issue: https://github.com/adefossez/seewav/issues/6

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.

Originally created by @PeterPan123456 on GitHub (Jul 11, 2023). Original GitHub issue: https://github.com/adefossez/seewav/issues/6 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.
Author
Owner

@PeterPan123456 commented on GitHub (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)
<!-- gh-comment-id:1631920438 --> @PeterPan123456 commented on GitHub (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 in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/seewav#6
No description provided.