7
宝塔面板安装ffmpeg视频切片模块方法教程
source link: https://www.huhexian.com/31331.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
宝塔面板安装ffmpeg视频切片模块方法教程
2022-03-1110:01:54评论1263字
这里宝塔官方论坛提供的一键脚本安装,但是安装过程也非常漫长,慢慢等吧。
- wget http://download.bt.cn/install/ext/ffmpeg.sh && sh ffmpeg.sh
安装完后可输入以下命令是否安装成功。
- ffmpeg -version
3、网站应用
应用到网站需要在PHP×设置中取消掉 scandir,exec、system、shell_exec函数。
装好之后,PHP截图某一帧代码:- exec('/usr/local/bin/ffmpeg -ss 00:00:01 -i ./test.mp4 ./test.jpg -r 1 -vframes 1 -an -f mjpeg 1>/dev/null');
PHP代码示例:
- function ffmpeg_thumb_callback(){
- global $wpdb;
- $post_id = esc_sql($_POST['post_id']);
- $video = esc_sql($_POST['video']);
- $status = 0;
- $video = str_replace(home_url(),_MBT('child_site_root'),$video);
- exec('/usr/local/bin/ffmpeg -ss 00:00:01 -i '.$video.' '.$video.'.jpg -r 1 -vframes 1 -an -f mjpeg 1>/dev/null');
- $url = str_replace(_MBT('child_site_root'), home_url(), $video.'.jpg');
- update_post_meta($post_id,'_thumbnail_ext_url',$url);
- $status = 1;
- $result = array(
- 'status' => $status,
- 'url' => $url
- header('Content-type: application/json');
- echo json_encode($result);
- exit;
- add_action( 'wp_ajax_ffmpeg_thumb', 'ffmpeg_thumb_callback');
JS代码示例:
- jQuery(function($){
- $(".modown-ffmpeg").click(function(){
- var v = $("input[name='video']").val();
- var thata = $(this);
- if(v){
- thata.text("截图中...");
- $.post(ajaxurl, {
- "action": "ffmpeg_thumb",
- "post_id": thata.data("id"),
- "video": v
- }, function(result) {
- thata.text("视频获取截图");
- console.log(result);
- if(result.status){
- $("#thumbnail_ext_url").val(result.url);
- }else{
- alert("截图失败!");
历史上的今天
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK