add/extract Audio to/from Video

19 ビュー (過去 30 日間)
Mike Dachui
Mike Dachui 2020 年 4 月 28 日
コメント済み: Mike Dachui 2020 年 4 月 30 日
How can I extract an audio document(*.wav) from a video document(*.avi)???
How can I add an audio document(*.wav) to a video document(*.avi)???
THX!!!THX!!!THX!!!

採用された回答

Mehmed Saad
Mehmed Saad 2020 年 4 月 28 日
編集済み: Mehmed Saad 2020 年 4 月 28 日
Write audio in a video using vision.VideoFileWriter. The source of code
VideoFrameRate = 24;
TempImage = imread('cameraman.tif');
load handel.mat
y = y(1:4 * Fs, :); % select the first 4s
AudioStep = Fs / VideoFrameRate;
videoFWriter = vision.VideoFileWriter('Temp.avi', 'FileFormat', 'AVI',...
'FrameRate', VideoFrameRate, 'AudioInputPort', true);
for i = 1:(VideoFrameRate * length(y) / Fs)
TempIndexBeginning = floor((i - 1) * AudioStep) + 1;
TempIndexEnding = ceil(TempIndexBeginning + AudioStep - 1);
step(videoFWriter, TempImage, y(TempIndexBeginning:TempIndexEnding));
end
release(videoFWriter);
Read Sound from Video directly usind audioread
[y1,Fs1] = audioread('Temp.avi');
  1 件のコメント
Mike Dachui
Mike Dachui 2020 年 4 月 30 日
Sorry for my late reply! Really helpful! Thanks a lot!

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by