hi,
i have written a script[1] using ffmpeg 5.1.2 to generate scrolling
waveform videos from audio files. i first use showwavespic to write the
full waveform to an image file, the width of which depends on the
duration of the audio. i then use crop with a time-varying x coordinate
to scroll through the image.
my problem is that the processing speed of the image-to-video step
appears to slow down significantly with longer audio files, i.e. wider
waveform images. for example, the second ffmpeg invocation on my machine
processes 10 seconds of audio at ~1x speed, but 5 minutes of audio at
only ~0.1x speed.
why is this? i expected that after the waveform image is initially
loaded into memory, the time complexity of crop would depend only on the
width and height of the cropped area. is there a better way to achieve
this?
best,
miranda
[1]
#!/usr/bin/env bash
audio_file=$1
xres=1080
yres=1080
downscale=64
fps=60
num_secs=$(soxi -D "$audio_file")
num_samples=$(soxi -s "$audio_file")
img_xres=$((num_samples / downscale))
img_yres="$yres"
img_file="$audio_file.bmp"
vid_file="$audio_file.mkv"
# create an image of the full waveform
ffmpeg \
-i "$audio_file" \
-filter_complex
"[0:a]aformat=channel_layouts=mono,showwavespic=s=${img_xres}x${img_yres}:colors=white:draw=full,format=rgba,pad=$((img_xres
+ xres)):$yres:$xres:0:black@0.0" \
-pix_fmt monob \
-frames:v 1 \
"$img_file"
# create a video scrolling through the waveform
ffmpeg \
-loop 1 -framerate "$fps" -i "$img_file" \
-i "$audio_file" \
-vf "crop=w=$xres:h=$yres:x=t*(iw-ow)/$num_secs:y=0" \
-shortest \
-r "$fps" \
-c:v libx264 \
-c:a copy \
-pix_fmt yuv420p \
"$vid_file"
_______________________________________________
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".