Filter löschen
Filter löschen

How to combine audio and video?

38 Ansichten (letzte 30 Tage)
keshav poojari
keshav poojari am 10 Dez. 2018
Kommentiert: Walter Roberson am 24 Feb. 2019
it will run.. but not play the video... please tell me what the problem and how to resolve that?
videoFReader = vision.VideoFileReader('video1.avi');
[AUDIO,Fs] = audioread('audio1.wav');
videoFWriter = vision.VideoFileWriter('newvideo.avi','AudioInputPort',true);
videoFrame = step(videoFReader);
step(videoFWriter,videoFrame,AUDIO);
release(videoFReader);
release(videoFWriter);

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 10 Dez. 2018
You are writing all of the audio for the first frame and only reading and writing one frame.
you need to loop reading one input frame and writing that frame out together with the audio that matches it. For example if your audio output rate were 44100 and your video output were 22 frames per second then you should emit roughly 2000 audio samples for each video frame .
You might want to buffer() your audio to make it easier to write the appropriate amount of audio per frame .
  15 Kommentare
keshav poojari
keshav poojari am 24 Feb. 2019
When i used above code to combine audio and video, The output video take much Storage space... can i compress this??? How??
Walter Roberson
Walter Roberson am 24 Feb. 2019
keshav poojari, you might need to post-process the video.
But have a look at the description of the AudioCompressor and VideoCompressor properties that you can set for vision.VideoFileWriter. The choices depend upon what you have installed on your system, so I cannot tell you what the choices are.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Produkte


Version

R2013a

Community Treasure Hunt

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

Start Hunting!

Translated by