gpt4 book ai didi

javascript - 带有 JavaScript 的 ffmpeg 缩略图

转载 作者:行者123 更新时间:2023-12-04 23:26:39 25 4
gpt4 key购买 nike

我正在使用下面的代码从视频中生成缩略图。
它生成一张 4 帧的图像。问题是它不在帧之间寻找,所以 4 帧是相同的。我想我必须使用 select而不是 -ss但我不知道怎么做。

// - inPath: path to video file
// - outPath: path to thumbnail, no thumbnail will be generated when absent
// - count: number of thumbs to generate
self.exec = function (inPath, outPath, count, handler) {
var args = outPath ? [
'-i', inPath ,
'-f', 'image2',
'-vframes', count || 1,
'-aspect', '4:3',
'-filter:vf', 'scale=\'if(gt(a,4/3),128,-1)\':' +
'\'if(gt(a,4/3),-1,96)\',' +
'pad=w=128:h=97:x=(ow-iw)/2:y=(oh-ih)/2:color=black,tile=4x1',
'-y',
'-ss', '15',
outPath
] : [
'-i', inPath
];

最佳答案

我有这个工作。

mdata = ffprobe(function(metadata){ },inPath)

var parts = mdata['duration'].split(":");
var hours = parts[0];
var minutes = parts[1];
var seconds = parts[2];
var durationSec = 3600 * parseFloat(hours) + 60 * parseFloat(minutes) + parseFloat(seconds);

var distance = Math.round(durationSec/5);

var args = outPath ? [
'-ss', distance ,
'-i', inPath ,
'-f', 'image2',
'-vframes', count || 1,
'-aspect', '4:3',
'-filter:vf', 'select=\'isnan(prev_selected_t)+gte(t-prev_selected_t\\,'+ distance +')\',' + 'scale=\'if(gt(a,4/3),206,-1)\':' +
'\'if(gt(a,4/3),-1,154)\',' +
'pad=w=206:h=155:x=(ow-iw)/2:y=(oh-ih)/2:color=black,tile=4x1',
'-y',



outPath
] : [
'-i', inPath
];

关于javascript - 带有 JavaScript 的 ffmpeg 缩略图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43948389/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com