Merge branch 'ffmpeg-tune' into 'develop'
Tune ffmpeg commands See merge request knotteye/satyr!19merge-requests/20/head
commit
ac73eb2af3
|
@ -26,6 +26,15 @@ transcode:
|
||||||
# satyr will generate one source quality variant, and the remaining
|
# satyr will generate one source quality variant, and the remaining
|
||||||
# variants will be of incrementally lower quality and bitrate
|
# variants will be of incrementally lower quality and bitrate
|
||||||
|
|
||||||
|
inputflags: ""
|
||||||
|
# additional flags to apply to the input during transcoding
|
||||||
|
outputflags: ""
|
||||||
|
# additional flags to apply to the output during transcoding
|
||||||
|
|
||||||
|
# hardware acceleration is a bit difficult to configure programmatically
|
||||||
|
# this is a good place to do so for your system
|
||||||
|
# https://trac.ffmpeg.org/wiki/HWAccelIntro is a good place to start
|
||||||
|
|
||||||
# having more than 4-5 variants will start giving diminishing returns on stream quality for cpu load
|
# having more than 4-5 variants will start giving diminishing returns on stream quality for cpu load
|
||||||
# if you can't afford to generate at least 3 variants, it's reccomended to leave adaptive streaming off
|
# if you can't afford to generate at least 3 variants, it's reccomended to leave adaptive streaming off
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,9 @@ const config: Object = {
|
||||||
transcode: Object.assign({
|
transcode: Object.assign({
|
||||||
adapative: false,
|
adapative: false,
|
||||||
variants: 3,
|
variants: 3,
|
||||||
format: 'dash'
|
format: 'dash',
|
||||||
|
inputflags: null,
|
||||||
|
outputflags: null
|
||||||
}, localconfig['transcode']),
|
}, localconfig['transcode']),
|
||||||
chat: {
|
chat: {
|
||||||
irc: Object.assign({
|
irc: Object.assign({
|
||||||
|
|
|
@ -41,7 +41,11 @@ function init () {
|
||||||
while(true){
|
while(true){
|
||||||
if(session.audioCodec !== 0 && session.videoCodec !== 0){
|
if(session.audioCodec !== 0 && session.videoCodec !== 0){
|
||||||
transCommand(results[0].username, key).then((r) => {
|
transCommand(results[0].username, key).then((r) => {
|
||||||
execFile(config['media']['ffmpeg'], r, {maxBuffer: Infinity}, (err, stdout, stderr) => {});
|
execFile(config['media']['ffmpeg'], r, {maxBuffer: Infinity}, (err, stdout, stderr) => {
|
||||||
|
console.log(err);
|
||||||
|
console.log(stdout);
|
||||||
|
console.log(stderr);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +116,9 @@ function init () {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function transCommand(user: string, key: string): Promise<string[]>{
|
async function transCommand(user: string, key: string): Promise<string[]>{
|
||||||
let args: string[] = [/*'-loglevel', 'fatal',*/ '-y', '-i', 'rtmp://127.0.0.1:'+config['rtmp']['port']+'/'+config['media']['privateEndpoint']+'/'+key];
|
let args: string[] = ['-loglevel', 'fatal', '-y'];
|
||||||
|
if(config['transcode']['inputflags'] !== null && config['transcode']['inputflags'] !== "") args = args.concat(config['transcode']['inputflags'].split(" "));
|
||||||
|
args = args.concat(['-i', 'rtmp://127.0.0.1:'+config['rtmp']['port']+'/'+config['media']['privateEndpoint']+'/'+key, '-movflags', '+faststart']);
|
||||||
if(config['transcode']['adaptive']===true && config['transcode']['variants'] > 1) {
|
if(config['transcode']['adaptive']===true && config['transcode']['variants'] > 1) {
|
||||||
for(let i=0;i<config['transcode']['variants'];i++){
|
for(let i=0;i<config['transcode']['variants'];i++){
|
||||||
args = args.concat(['-map', '0:2']);
|
args = args.concat(['-map', '0:2']);
|
||||||
|
@ -133,8 +139,11 @@ async function transCommand(user: string, key: string): Promise<string[]>{
|
||||||
else {
|
else {
|
||||||
args = args.concat(['-c:a', 'aac', '-c:v', 'libx264']);
|
args = args.concat(['-c:a', 'aac', '-c:v', 'libx264']);
|
||||||
}
|
}
|
||||||
|
args = args.concat(['-preset', 'veryfast', '-tune', 'zerolatency']);
|
||||||
//if(config['transcode']['format'] === 'dash')
|
//if(config['transcode']['format'] === 'dash')
|
||||||
args = args.concat(['-remove_at_exit', '1', '-seg_duration', '1', '-window_size', '30', '-f', 'dash', config['http']['directory']+'/'+config['media']['publicEndpoint']+'/'+user+'/index.mpd']);
|
args = args.concat(['-remove_at_exit', '1', '-seg_duration', '1', '-window_size', '30']);
|
||||||
|
if(config['transcode']['outputflags'] !== null && config['transcode']['outputflags'] !== "") args = args.concat(config['transcode']['outputflags'].split(" "));
|
||||||
|
args = args.concat(['-f', 'dash', config['http']['directory']+'/'+config['media']['publicEndpoint']+'/'+user+'/index.mpd']);
|
||||||
//else if(config['transcode']['format'] === 'hls')
|
//else if(config['transcode']['format'] === 'hls')
|
||||||
//args = args.concat(['-remove_at_exit', '1', '-hls_time', '1', '-hls_list_size', '30', '-f', 'hls', config['http']['directory']+'/'+config['media']['publicEndpoint']+'/'+user+'/index.m3u8']);
|
//args = args.concat(['-remove_at_exit', '1', '-hls_time', '1', '-hls_list_size', '30', '-f', 'hls', config['http']['directory']+'/'+config['media']['publicEndpoint']+'/'+user+'/index.m3u8']);
|
||||||
return args;
|
return args;
|
||||||
|
|
Reference in New Issue