7

宝塔面板安装ffmpeg视频切片模块方法教程

 2 years ago
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.
neoserver,ios ssh client

宝塔面板安装ffmpeg视频切片模块方法教程

青山 2022-03-1110:01:54评论1263字

这里宝塔官方论坛提供的一键脚本安装,但是安装过程也非常漫长,慢慢等吧。

  1. wget http://download.bt.cn/install/ext/ffmpeg.sh && sh ffmpeg.sh

安装完后可输入以下命令是否安装成功。

  1. ffmpeg -version

3、网站应用

应用到网站需要在PHP×设置中取消掉 scandir,exec、system、shell_exec函数。

宝塔面板安装ffmpeg视频切片模块方法教程宝塔面板安装ffmpeg视频切片模块方法教程装好之后,PHP截图某一帧代码:
  1. 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代码示例:

  1. function ffmpeg_thumb_callback(){
  2. global $wpdb;
  3. $post_id = esc_sql($_POST['post_id']);
  4. $video = esc_sql($_POST['video']);
  5. $status = 0;
  6. $video = str_replace(home_url(),_MBT('child_site_root'),$video);
  7. exec('/usr/local/bin/ffmpeg -ss 00:00:01 -i '.$video.' '.$video.'.jpg -r 1 -vframes 1 -an -f mjpeg 1>/dev/null');
  8. $url = str_replace(_MBT('child_site_root'), home_url(), $video.'.jpg');
  9. update_post_meta($post_id,'_thumbnail_ext_url',$url);
  10. $status = 1;
  11. $result = array(
  12. 'status' => $status,
  13. 'url' => $url
  14. header('Content-type: application/json');
  15. echo json_encode($result);
  16. exit;
  17. add_action( 'wp_ajax_ffmpeg_thumb', 'ffmpeg_thumb_callback');

JS代码示例:

  1. jQuery(function($){
  2. $(".modown-ffmpeg").click(function(){
  3. var v = $("input[name='video']").val();
  4. var thata = $(this);
  5. if(v){
  6. thata.text("截图中...");
  7. $.post(ajaxurl, {
  8. "action": "ffmpeg_thumb",
  9. "post_id": thata.data("id"),
  10. "video": v
  11. }, function(result) {
  12. thata.text("视频获取截图");
  13. console.log(result);
  14. if(result.status){
  15. $("#thumbnail_ext_url").val(result.url);
  16. }else{
  17. alert("截图失败!");

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK