Reading a video file with audio and writing it back to another video file (both image frames and audio))
14 次查看(过去 30 天)
显示 更早的评论
I am trying to read an .mp4 file which has both audio & video and I want to write back the video & audio to another file.
This is what I have done so far.
videoFReader = vision.VideoFileReader('CB1.mp4', 'AudioOutputPort', true); %CB1 is the original video file
videoFWriter = vision.VideoFileWriter('myFile.avi', ...
'FrameRate',videoFReader.info.VideoFrameRate, 'AudioInputPort', true);
for i=1:500
[videoFrame, audio] = videoFReader();
videoFWriter(videoFrame, audio);
end
release(videoFReader);
release(videoFWriter);
When I run this code, I get the following error
Error using VideoFileReader
the audio input stream has become unresponsive.
When I play myFile.avi, the audio is distorted (probably sampled at a different rate from the original sampling rate).
Could some one help me with this? I am not restricted to using vision.VideoFileReader, the purpose is to read a video file and write it back, but with the audio intact.
0 个评论
回答(1 个)
Rajani Mishra
2020-8-2
Refer to VideoReader function and other functions from "Read or Write Video" section of this link : https://in.mathworks.com/help/matlab/audio-and-video.html
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!