Compare commits

...

3 commits

Author SHA1 Message Date
mertalev
fccca4759e
fixed audio stream mapping 2023-09-02 14:35:56 -04:00
mertalev
19fb0fc345
updated tests 2023-09-02 00:45:09 -04:00
mertalev
74f53e9519
set stream with -map flag 2023-09-02 00:22:04 -04:00
4 changed files with 155 additions and 80 deletions

View file

@ -311,10 +311,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: [], inputOptions: [],
outputOptions: [ outputOptions: [
'-c:v:0 h264', '-c:v h264',
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf format=yuv420p', '-vf format=yuv420p',
'-preset ultrafast', '-preset ultrafast',
@ -350,10 +352,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: [], inputOptions: [],
outputOptions: [ outputOptions: [
'-c:v:0 h264', '-c:v h264',
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf format=yuv420p', '-vf format=yuv420p',
'-preset ultrafast', '-preset ultrafast',
@ -374,10 +378,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: [], inputOptions: [],
outputOptions: [ outputOptions: [
'-c:v:0 h264', '-c:v h264',
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf scale=-2:720,format=yuv420p', '-vf scale=-2:720,format=yuv420p',
'-preset ultrafast', '-preset ultrafast',
@ -401,10 +407,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: [], inputOptions: [],
outputOptions: [ outputOptions: [
'-c:v:0 h264', '-c:v h264',
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf format=yuv420p', '-vf format=yuv420p',
'-preset ultrafast', '-preset ultrafast',
@ -426,10 +434,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: [], inputOptions: [],
outputOptions: [ outputOptions: [
'-c:v:0 h264', '-c:v h264',
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf scale=720:-2,format=yuv420p', '-vf scale=720:-2,format=yuv420p',
'-preset ultrafast', '-preset ultrafast',
@ -451,10 +461,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: [], inputOptions: [],
outputOptions: [ outputOptions: [
'-c:v:0 h264', '-c:v h264',
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf scale=-2:720,format=yuv420p', '-vf scale=-2:720,format=yuv420p',
'-preset ultrafast', '-preset ultrafast',
@ -476,10 +488,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: [], inputOptions: [],
outputOptions: [ outputOptions: [
'-c:v:0 h264', '-c:v h264',
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf scale=-2:720,format=yuv420p', '-vf scale=-2:720,format=yuv420p',
'-preset ultrafast', '-preset ultrafast',
@ -525,10 +539,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: [], inputOptions: [],
outputOptions: [ outputOptions: [
'-c:v:0 h264', '-c:v h264',
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf scale=-2:720,format=yuv420p', '-vf scale=-2:720,format=yuv420p',
'-preset ultrafast', '-preset ultrafast',
@ -555,10 +571,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: [], inputOptions: [],
outputOptions: [ outputOptions: [
'-c:v:0 h264', '-c:v h264',
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf scale=-2:720,format=yuv420p', '-vf scale=-2:720,format=yuv420p',
'-preset ultrafast', '-preset ultrafast',
@ -582,10 +600,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: [], inputOptions: [],
outputOptions: [ outputOptions: [
'-c:v:0 h264', '-c:v h264',
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf scale=-2:720,format=yuv420p', '-vf scale=-2:720,format=yuv420p',
'-preset ultrafast', '-preset ultrafast',
@ -611,10 +631,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: [], inputOptions: [],
outputOptions: [ outputOptions: [
'-c:v:0 vp9', '-c:v vp9',
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf scale=-2:720,format=yuv420p', '-vf scale=-2:720,format=yuv420p',
'-cpu-used 5', '-cpu-used 5',
@ -642,10 +664,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: [], inputOptions: [],
outputOptions: [ outputOptions: [
'-c:v:0 vp9', '-c:v vp9',
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf scale=-2:720,format=yuv420p', '-vf scale=-2:720,format=yuv420p',
'-cpu-used 2', '-cpu-used 2',
@ -672,10 +696,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: [], inputOptions: [],
outputOptions: [ outputOptions: [
'-c:v:0 vp9', '-c:v vp9',
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf scale=-2:720,format=yuv420p', '-vf scale=-2:720,format=yuv420p',
'-row-mt 1', '-row-mt 1',
@ -701,10 +727,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: [], inputOptions: [],
outputOptions: [ outputOptions: [
'-c:v:0 vp9', '-c:v vp9',
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf scale=-2:720,format=yuv420p', '-vf scale=-2:720,format=yuv420p',
'-cpu-used 5', '-cpu-used 5',
@ -729,10 +757,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: [], inputOptions: [],
outputOptions: [ outputOptions: [
'-c:v:0 h264', '-c:v h264',
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf scale=-2:720,format=yuv420p', '-vf scale=-2:720,format=yuv420p',
'-preset ultrafast', '-preset ultrafast',
@ -757,10 +787,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: [], inputOptions: [],
outputOptions: [ outputOptions: [
'-c:v:0 h264', '-c:v h264',
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf scale=-2:720,format=yuv420p', '-vf scale=-2:720,format=yuv420p',
'-preset ultrafast', '-preset ultrafast',
@ -785,10 +817,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: [], inputOptions: [],
outputOptions: [ outputOptions: [
'-c:v:0 hevc', '-c:v hevc',
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf scale=-2:720,format=yuv420p', '-vf scale=-2:720,format=yuv420p',
'-preset ultrafast', '-preset ultrafast',
@ -816,10 +850,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: [], inputOptions: [],
outputOptions: [ outputOptions: [
'-c:v:0 hevc', '-c:v hevc',
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf scale=-2:720,format=yuv420p', '-vf scale=-2:720,format=yuv420p',
'-preset ultrafast', '-preset ultrafast',
@ -885,10 +921,12 @@ describe(MediaService.name, () => {
'-rc-lookahead 20', '-rc-lookahead 20',
'-i_qfactor 0.75', '-i_qfactor 0.75',
'-b_qfactor 1.1', '-b_qfactor 1.1',
`-c:v:0 h264_nvenc`, `-c:v h264_nvenc`,
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf format=nv12,hwupload_cuda,scale_cuda=-2:720', '-vf format=nv12,hwupload_cuda,scale_cuda=-2:720',
'-preset p1', '-preset p1',
@ -925,10 +963,12 @@ describe(MediaService.name, () => {
'-rc-lookahead 20', '-rc-lookahead 20',
'-i_qfactor 0.75', '-i_qfactor 0.75',
'-b_qfactor 1.1', '-b_qfactor 1.1',
`-c:v:0 h264_nvenc`, `-c:v h264_nvenc`,
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf format=nv12,hwupload_cuda,scale_cuda=-2:720', '-vf format=nv12,hwupload_cuda,scale_cuda=-2:720',
'-preset p1', '-preset p1',
@ -961,10 +1001,12 @@ describe(MediaService.name, () => {
'-rc-lookahead 20', '-rc-lookahead 20',
'-i_qfactor 0.75', '-i_qfactor 0.75',
'-b_qfactor 1.1', '-b_qfactor 1.1',
`-c:v:0 h264_nvenc`, `-c:v h264_nvenc`,
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf format=nv12,hwupload_cuda,scale_cuda=-2:720', '-vf format=nv12,hwupload_cuda,scale_cuda=-2:720',
'-preset p1', '-preset p1',
@ -998,10 +1040,12 @@ describe(MediaService.name, () => {
'-rc-lookahead 20', '-rc-lookahead 20',
'-i_qfactor 0.75', '-i_qfactor 0.75',
'-b_qfactor 1.1', '-b_qfactor 1.1',
`-c:v:0 h264_nvenc`, `-c:v h264_nvenc`,
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf format=nv12,hwupload_cuda,scale_cuda=-2:720', '-vf format=nv12,hwupload_cuda,scale_cuda=-2:720',
'-cq:v 23', '-cq:v 23',
@ -1031,10 +1075,12 @@ describe(MediaService.name, () => {
'-rc-lookahead 20', '-rc-lookahead 20',
'-i_qfactor 0.75', '-i_qfactor 0.75',
'-b_qfactor 1.1', '-b_qfactor 1.1',
`-c:v:0 h264_nvenc`, `-c:v h264_nvenc`,
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf format=nv12,hwupload_cuda,scale_cuda=-2:720', '-vf format=nv12,hwupload_cuda,scale_cuda=-2:720',
'-preset p1', '-preset p1',
@ -1064,10 +1110,12 @@ describe(MediaService.name, () => {
'-extbrc 1', '-extbrc 1',
'-refs 5', '-refs 5',
'-bf 7', '-bf 7',
`-c:v:0 h264_qsv`, `-c:v h264_qsv`,
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf format=nv12,hwupload=extra_hw_frames=64,scale_qsv=-1:720', '-vf format=nv12,hwupload=extra_hw_frames=64,scale_qsv=-1:720',
'-preset 7', '-preset 7',
@ -1099,10 +1147,12 @@ describe(MediaService.name, () => {
'-extbrc 1', '-extbrc 1',
'-refs 5', '-refs 5',
'-bf 7', '-bf 7',
`-c:v:0 h264_qsv`, `-c:v h264_qsv`,
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf format=nv12,hwupload=extra_hw_frames=64,scale_qsv=-1:720', '-vf format=nv12,hwupload=extra_hw_frames=64,scale_qsv=-1:720',
'-global_quality 23', '-global_quality 23',
@ -1131,10 +1181,12 @@ describe(MediaService.name, () => {
'-extbrc 1', '-extbrc 1',
'-refs 5', '-refs 5',
'-bf 7', '-bf 7',
`-c:v:0 vp9_qsv`, `-c:v vp9_qsv`,
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-low_power 1', '-low_power 1',
'-v verbose', '-v verbose',
'-vf format=nv12,hwupload=extra_hw_frames=64,scale_qsv=-1:720', '-vf format=nv12,hwupload=extra_hw_frames=64,scale_qsv=-1:720',
@ -1170,10 +1222,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: ['-init_hw_device vaapi=accel:/dev/dri/renderD128', '-filter_hw_device accel'], inputOptions: ['-init_hw_device vaapi=accel:/dev/dri/renderD128', '-filter_hw_device accel'],
outputOptions: [ outputOptions: [
`-c:v:0 h264_vaapi`, `-c:v h264_vaapi`,
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf format=nv12,hwupload,scale_vaapi=-2:720', '-vf format=nv12,hwupload,scale_vaapi=-2:720',
'-compression_level 7', '-compression_level 7',
@ -1199,10 +1253,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: ['-init_hw_device vaapi=accel:/dev/dri/renderD128', '-filter_hw_device accel'], inputOptions: ['-init_hw_device vaapi=accel:/dev/dri/renderD128', '-filter_hw_device accel'],
outputOptions: [ outputOptions: [
`-c:v:0 h264_vaapi`, `-c:v h264_vaapi`,
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf format=nv12,hwupload,scale_vaapi=-2:720', '-vf format=nv12,hwupload,scale_vaapi=-2:720',
'-compression_level 7', '-compression_level 7',
@ -1230,10 +1286,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: ['-init_hw_device vaapi=accel:/dev/dri/renderD128', '-filter_hw_device accel'], inputOptions: ['-init_hw_device vaapi=accel:/dev/dri/renderD128', '-filter_hw_device accel'],
outputOptions: [ outputOptions: [
`-c:v:0 h264_vaapi`, `-c:v h264_vaapi`,
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf format=nv12,hwupload,scale_vaapi=-2:720', '-vf format=nv12,hwupload,scale_vaapi=-2:720',
'-qp 23', '-qp 23',
@ -1257,10 +1315,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: ['-init_hw_device vaapi=accel:/dev/dri/card1', '-filter_hw_device accel'], inputOptions: ['-init_hw_device vaapi=accel:/dev/dri/card1', '-filter_hw_device accel'],
outputOptions: [ outputOptions: [
`-c:v:0 h264_vaapi`, `-c:v h264_vaapi`,
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf format=nv12,hwupload,scale_vaapi=-2:720', '-vf format=nv12,hwupload,scale_vaapi=-2:720',
'-compression_level 7', '-compression_level 7',
@ -1280,10 +1340,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: ['-init_hw_device vaapi=accel:/dev/dri/renderD129', '-filter_hw_device accel'], inputOptions: ['-init_hw_device vaapi=accel:/dev/dri/renderD129', '-filter_hw_device accel'],
outputOptions: [ outputOptions: [
`-c:v:0 h264_vaapi`, `-c:v h264_vaapi`,
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf format=nv12,hwupload,scale_vaapi=-2:720', '-vf format=nv12,hwupload,scale_vaapi=-2:720',
'-compression_level 7', '-compression_level 7',
@ -1310,10 +1372,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: [], inputOptions: [],
outputOptions: [ outputOptions: [
'-c:v:0 h264', '-c:v h264',
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf scale=-2:720,format=yuv420p', '-vf scale=-2:720,format=yuv420p',
'-preset ultrafast', '-preset ultrafast',
@ -1345,10 +1409,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: [], inputOptions: [],
outputOptions: [ outputOptions: [
'-c:v:0 h264', '-c:v h264',
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf zscale=t=linear:npl=100,tonemap=hable:desat=0,zscale=p=bt709:t=bt709:m=bt709:range=pc,format=yuv420p', '-vf zscale=t=linear:npl=100,tonemap=hable:desat=0,zscale=p=bt709:t=bt709:m=bt709:range=pc,format=yuv420p',
'-preset ultrafast', '-preset ultrafast',
@ -1370,10 +1436,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: [], inputOptions: [],
outputOptions: [ outputOptions: [
'-c:v:0 h264', '-c:v h264',
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf zscale=t=linear:npl=100,tonemap=hable:desat=0,zscale=p=bt709:t=bt709:m=bt709:range=pc,format=yuv420p', '-vf zscale=t=linear:npl=100,tonemap=hable:desat=0,zscale=p=bt709:t=bt709:m=bt709:range=pc,format=yuv420p',
'-preset ultrafast', '-preset ultrafast',
@ -1395,10 +1463,12 @@ describe(MediaService.name, () => {
{ {
inputOptions: [], inputOptions: [],
outputOptions: [ outputOptions: [
'-c:v:0 h264', '-c:v h264',
'-c:a:0 aac', '-c:a aac',
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
'-v verbose', '-v verbose',
'-vf zscale=t=linear:npl=250,tonemap=mobius:desat=0,zscale=p=bt709:t=bt709:m=bt709:range=pc,format=yuv420p', '-vf zscale=t=linear:npl=250,tonemap=mobius:desat=0,zscale=p=bt709:t=bt709:m=bt709:range=pc,format=yuv420p',
'-preset ultrafast', '-preset ultrafast',

View file

@ -11,7 +11,7 @@ import {
class BaseConfig implements VideoCodecSWConfig { class BaseConfig implements VideoCodecSWConfig {
constructor(protected config: SystemConfigFFmpegDto) {} constructor(protected config: SystemConfigFFmpegDto) {}
getOptions(videoStream: VideoStreamInfo, audioStream: AudioStreamInfo) { getOptions(videoStream: VideoStreamInfo, audioStream?: AudioStreamInfo) {
const options = { const options = {
inputOptions: this.getBaseInputOptions(), inputOptions: this.getBaseInputOptions(),
outputOptions: this.getBaseOutputOptions(videoStream, audioStream).concat('-v verbose'), outputOptions: this.getBaseOutputOptions(videoStream, audioStream).concat('-v verbose'),
@ -32,15 +32,21 @@ class BaseConfig implements VideoCodecSWConfig {
return []; return [];
} }
getBaseOutputOptions(videoStream: VideoStreamInfo, audioStream: AudioStreamInfo) { getBaseOutputOptions(videoStream: VideoStreamInfo, audioStream?: AudioStreamInfo) {
return [ const options = [
`-c:v:${videoStream.index} ${this.getVideoCodec()}`, `-c:v ${this.getVideoCodec()}`,
`-c:a:${audioStream.index} ${this.getAudioCodec()}`, `-c:a ${this.getAudioCodec()}`,
// Makes a second pass moving the moov atom to the // Makes a second pass moving the moov atom to the
// beginning of the file for improved playback speed. // beginning of the file for improved playback speed.
'-movflags faststart', '-movflags faststart',
'-fps_mode passthrough', '-fps_mode passthrough',
// explicitly selects the video stream instead of leaving it up to FFmpeg
`-map 0:${videoStream.index}`,
]; ];
if (audioStream) {
options.push(`-map 0:${audioStream.index}`);
}
return options;
} }
getFilterOptions(videoStream: VideoStreamInfo) { getFilterOptions(videoStream: VideoStreamInfo) {
@ -311,7 +317,7 @@ export class NVENCConfig extends BaseHWConfig {
return ['-init_hw_device cuda=cuda:0', '-filter_hw_device cuda']; return ['-init_hw_device cuda=cuda:0', '-filter_hw_device cuda'];
} }
getBaseOutputOptions(videoStream: VideoStreamInfo, audioStream: AudioStreamInfo) { getBaseOutputOptions(videoStream: VideoStreamInfo, audioStream?: AudioStreamInfo) {
return [ return [
// below settings recommended from https://docs.nvidia.com/video-technologies/video-codec-sdk/12.0/ffmpeg-with-nvidia-gpu/index.html#command-line-for-latency-tolerant-high-quality-transcoding // below settings recommended from https://docs.nvidia.com/video-technologies/video-codec-sdk/12.0/ffmpeg-with-nvidia-gpu/index.html#command-line-for-latency-tolerant-high-quality-transcoding
'-tune hq', '-tune hq',
@ -379,7 +385,7 @@ export class QSVConfig extends BaseHWConfig {
return ['-init_hw_device qsv=hw', '-filter_hw_device hw']; return ['-init_hw_device qsv=hw', '-filter_hw_device hw'];
} }
getBaseOutputOptions(videoStream: VideoStreamInfo, audioStream: AudioStreamInfo) { getBaseOutputOptions(videoStream: VideoStreamInfo, audioStream?: AudioStreamInfo) {
// recommended from https://github.com/intel/media-delivery/blob/master/doc/benchmarks/intel-iris-xe-max-graphics/intel-iris-xe-max-graphics.md // recommended from https://github.com/intel/media-delivery/blob/master/doc/benchmarks/intel-iris-xe-max-graphics/intel-iris-xe-max-graphics.md
const options = [ const options = [
'-g 256', '-g 256',

View file

@ -32,7 +32,6 @@ export class MediaRepository implements IMediaRepository {
async probe(input: string): Promise<VideoInfo> { async probe(input: string): Promise<VideoInfo> {
const results = await probe(input); const results = await probe(input);
return { return {
format: { format: {
formatName: results.format.format_name, formatName: results.format.format_name,

View file

@ -20,7 +20,7 @@ const probeStubDefaultVideoStream: VideoStreamInfo[] = [
]; ];
const probeStubDefaultAudioStream: AudioStreamInfo[] = [ const probeStubDefaultAudioStream: AudioStreamInfo[] = [
{ index: 0, codecName: 'aac', codecType: 'audio', frameCount: 100 }, { index: 1, codecName: 'aac', codecType: 'audio', frameCount: 100 },
]; ];
const probeStubDefault: VideoInfo = { const probeStubDefault: VideoInfo = {
@ -119,7 +119,7 @@ export const probeStub = {
}), }),
audioStreamMp3: Object.freeze<VideoInfo>({ audioStreamMp3: Object.freeze<VideoInfo>({
...probeStubDefault, ...probeStubDefault,
audioStreams: [{ index: 0, codecType: 'audio', codecName: 'aac', frameCount: 100 }], audioStreams: [{ index: 1, codecType: 'audio', codecName: 'aac', frameCount: 100 }],
}), }),
matroskaContainer: Object.freeze<VideoInfo>({ matroskaContainer: Object.freeze<VideoInfo>({
...probeStubDefault, ...probeStubDefault,