Update video_processing.yaml
Browse files- video_processing.yaml +86 -13
video_processing.yaml
CHANGED
|
@@ -1,30 +1,29 @@
|
|
| 1 |
_id: video_processing
|
| 2 |
-
version: 2
|
| 3 |
-
title: en=Video processing;ru=Работа с видео
|
| 4 |
-
description: Using FFmpeg process videos
|
| 5 |
-
readme: "Fix ffmpeg fluent"
|
| 6 |
author: Anton Breslavskii | https://github.com/breslavsky
|
|
|
|
|
|
|
|
|
|
| 7 |
url: https://huggingface.co/PiperMy/Node-Packages/resolve/main/video_processing.yaml
|
|
|
|
| 8 |
nodes:
|
| 9 |
split_video_by_frames:
|
| 10 |
_id: split_video_by_frames
|
| 11 |
arrange:
|
| 12 |
-
x:
|
| 13 |
-
y:
|
| 14 |
category:
|
| 15 |
-
_id:
|
| 16 |
-
title: en=Video processing;ru=Обработка видео
|
| 17 |
-
costs: ""
|
| 18 |
environment: {}
|
| 19 |
inputs:
|
| 20 |
video:
|
| 21 |
order: 1
|
| 22 |
-
title:
|
| 23 |
type: video
|
| 24 |
required: true
|
| 25 |
fps:
|
| 26 |
order: 2
|
| 27 |
-
title: Frame rate
|
| 28 |
type: integer
|
| 29 |
min: 1
|
| 30 |
max: 60
|
|
@@ -32,7 +31,7 @@ nodes:
|
|
| 32 |
default: 12
|
| 33 |
outputs:
|
| 34 |
frames:
|
| 35 |
-
title: Frames
|
| 36 |
type: image[]
|
| 37 |
package: video_processing
|
| 38 |
script: |-
|
|
@@ -80,4 +79,78 @@ nodes:
|
|
| 80 |
}
|
| 81 |
source: catalog
|
| 82 |
title: en=Split video by frames;ru=Разбить видео по кадрам
|
| 83 |
-
version:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
_id: video_processing
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
author: Anton Breslavskii | https://github.com/breslavsky
|
| 3 |
+
description: Using FFmpeg process videos
|
| 4 |
+
readme: Fix ffmpeg fluent
|
| 5 |
+
title: en=Video processing;ru=Работа с видео
|
| 6 |
url: https://huggingface.co/PiperMy/Node-Packages/resolve/main/video_processing.yaml
|
| 7 |
+
version: 2
|
| 8 |
nodes:
|
| 9 |
split_video_by_frames:
|
| 10 |
_id: split_video_by_frames
|
| 11 |
arrange:
|
| 12 |
+
x: 120
|
| 13 |
+
y: 120
|
| 14 |
category:
|
| 15 |
+
_id: video_processing
|
| 16 |
+
title: "title: en=Video processing;ru=Обработка видео"
|
|
|
|
| 17 |
environment: {}
|
| 18 |
inputs:
|
| 19 |
video:
|
| 20 |
order: 1
|
| 21 |
+
title: en=Video;ru=Видео
|
| 22 |
type: video
|
| 23 |
required: true
|
| 24 |
fps:
|
| 25 |
order: 2
|
| 26 |
+
title: en=Frame rate;ru=Частота кадров
|
| 27 |
type: integer
|
| 28 |
min: 1
|
| 29 |
max: 60
|
|
|
|
| 31 |
default: 12
|
| 32 |
outputs:
|
| 33 |
frames:
|
| 34 |
+
title: en=Frames;ru=Кадры
|
| 35 |
type: image[]
|
| 36 |
package: video_processing
|
| 37 |
script: |-
|
|
|
|
| 79 |
}
|
| 80 |
source: catalog
|
| 81 |
title: en=Split video by frames;ru=Разбить видео по кадрам
|
| 82 |
+
version: 1
|
| 83 |
+
join_frames_to_video:
|
| 84 |
+
_id: join_frames_to_video
|
| 85 |
+
arrange:
|
| 86 |
+
x: 480
|
| 87 |
+
y: 120
|
| 88 |
+
category:
|
| 89 |
+
_id: video_processing
|
| 90 |
+
title: "title: en=Video processing;ru=Обработка видео"
|
| 91 |
+
execution: deferred
|
| 92 |
+
inputs:
|
| 93 |
+
frames:
|
| 94 |
+
order: 1
|
| 95 |
+
title: en=Frames;ru=Кадры
|
| 96 |
+
type: image[]
|
| 97 |
+
required: true
|
| 98 |
+
fps:
|
| 99 |
+
order: 2
|
| 100 |
+
title: en=Frame rate;ru=Частота кадров
|
| 101 |
+
type: integer
|
| 102 |
+
min: 1
|
| 103 |
+
max: 60
|
| 104 |
+
step: 1
|
| 105 |
+
default: 12
|
| 106 |
+
outputs:
|
| 107 |
+
video:
|
| 108 |
+
title: en=Video;ru=Видео
|
| 109 |
+
type: video
|
| 110 |
+
package: video_processing
|
| 111 |
+
script: |-
|
| 112 |
+
export async function run({ inputs }) {
|
| 113 |
+
const { frames, fps = 12 } = inputs;
|
| 114 |
+
|
| 115 |
+
const { FatalError, NextNode } = DEFINITIONS;
|
| 116 |
+
const ffmpeg = require('fluent-ffmpeg');
|
| 117 |
+
const path = require('path');
|
| 118 |
+
const fs = require('fs/promises');
|
| 119 |
+
|
| 120 |
+
let output;
|
| 121 |
+
|
| 122 |
+
await useTempFolder(async (tmpFolder) => {
|
| 123 |
+
|
| 124 |
+
const buffers = (await Promise.all(frames.map(frame => download(frame)))).map(({ data }) => data);
|
| 125 |
+
for (let i = 0; i < buffers.length; i++) {
|
| 126 |
+
const fileName = path.join(tmpFolder, `${String(i).padStart(5, '0')}.jpg`);
|
| 127 |
+
await fs.writeFile(fileName, buffers[i]);
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
const outputPath = path.join(tmpFolder, 'output.mp4');
|
| 131 |
+
|
| 132 |
+
await new Promise((resolve, reject) => {
|
| 133 |
+
ffmpeg()
|
| 134 |
+
.input(path.join(tmpFolder, '%05d.jpg'))
|
| 135 |
+
.inputFPS(fps)
|
| 136 |
+
.outputFPS(fps)
|
| 137 |
+
.outputOptions([
|
| 138 |
+
'-c:v libx264',
|
| 139 |
+
'-pix_fmt yuv420p',
|
| 140 |
+
'-crf 23'
|
| 141 |
+
])
|
| 142 |
+
.output(outputPath)
|
| 143 |
+
.on('start', cmd => console.log(cmd))
|
| 144 |
+
.on('end', resolve)
|
| 145 |
+
.on('error', err => reject(new FatalError(err)))
|
| 146 |
+
.run();
|
| 147 |
+
});
|
| 148 |
+
|
| 149 |
+
output = await fs.readFile(outputPath);
|
| 150 |
+
});
|
| 151 |
+
|
| 152 |
+
return NextNode.from({ outputs: { video: output } });
|
| 153 |
+
}
|
| 154 |
+
source: catalog
|
| 155 |
+
title: en=Join frames to video;ru=Собрать кадры в видео
|
| 156 |
+
version: 1
|