convert file from .wav to .mp3
Mostrar comentarios más antiguos
I am using following code to extract just the audio in .wav format from a video in .avi format
file='take.avi';
file1='vipmen1.wav'; %o/p file name
hmfr=video.MultimediaFileReader(file,'AudioOutputPort',true,'VideoOutputPort',false);
hmfw = video.MultimediaFileWriter(file1,'AudioInputPort',true,'FileFormat','WAV');
while ~isDone(hmfr)
audioFrame = step(hmfr);
step(hmfw,audioFrame);
end
close(hmfw);
close(hmfr);
Then i am using the following code in gui for conversion :
global pl;
global sf;
[FileName,PathName]=uigetfile('*.wav')
myFile=[PathName,FileName]
[mySong,sf]=wavread(myFile);
mp3write(mySong,sf,FileName)
it gives no error whatsoever but the mp3 file is not to be found.
Its not there in the working directory and the inital .wav file still is in same format.
1 comentario
Jan
el 25 de Mzo. de 2013
Please format your code properly.
Respuestas (1)
[FileName,PathName]=uigetfile('*.wav')
myFile=[PathName,FileName]
[mySong,sf]=wavread(myFile);
mp3write(mySong,sf,FileName)
Is this mp3write from the FileExchange? Please do not let us guess such important details. This function creates the file "Default_name.mp3" as default, when it is called with 3 inputs only.
What is the current directory during writing the file? Using absolute file names would be safer:
[dummy, Name] = fileparts(FileName);
mp3write(mySong, sf, FileName, fullfile(PathName, [Name, '.mp3']);
A general method to solve such problems is the debugger: Set a breakpoint in the line, which calls mp3write, then step into this function and see, what's going on.
4 comentarios
Niranjan Satam
el 25 de Mzo. de 2013
Look in the code of mp3write. The file name 'Default_name.mp3' is created there and the file should be saved to directory, which is active, when you start lame ! So please define an absolute file name for the created MP3. There is no better way to allow for an easy finding of the file later on:
mp3write(mySong, sf, FileName, fullfile(PathName, [Name, '.mp3']);
Do you see, that a 4th input is defined for mp3write?
UPS! Sorry, another search has shown, that there are 2 mp3write function in the FileExchange. So please, Niranjan Satam, tell us, which function you are using.
I'm convinced, that the debugger will be very useful, if it is used carefully.
Niranjan Satam
el 26 de Mzo. de 2013
Niranjan Satam
el 27 de Mzo. de 2013
Categorías
Más información sobre Audio and Video Data en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!