From 4a7ad4d6170fbfecbfdcb3e541a8b5379b570651 Mon Sep 17 00:00:00 2001 From: Sebastian Reimers Date: Fri, 9 Dec 2022 22:53:49 +0100 Subject: [PATCH] record: add final mp4 conversion --- modules/aumix/record.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/modules/aumix/record.c b/modules/aumix/record.c index 4310977c..45129a26 100644 --- a/modules/aumix/record.c +++ b/modules/aumix/record.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -183,11 +184,40 @@ int aumix_record(const uint8_t *buf, size_t size) } +static int ffmpeg_final(void *arg) +{ + char *folder = arg; + char *cmd; + int err; + + if (!folder) + return EINVAL; + + err = re_sdprintf( + &cmd, + "cd %s && ffmpeg -f s16le -ar %d -ac %d -i audio.pcm -i " + "video.h264 -c:v copy -c:a aac record.mp4", + folder, SRATE, CH); + if (err) + goto out; + + system(cmd); + + mem_deref(cmd); + +out: + mem_deref(folder); + + return err; +} + + void vidmix_record_close(void); void aumix_record_close(void) { if (!record.run) return; + char *folder = NULL; vidmix_record_close(); @@ -204,4 +234,8 @@ void aumix_record_close(void) fclose(record.f); chmod(record.filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); record.f = NULL; + + str_dup(&folder, record_folder); + + re_thread_async(ffmpeg_final, NULL, folder); }