Commit 96b62209 authored by Julian Rother's avatar Julian Rother

simple_live_transcode: Added left2mono, downmix2mono and normalize options

parent 8346a4b9
...@@ -18,7 +18,7 @@ static void copy_to_log(int fd) ...@@ -18,7 +18,7 @@ static void copy_to_log(int fd)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int ret, canceled = 0, errpipe[2] = {-1, -1}; int ret, canceled = 0, errpipe[2] = {-1, -1};
char *src, *dest; char *src, *dest, *options, *afilter;
pid_t pid; pid_t pid;
struct pollfd fds = {.fd = -1, .events = POLLIN}; struct pollfd fds = {.fd = -1, .events = POLLIN};
if (argc != 5) if (argc != 5)
...@@ -28,7 +28,15 @@ int main(int argc, char *argv[]) ...@@ -28,7 +28,15 @@ int main(int argc, char *argv[])
jobid = atoi(argv[1]); jobid = atoi(argv[1]);
src = jstr(jlookup(argv[4], "src"), "rtmp://127.0.0.1:999999/nourl"); src = jstr(jlookup(argv[4], "src"), "rtmp://127.0.0.1:999999/nourl");
dest = jstr(jlookup(argv[4], "destbase"), "rtmp://127.0.0.1:999999/nourl"); dest = jstr(jlookup(argv[4], "destbase"), "rtmp://127.0.0.1:999999/nourl");
options = jlookup(argv[4], "options");
afilter = "";
if (jint(jlookup(options, "left2mono"), 0))
afilter = mprintf("%span=mono|c0=c0,", afilter);
else if (jint(jlookup(options, "downmix2mono"), 0))
afilter = mprintf("%span=mono|c0=0.5*c0+0.5*c1,", afilter);
if (jint(jlookup(options, "normalize"), 0))
afilter = mprintf("%sloudnorm,", afilter);
pipe(errpipe); pipe(errpipe);
if (!(pid = fork())) if (!(pid = fork()))
{ {
...@@ -37,7 +45,8 @@ int main(int argc, char *argv[]) ...@@ -37,7 +45,8 @@ int main(int argc, char *argv[])
dup2(open("/dev/null", O_RDONLY|O_CLOEXEC), 0); dup2(open("/dev/null", O_RDONLY|O_CLOEXEC), 0);
dup2(open("/dev/null", O_WRONLY|O_CLOEXEC), 1); dup2(open("/dev/null", O_WRONLY|O_CLOEXEC), 1);
execlp("ffmpeg", "ffmpeg", "-nostats", "-i", src, "-filter_complex", execlp("ffmpeg", "ffmpeg", "-nostats", "-i", src, "-filter_complex",
mprintf("[0:a]asplit=3[lowa][mida][higha]; movie=%s/video-logo-150px-trans.png,scale=w=100:h=100[logo]; [0:v]yadif,scale=1920:1080[tmp]; [tmp][logo]overlay=x=W-195:y=H-155,split=3[lowtmp][midtmp][high]; [lowtmp]scale=640:360[low]; [midtmp]scale=1280:720[mid]", getenv(WORKER_RAW)), mprintf("[0:a]%sasplit=3[lowa][mida][higha]; movie=%s/video-logo-150px-trans.png,scale=w=100:h=100[logo]; [0:v]yadif,scale=1920:1080[tmp]; [tmp][logo]overlay=x=W-195:y=H-155,split=3[lowtmp][midtmp][high]; [lowtmp]scale=640:360[low]; [midtmp]scale=1280:720[mid]",
afilter, getenv(WORKER_RAW)),
"-map", "[low]", "-map", "[lowa]", OUTPUT_FORMAT("512k"), mprintf("%s_low", dest), "-map", "[low]", "-map", "[lowa]", OUTPUT_FORMAT("512k"), mprintf("%s_low", dest),
"-map", "[mid]", "-map", "[mida]", OUTPUT_FORMAT("2024k"), mprintf("%s_mid", dest), "-map", "[mid]", "-map", "[mida]", OUTPUT_FORMAT("2024k"), mprintf("%s_mid", dest),
"-map", "[high]", "-map", "[higha]", OUTPUT_FORMAT("6024k"), mprintf("%s_high", dest), 0); "-map", "[high]", "-map", "[higha]", OUTPUT_FORMAT("6024k"), mprintf("%s_high", dest), 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment