使用FFmpeg截取视频封面图片(完整例子)

先看看截图:

 

下面是代码,使用的是aardio写的,直接可以运行,ffmpeg直接区官方下载.

import win.ui;
import fsys.dlg;
/*DSG{undefined{*/
mainForm = win.form(text="都客视频封面工具";right=600;bottom=400)
mainForm.add(
btnClearList={cls="button";text="清空";left=482;top=195;right=547;bottom=223;z=6};
button3={cls="button";text="浏览";left=309;top=275;right=376;bottom=300;z=4};
button4={cls="button";text="开始处理";left=400;top=267;right=499;bottom=306;z=5};
groupbox={cls="groupbox";text="工作区(拖拽文件或者文件夹到列表,支持mp4和avi格式)";left=16;top=21;right=568;bottom=376;edge=1;z=1};
listcol={cls="listview";left=32;top=48;right=469;bottom=225;acceptfiles=1;edge=1;z=2};
txtOutDir={cls="edit";left=36;top=276;right=297;bottom=302;edge=1;z=3}
)
/*}}*/

import process;
import process.popen;

mainForm.listcol.insertColumn("列名",150);
mainForm.listcol.insertColumn("文件路径",-1);

mainForm.button3.oncommand = function(id,event){undefined
//输出out目录
mainForm.txtOutDir.text = fsys.dlg.opendir(,mainForm.hwnd,"请选择生成后文件存放的目录")
}
var htfile={};

mainForm.button4.oncommand = function(id,event)
{
for(k,v in htfile)
{
var para=string.format("-i %s -y -r 1 -ss 00:00:02 -vframes 1 %s",v,mainForm.txtOutDir.text+"\\"+k+".jpg");
process.popen("\res\ffmpeg.exe",para);
}
win.msgbox("操作成功!","温馨提示");
}
//拖放会触发onDropFiles事件
mainForm.onDropFiles = function(files)
{
var cur=mainForm.listcol.count;
for(k,v in files)
{
if(!table.find(htfile,v))
{undefined
if(fsys.getExtensionName(v)=="mp4" or fsys.getExtensionName(v)=="avi")
{
mainForm.listcol.addItem({cur+k,v});
table.push(htfile,v);
}
}
}
}

mainForm.btnClearList.oncommand = function(id,event){undefined
mainForm.listcol.clear();
htfile={};
}

mainForm.show();
return win.loopMessage();

 

posted @ 2022-02-09 12:24  dukey's  阅读(663)  评论(1编辑  收藏  举报