Creating MP4 with Audio
Hello
I want to create an MP4 file which contains audio. VideoWriter is not suitable, as it doesn’t input any audio data. So, I used _vision.VideoFileWriter_ and _step_. But I have some problems.
When running the code below:
videoFWriter = vision.VideoFileWriter(‘Test.mp4’, ‘FileFormat’, ‘MPEG4’, ‘FrameRate’, 30, ‘AudioInputPort’, true);
videoFWriter.VideoCompressor = ‘MJPEG Compressor’;
I receive the following warning message:
Warning: The AudioInputPort property is not relevant in this configuration of the System object.
When I change the code to the following, the video format is uncompressed AVI, which leads to huge file sizes.
videoFWriter = vision.VideoFileWriter(‘Test.avi’, ‘FileFormat’, ‘AVI’, ‘FrameRate’, 30, ‘AudioInputPort’, true);
videoFWriter.VideoCompressor = ‘MJPEG Compressor’;
step(videoFWriter, FrameScreen, FrameAudio);
_FrameAudio_ contains audio data corresponding to one video frame. It seems that it ignores ‘MJPEG Compressor’.
I would love to be able to directly create .mp4 files, but if not possible, it is fine with me to create good quality compressed .avi files, and use a 3rd party software to convert to .mp4. I would appreciate any suggestions. Thanks.
My OS is Windows 7, and MATLAB r2017b.
Cheers
Amir-HomayounHello
I want to create an MP4 file which contains audio. VideoWriter is not suitable, as it doesn’t input any audio data. So, I used _vision.VideoFileWriter_ and _step_. But I have some problems.
When running the code below:
videoFWriter = vision.VideoFileWriter(‘Test.mp4’, ‘FileFormat’, ‘MPEG4’, ‘FrameRate’, 30, ‘AudioInputPort’, true);
videoFWriter.VideoCompressor = ‘MJPEG Compressor’;
I receive the following warning message:
Warning: The AudioInputPort property is not relevant in this configuration of the System object.
When I change the code to the following, the video format is uncompressed AVI, which leads to huge file sizes.
videoFWriter = vision.VideoFileWriter(‘Test.avi’, ‘FileFormat’, ‘AVI’, ‘FrameRate’, 30, ‘AudioInputPort’, true);
videoFWriter.VideoCompressor = ‘MJPEG Compressor’;
step(videoFWriter, FrameScreen, FrameAudio);
_FrameAudio_ contains audio data corresponding to one video frame. It seems that it ignores ‘MJPEG Compressor’.
I would love to be able to directly create .mp4 files, but if not possible, it is fine with me to create good quality compressed .avi files, and use a 3rd party software to convert to .mp4. I would appreciate any suggestions. Thanks.
My OS is Windows 7, and MATLAB r2017b.
Cheers
Amir-Homayoun Hello
I want to create an MP4 file which contains audio. VideoWriter is not suitable, as it doesn’t input any audio data. So, I used _vision.VideoFileWriter_ and _step_. But I have some problems.
When running the code below:
videoFWriter = vision.VideoFileWriter(‘Test.mp4’, ‘FileFormat’, ‘MPEG4’, ‘FrameRate’, 30, ‘AudioInputPort’, true);
videoFWriter.VideoCompressor = ‘MJPEG Compressor’;
I receive the following warning message:
Warning: The AudioInputPort property is not relevant in this configuration of the System object.
When I change the code to the following, the video format is uncompressed AVI, which leads to huge file sizes.
videoFWriter = vision.VideoFileWriter(‘Test.avi’, ‘FileFormat’, ‘AVI’, ‘FrameRate’, 30, ‘AudioInputPort’, true);
videoFWriter.VideoCompressor = ‘MJPEG Compressor’;
step(videoFWriter, FrameScreen, FrameAudio);
_FrameAudio_ contains audio data corresponding to one video frame. It seems that it ignores ‘MJPEG Compressor’.
I would love to be able to directly create .mp4 files, but if not possible, it is fine with me to create good quality compressed .avi files, and use a 3rd party software to convert to .mp4. I would appreciate any suggestions. Thanks.
My OS is Windows 7, and MATLAB r2017b.
Cheers
Amir-Homayoun mp4, audio, compression, video, avi, movie, mpeg4, videofilewriter, videowriter, sound MATLAB Answers — New Questions