jbilcke-hf HF staff commited on
Commit
cca0a16
1 Parent(s): 35db0ae
Files changed (2) hide show
  1. README.md +5 -0
  2. src/index.mts +11 -3
README.md CHANGED
@@ -18,6 +18,11 @@ Campose API is a REST API to generate camera pose data from a set of images or a
18
 
19
  ## Manual testing (using CURL)
20
 
 
 
 
 
 
21
  Generating poses from a local video:
22
 
23
  ```bash:
 
18
 
19
  ## Manual testing (using CURL)
20
 
21
+ Converting a video to images:
22
+
23
+ ```
24
+ ffmpeg -i in.mp4 %04d.jpg
25
+ ```
26
  Generating poses from a local video:
27
 
28
  ```bash:
src/index.mts CHANGED
@@ -133,12 +133,20 @@ async function handleFileStorage(dataFile: fileUpload.UploadedFile | Buffer, pro
133
  }
134
 
135
  function generateImagesFromData(imageFolder: string, filePath: string) {
 
136
  return new Promise<void>((resolve, reject) => {
137
  ffmpeg(filePath)
138
- .outputOptions('-vf', 'fps=1')
 
139
  .output(path.join(imageFolder, 'image-%03d.png'))
140
- .on('end', resolve)
141
- .on('error', reject)
 
 
 
 
 
 
142
  .run()
143
  });
144
  }
 
133
  }
134
 
135
  function generateImagesFromData(imageFolder: string, filePath: string) {
136
+ console.log(`generateImagesFromData("${imageFolder}", "${filePath}")`);
137
  return new Promise<void>((resolve, reject) => {
138
  ffmpeg(filePath)
139
+ // .outputOptions('-vf', 'fps=1')
140
+ .outputOptions('-i')
141
  .output(path.join(imageFolder, 'image-%03d.png'))
142
+ .on('end', () => {
143
+ console.log('Image generation finished successfully.');
144
+ resolve();
145
+ })
146
+ .on('error', (err) => {
147
+ console.log(`failed to generate the images: ${err}`)
148
+ reject(err);
149
+ })
150
  .run()
151
  });
152
  }