Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
F
ffworker
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Video AG Infrastruktur
ffworker
Commits
17eeeac6
Commit
17eeeac6
authored
Jan 04, 2018
by
Julian Rother
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added "simple_live_transcode" worker
parent
6de49420
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
1 deletion
+70
-1
Makefile
Makefile
+3
-1
simple_live_transcode.c
simple_live_transcode.c
+67
-0
No files found.
Makefile
View file @
17eeeac6
TARGETS
=
probe probe-raw remux thumbnail transcode publish_video
TARGETS
=
probe probe-raw remux thumbnail transcode publish_video
simple_live_transcode
CFLAGS
=
-I
/usr/include/libxml2
LDFLAGS
=
-lcurl
-lavcodec
-lavformat
-lavfilter
-lswscale
-lavutil
-lxml2
...
...
@@ -18,5 +18,7 @@ transcode: transcode.c *.h util/*.c
publish_video
:
publish_video.c *.h util/*.c
simple_live_transcode
:
simple_live_transcode.c *.h util/*.c
clean
:
rm
-f
${TARGETS}
simple_live_transcode.c
0 → 100644
View file @
17eeeac6
#include <poll.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "util.h"
#define OUTPUT_FORMAT(bitrate) "-f", "flv", "-r", "25", "-c:v", "libx264", "-b:v", bitrate, "-bufsize", bitrate, "-preset", "veryfast", "-x264-params", "keyint=125:min-keyint=125:no-scenecut", "-c:a", "aac"
static
void
copy_to_log
(
int
fd
)
{
static
char
buf
[
1024
];
size_t
len
;
if
((
len
=
read
(
fd
,
BL
(
buf
)))
>
0
)
fwrite
(
buf
,
1
,
len
,
logstream
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
ret
,
errpipe
[
2
]
=
{
-
1
,
-
1
};
char
*
src
,
*
dest
;
pid_t
pid
;
struct
pollfd
fds
=
{.
fd
=
-
1
,
.
events
=
POLLIN
};
if
(
argc
!=
5
)
return
1
;
init_env
();
init_avlogbuf
();
jobid
=
atoi
(
argv
[
1
]);
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"
);
pipe
(
errpipe
);
if
(
!
(
pid
=
fork
()))
{
close
(
errpipe
[
0
]);
dup2
(
errpipe
[
1
],
2
);
close
(
errpipe
[
1
]);
dup2
(
open
(
"/dev/null"
,
O_RDONLY
|
O_CLOEXEC
),
0
);
dup2
(
open
(
"/dev/null"
,
O_WRONLY
|
O_CLOEXEC
),
1
);
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
)),
"-map"
,
"[low]"
,
"-map"
,
"[lowa]"
,
OUTPUT_FORMAT
(
"512k"
),
mprintf
(
"%s_low"
,
dest
),
"-map"
,
"[mid]"
,
"-map"
,
"[mida]"
,
OUTPUT_FORMAT
(
"2024k"
),
mprintf
(
"%s_mid"
,
dest
),
"-map"
,
"[high]"
,
"-map"
,
"[higha]"
,
OUTPUT_FORMAT
(
"6024k"
),
mprintf
(
"%s_high"
,
dest
),
0
);
exit
(
1
);
}
close
(
errpipe
[
1
]);
fds
.
fd
=
errpipe
[
0
];
while
(
1
)
{
ping_job
(
jobid
,
"running"
,
"{
\"
log
\"
:
\"
%s
\"
}"
,
jescape
(
get_avlogbuf
()));
poll
(
&
fds
,
1
,
15000
);
if
(
fds
.
revents
&
POLLIN
)
copy_to_log
(
fds
.
fd
);
else
if
(
fds
.
revents
&
(
POLLERR
|
POLLHUP
|
POLLNVAL
))
break
;
}
waitpid
(
pid
,
&
ret
,
0
);
if
(
!
WEXITSTATUS
(
ret
))
ping_job
(
jobid
,
"finished"
,
"{
\"
log
\"
:
\"
%s
\"
}"
,
jescape
(
get_avlogbuf
()));
else
if
(
WIFSIGNALED
(
ret
))
job_failed
(
"Subprocesses was killed by signal %s (%i)"
,
strsignal
(
WTERMSIG
(
ret
)),
WTERMSIG
(
ret
));
else
job_failed
(
"Subprocesses terminated with exit status %i"
,
WEXITSTATUS
(
ret
));
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment