ffmpeg-progress 1.8.0 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +25 -3
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -78,8 +78,26 @@ function onProgress(args) {
|
|
|
78
78
|
(args.currentSeconds / (passedTime / 1000)));
|
|
79
79
|
writeProgress(`progress=${progress} speed=${speed}x elapsed=${elapsed} eta=${eta}`);
|
|
80
80
|
}
|
|
81
|
+
function timestamp() {
|
|
82
|
+
let date = new Date();
|
|
83
|
+
let y = date.getFullYear();
|
|
84
|
+
let m = (date.getMonth() + 1).toString().padStart(2, '0');
|
|
85
|
+
let d = date.getDate().toString().padStart(2, '0');
|
|
86
|
+
let H = date.getHours().toString().padStart(2, '0');
|
|
87
|
+
let M = date.getMinutes().toString().padStart(2, '0');
|
|
88
|
+
let S = date.getSeconds().toString().padStart(2, '0');
|
|
89
|
+
return `${y}-${m}-${d} ${H}:${M}:${S}`;
|
|
90
|
+
}
|
|
91
|
+
function logVerbose(message) {
|
|
92
|
+
console.log(`[${timestamp()}] ${message}`);
|
|
93
|
+
}
|
|
81
94
|
if (args.length == 0) {
|
|
82
|
-
|
|
95
|
+
if (verbose) {
|
|
96
|
+
logVerbose('reading ffmpeg output from pipe...');
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
writeProgress('reading ffmpeg output from pipe...');
|
|
100
|
+
}
|
|
83
101
|
(0, core_1.attachStream)({
|
|
84
102
|
stream: process.stdin,
|
|
85
103
|
onData: checkOverwrite,
|
|
@@ -87,7 +105,7 @@ if (args.length == 0) {
|
|
|
87
105
|
}).on('end', () => {
|
|
88
106
|
process.stdout.write('\n');
|
|
89
107
|
if (verbose) {
|
|
90
|
-
|
|
108
|
+
logVerbose('end of ffmpeg output.');
|
|
91
109
|
}
|
|
92
110
|
});
|
|
93
111
|
}
|
|
@@ -104,6 +122,7 @@ else {
|
|
|
104
122
|
}
|
|
105
123
|
}
|
|
106
124
|
console.log('> ' + cmd);
|
|
125
|
+
logVerbose('starting ffmpeg process...');
|
|
107
126
|
}
|
|
108
127
|
let childProcess = (0, child_process_1.spawn)('ffmpeg', args, {
|
|
109
128
|
stdio: ['inherit', 'pipe', 'pipe'],
|
|
@@ -116,10 +135,13 @@ else {
|
|
|
116
135
|
.then(() => {
|
|
117
136
|
process.stdout.write('\n');
|
|
118
137
|
if (verbose) {
|
|
119
|
-
|
|
138
|
+
logVerbose('ffmpeg process finished.');
|
|
120
139
|
}
|
|
121
140
|
})
|
|
122
141
|
.catch(error => {
|
|
142
|
+
if (verbose) {
|
|
143
|
+
logVerbose('ffmpeg process failed.');
|
|
144
|
+
}
|
|
123
145
|
process.stderr.write('\n');
|
|
124
146
|
for (let line of errorLines) {
|
|
125
147
|
console.error(line);
|