ofxVideoRecorder issue_image quality & audio issue

Hi,
I tried to import an video in my project and then exported this video using ofxVideoRecorder. However, the image quality is not satisfactory. And I cannot find a way to record audio from my video, the audio recorded was from outside.
The video image before & after:


Does anyone have methods to export video with high-quality?
And also record audio from an video?

Thanks in advance for your help
keyu

Well, the problem with the image quality was solved. It was just that I did not set the video bitrate right.
But I still have the problem with audio recording from video.

I think you’ve got two options here:
1.you can record an audio from microphone - but I am not sure about quality of the sound.

ofSoundStream soundStream;

soundStream.listDevices();
soundStream.setDeviceID(audioDevId);
soundStream.setup(this, 0, audioChannels, audioSampleRate, 256, 4);

void ofApp::recordMovie() {
bRecording = !bRecording;
if (bRecording && !vidRecorder.isInitialized()) {
if (bRecAudio) {
vidRecorder.setup(fileName, vidWidth, vidHeight, recordingFps, audioSampleRate, audioChannels);
}
else {
vidRecorder.setup(fileName, vidWidth, vidHeight, recordingFps, 0, 0, true, false);
}
// Start recording
vidRecorder.start();
}
else if (!bRecording && vidRecorder.isInitialized()) {
vidRecorder.setPaused(true);
}
else if (bRecording && vidRecorder.isInitialized()) {
vidRecorder.setPaused(false);
}
}

This is important part:

void ofApp::audioIn(float *input, int bufferSize, int nChannels) {
if (bRecording) {
vidRecorder.addAudioSamples(input, bufferSize, nChannels);
}
}

2.you can merge your recorded movie with audio (.mp3 or .wav) file afterwards.
You can use the same ffmpeg application which ofxVideoRecorder uses for merging.

Here is some information how to merge audio and video:


Hi Sebastian,
I’m very appreciated for your reply.
But what I actually want to is to complete this whole procedure in oF.
Now I’m thinking about how to get audio from my video,
and then I can process this audio sample in audioOut(), like:

void ofApp::audioOut(float * output, int bufferSize, int nChannels) {
   for (int i = 0; i < bufferSize; i++) {
        double sample = video.getAudioSample();

	    output[i * nChannels + 0] = sample;
	    output[i * nChannels + 1] = sample;
		
	}

	if (bRecording) {
		vidRecorder.addSamples(output, bufferSize * 2);
	}
}

Hi, @Keyu_Gong
I am just curious Did you handle it?

Hi, @SebastianSobotka
Sorry for late reply. I haven’t solved this yet and I’m busy with other things recently. But I will continue to work on it in the future. I’ll let you know if I get a clue.