Passing arguments to system()

조회 수: 1 (최근 30일)
Andrés Liu
Andrés Liu 2015년 3월 7일
댓글: Image Analyst 2015년 3월 7일
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?

답변 (1개)

Image Analyst
Image Analyst 2015년 3월 7일
If your video file name is in variable videoFile, how about
strCommandLine = sprintf('ffmpeg -i %s -vn audio.mp3', videoFile);
system(strCommandLine);
  댓글 수: 2
Andrés Liu
Andrés Liu 2015년 3월 7일
Yes! This worked, thank you!
Image Analyst
Image Analyst 2015년 3월 7일
Can you officially "Accept" it then? Thanks in advance.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by