From 0e413b94d8f8245e8eb9a147fc494a4497537667 Mon Sep 17 00:00:00 2001 From: Tobias Schlager Date: Fri, 24 Sep 2021 13:43:33 +0200 Subject: [PATCH] Fix WAV audio recordings Using WAV as the audio recording format resulted in corrupted files where the chunk length did not propery correspond to the actual chunk content or file length. This was caused by initially writing the audio samples to the start of the file instead of the data chunk. On close, writing the WAV header would then overwrite the first bytes of audio. --- src/audiofilters/msfilerec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/audiofilters/msfilerec.c b/src/audiofilters/msfilerec.c index 7a008e8bc4..f2d4f8c190 100644 --- a/src/audiofilters/msfilerec.c +++ b/src/audiofilters/msfilerec.c @@ -151,6 +151,10 @@ static int rec_open(MSFilter *f, void *arg){ ms_error("Could not lseek to end of file: %s",strerror(err)); } }else ms_error("fstat() failed: %s",strerror(errno)); + }else{ + if (s->is_wav){ + write_wav_header(s->fd, s->rate, s->nchannels, s->size); + } } ms_message("MSFileRec: recording into %s",filename); s->writer = ms_async_writer_new(s->fd);