able to record ok-sounding audio from picodrive

This commit is contained in:
Viv Lim 2021-07-25 22:02:40 -07:00
parent 41da935d42
commit 57530da214
2 changed files with 13 additions and 4 deletions

9
.gitignore vendored
View File

@ -2,3 +2,12 @@
**/*.rs.bk
/.idea
/Cargo.lock
*.so
*.dll
*.dylib
*.mp4
*.ogv
*.gb
*.bin
.DS_Store

View File

@ -160,7 +160,7 @@ let wavname = Path::new("out.wav");
av_info.geometry.aspect_ratio = 4.33;
}
if av_info.timing.sample_rate == 0.0 {
av_info.timing.sample_rate = 32040.0;
av_info.timing.sample_rate = 44100.0;
}
video_encoder.set_width(av_info.geometry.base_width);
video_encoder.set_height(av_info.geometry.base_height);
@ -303,7 +303,7 @@ static bool ffmpeg_init_config(struct ff_config_param *params,
ChannelLayout::STEREO
);
aframe.set_channels(2);
aframe.set_rate(32040);
aframe.set_rate(44100);
let aplane: &mut [(i16, i16)] = aframe.plane_mut(0);
eprintln!("Audio buffer length {} -> {}", self.audio_buf.len(), aplane.len());
aplane.copy_from_slice(self.audio_buf.as_ref());
@ -355,9 +355,9 @@ static bool ffmpeg_init_config(struct ff_config_param *params,
}
pub fn end(&mut self) {
self.video_encoder.send_eof().unwrap();
self.video_encoder.send_eof();
self.receive_and_write_packets(EncoderToWriteFrom::Video);
self.audio_encoder.send_eof().unwrap();
self.audio_encoder.send_eof();
self.receive_and_write_packets(EncoderToWriteFrom::Audio);
self.octx.write_trailer().unwrap();
}