Passing arguments to system()

I'm using system() to run ffmpeg, my problem is that I can't get to pass the arguments from outside this function. This is the code:
function videoFunction(videoFile)
vid = VideoReader(videoFile);
system('ffmpeg -i vid -vn audio.mp3');
disp('Audio extraído')
end
If I put the path to the video in -i video.avi instead of -i vid it would work but I need to pass it like I mentioned. Any ideas?

Antworten (1)

Image Analyst
Image Analyst am 7 Mär. 2015

0 Stimmen

If your video file name is in variable videoFile, how about
strCommandLine = sprintf('ffmpeg -i %s -vn audio.mp3', videoFile);
system(strCommandLine);

2 Kommentare

Andrés Liu
Andrés Liu am 7 Mär. 2015
Yes! This worked, thank you!
Image Analyst
Image Analyst am 7 Mär. 2015
Can you officially "Accept" it then? Thanks in advance.

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 7 Mär. 2015

Kommentiert:

am 7 Mär. 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by