image-video-optimizer 1.1.1 → 1.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "image-video-optimizer",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "CLI tool to optimize images and videos with configurable resize and compression settings",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -75,11 +75,16 @@ class VideoProcessor {
75
75
  ffmpegCommand = ffmpegCommand.videoCodec('libx264').audioCodec('aac');
76
76
  }
77
77
 
78
+ // Add input/output options with proper quoting
79
+ ffmpegCommand = ffmpegCommand.inputOptions(['-fflags', '+genpts']);
80
+ ffmpegCommand = ffmpegCommand.outputOptions(['-crf', '23', '-preset', 'medium']);
81
+ ffmpegCommand = ffmpegCommand.format('mp4');
82
+ ffmpegCommand = ffmpegCommand.output(tempPath);
83
+
78
84
  ffmpegCommand
79
- .outputOptions('-crf 23')
80
- .outputOptions('-preset medium')
81
- .format('mp4')
82
- .output(tempPath)
85
+ .on('start', (commandLine) => {
86
+ console.log(`FFmpeg command: ${commandLine}`);
87
+ })
83
88
  .on('end', () => {
84
89
  const compressionResult = this.checkCompression(inputPath, tempPath);
85
90
 
@@ -103,6 +108,7 @@ class VideoProcessor {
103
108
  })
104
109
  .on('error', (err) => {
105
110
  console.error(`Error processing video ${inputPath}:`, err.message);
111
+ console.error(`FFmpeg stderr: ${err.stderr || 'No stderr available'}`);
106
112
  if (fs.existsSync(tempPath)) {
107
113
  fs.unlinkSync(tempPath);
108
114
  }
@@ -113,7 +119,7 @@ class VideoProcessor {
113
119
  }
114
120
 
115
121
  let ffmpegCommand = ffmpeg(inputPath);
116
-
122
+
117
123
  if (needsResize) {
118
124
  const newHeight = Math.round((maxWidth / videoStream.width) * videoStream.height);
119
125
  ffmpegCommand = ffmpegCommand.videoFilters(`scale=${maxWidth}:${newHeight}`);
@@ -134,11 +140,15 @@ class VideoProcessor {
134
140
  ffmpegCommand = ffmpegCommand.videoCodec('libx264').audioCodec('aac');
135
141
  }
136
142
 
143
+ ffmpegCommand = ffmpegCommand.inputOptions(['-fflags', '+genpts']);
144
+ ffmpegCommand = ffmpegCommand.outputOptions(['-crf', '23', '-preset', 'medium']);
145
+ ffmpegCommand = ffmpegCommand.format('mp4');
146
+ ffmpegCommand = ffmpegCommand.output(outputPath);
147
+
137
148
  ffmpegCommand
138
- .outputOptions('-crf 23')
139
- .outputOptions('-preset medium')
140
- .format('mp4')
141
- .output(outputPath)
149
+ .on('start', (commandLine) => {
150
+ console.log(`FFmpeg command: ${commandLine}`);
151
+ })
142
152
  .on('end', () => {
143
153
  const compressionResult = this.checkCompression(inputPath, outputPath);
144
154
 
@@ -159,6 +169,7 @@ class VideoProcessor {
159
169
  })
160
170
  .on('error', (err) => {
161
171
  console.error(`Error processing video ${inputPath}:`, err.message);
172
+ console.error(`FFmpeg stderr: ${err.stderr || 'No stderr available'}`);
162
173
  if (fs.existsSync(outputPath)) {
163
174
  fs.unlinkSync(outputPath);
164
175
  }