Skip to content

Commit

Permalink
support x264 encoder
Browse files Browse the repository at this point in the history
  • Loading branch information
Last-Order committed Apr 9, 2020
1 parent c0b5186 commit 531d6d5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/recipes/static_image_video_v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class StaticImageVideoV2 extends BaseRecipe {
return false;
}
for (let index = 0; index < files.length; index++) {
const audioRegex = new RegExp('^.+(mp3|flac|aac|alac|wav)$', 'i')
const audioRegex = new RegExp('^.+(mp3|flac|aac|alac|wav|m4a|ac3|ogg|wma|opus|mp4)$', 'i')
const isAudio = audioRegex.test(files[index].path);
if (!isAudio && index !== imageFileIndex) {
return false;
Expand Down Expand Up @@ -52,17 +52,17 @@ export default class StaticImageVideoV2 extends BaseRecipe {
type: 'pipe_encode',
pipe: 'smg',
input: imageFile.path,
output: `${audioFile.path}.smg.mp4`,
output: `${audioFile.path}.smg.264`,
duration: Math.ceil(audioDuration)
}, {
stepName: '混流',
type: 'execute',
command: '"${ffmpeg}"' + ` -i "${audioFile.path + '.smg.mp4'}" -i "${audioFile.path}" -c:v copy -c:a aac -b:a 320k "${audioFile.path + '.smg.mux.mp4'}"`
command: '"${ffmpeg}"' + ` -i "${audioFile.path + '.smg.264'}" -i "${audioFile.path}" -c:v copy -c:a aac -b:a 320k "${audioFile.path + '.smg.mux.mp4'}"`
}, {
stepName: '清理文件',
type: 'delete',
files: [
audioFile.path + '.smg.mp4',
audioFile.path + '.smg.264',
]
}]
})
Expand Down
4 changes: 2 additions & 2 deletions src/services/task_runners/encoders/x264.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import BaseEncoder from './base_encoder';

class X264 extends BaseEncoder {
static encoderName = 'nvencc';
static encoderName = 'x264';
constructor(input, output, settings) {
super(input, output, settings);
this.commandTemplate = '${x264} "${input}" -o "${output}" ';
this.commandTemplate = '${x264} -o "${output}" "${input}"';
this.encodedFrames = 0;
this.progress = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/task_runners/pipes/smgpipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class SMGPipe extends EventEmitter {
static commandTemplates = {
'nvencc': '"${smg}" --input "${input}" -d "${duration}" -c | "${nvencc}" --y4m -i - -o "${output}"',
'qsvencc': '"${smg}" --input "${input}" -d "${duration}" -c | "${qsvencc}" --y4m -i - -o "${output}"',
'x264': '"${smg}" --input "${input}" -d "${duration}" -c | "${x264}" --demuxer y4m -i - -o "${output}"'
'x264': '"${smg}" --input "${input}" -d "${duration}" -c | "${x264}" --demuxer y4m -o "${output}" -'
};
constructor(input, output, duration, encoder, encoderSettings) {
super();
Expand Down

0 comments on commit 531d6d5

Please sign in to comment.