This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Waveform clip

Tags: None
(comma "," separated)
p1ngu1n
Registered Member
Posts
8
Karma
0

Waveform clip

Mon Dec 27, 2010 5:52 pm
Hello,

this sounds like an audio effect, but it is a video one: I'd like to display as a clip the audio waveform of a sound track, like an oscilloscope does.
Moreover, I'd like to display the audio spectrum too. I assume that Granjow current work will allow that.

Since it is quite a specific need, I'm ready to generate to audio waveform video file and them add it as a clip, but I don't know any good s/w that does that...

best regards

Vincent
Granjow
Moderator
Posts
247
Karma
0

Re: Waveform clip

Mon Dec 27, 2010 6:56 pm
Hi Vincent,

Yes, displaying the spectrum is possible in current SVN. If you have any suggestions there, they are welcome.

If you want to display the waveform (that's the one that is displayed in Audacity by default, right?) in a video clip, then I cannot give you a hint. (I understood correctly that you do not want this for monitoring but merely as a visual effect for the final video?) All frei0r effects only receive image frames, no audio. Maybe you would have to implement this in MLT.

Simon
p1ngu1n
Registered Member
Posts
8
Karma
0

Re: Waveform clip

Mon Dec 27, 2010 10:49 pm
Here is what I'm currently doing:

- extract audio into a wav file (kdenlive does it well, or ffmpeg, mencoder)
- use GNU octave to plot the wave in PNG images files so that each image plots the audio of one video frame (25 images/sec, 48 kHz ==> 1920 samples per image)
- use ffmpeg/mencoder to create the video based on the PNG images files

I've just finished my first try. It seems OK, but I now have to deal with axis, style, colors, to make it look less "mathematic" and more funny.
I'll share whole process when it is ready. It relies on GNU octave that is a easy to get software, and free
Granjow
Moderator
Posts
247
Karma
0

Re: Waveform clip

Wed Dec 29, 2010 7:29 am
Uh. I never even managed to print plots to PNG files with a custom size.
Perhaps you could run a GIMP script or imagemagick on the PNG files afterwards for some effects? ;)
j-b-m
Registered Member
Posts
804
Karma
1

Re: Waveform clip

Wed Dec 29, 2010 1:25 pm
MLT provides an effect to display the audio as waveform. The effect is called "audiowave". To test it, from a terminal:

melt myclip.mpg -attach audiowave

I just added it in Kdenlive's current svn.
ddennedy
Registered Member
Posts
1315
Karma
1

Re: Waveform clip

Wed Dec 29, 2010 6:19 pm
Please note that this mlt effect does not look well at high/wide resolution - if the project horizontal resolution is close to or greater than the number of audio samples in the duration of one video frame. For example, at 30 fps video and 48 KHz audio, there are 1600 samples per frame. So, resolutions higher than SD will not give good results. The effect was mostly designed to provide forthcoming audio thumbnailing in OpenShot. It could use some improvement.


p1ngu1n
Registered Member
Posts
8
Karma
0

Re: Waveform clip

Wed Dec 29, 2010 10:19 pm
Hi all,

ddennedy, I'll give it a try asap !


In the mid time, I have written folowing octave script that gives me pretty good result (thickness of the waveform is set to 3 so as to avoid problems like the one mentioned by ddennedy).


# read the wave file
ys = wavread("myFile.mov.wav");
# Only get the firt track, choose the one you want
ys1 = ys(:, 1);
# every 1/25second, plot the wave
# 1920 samples are recorded every 1/25 second since 48kHz
for i=1:length(ys1)/1920-1
# plot
plot(ys1(i*1920: (i+1)*1920));
# define same axis for all plots
axis ([0,1920,-0.5,+0.5]);
# bold line
ht = findall (gcf, "-property", "linewidth");
set(ht, "linewidth", 3)
# remove axis
axes = gca;
set(axes, 'visible', 'off');
# create a filename
filename=sprintf('%05d.png',i);
# save as a png file of 1920 x 400 pixels
print(filename, "-S1920,400");
endfor

then, in a shell, simply combine all png into one file:
mencoder mf://*.png -mf w=1920:h=400:fps=25:type=png -ovc lavc -lavcopts vcodec=mjpeg -oac copy -o output.avi

Granjow, the line "print(filename, "-S1920,400");" scales the png file to correct size and redraw the waveform so that there is no ugly scaling effects. It took me hours to begin understanding how to pamareterize gnuplot from octave...

Attached is one frame (you will surely recognize that it is a baby cry).
Image


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], lockheed, Sogou [Bot]