Skip to content

Commit

Permalink
record: add final mp4 conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Dec 9, 2022
1 parent 245b48c commit 4a7ad4d
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions modules/aumix/record.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

#include <time.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <pthread.h>
#include <re.h>
Expand Down Expand Up @@ -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();

Expand All @@ -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);
}

0 comments on commit 4a7ad4d

Please sign in to comment.