Borrar filtros
Borrar filtros

Reading a video file with audio and writing it back to another video file (both image frames and audio))

12 visualizaciones (últimos 30 días)
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',, 'AudioInputPort', true);
for i=1:500
[videoFrame, audio] = videoFReader();
videoFWriter(videoFrame, audio);
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.

Respuestas (1)

Rajani Mishra
Rajani Mishra el 2 de Ag. de 2020
Refer to VideoReader function and other functions from "Read or Write Video" section of this link :
  1 comentario
JT el 7 de Ag. de 2020
Dear Rajani,
Based on your comments, this is the code which I wrote:
v1 = VideoReader('xylophone.mp4'); % original file
v2 = VideoWriter('newfile.avi'); % new file
while hasFrame(v1)
frame = readFrame(v1);
I am trying to duplicate 'xylophone.mp4' and 'newfile.avi' is my new file. The issue is that the audio in 'xylophone.mp4' is lost during this process. As mentioned in my question, my requirement is to create a file with both audio and video.

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by