目录
php使用ffmpeg向视频中添加文字字幕,
首页 后端开发 php教程 php使用ffmpeg向视频中添加文字字幕,_PHP教程

php使用ffmpeg向视频中添加文字字幕,_PHP教程

Jul 12, 2016 am 08:52 AM
ffmpeg php 使用 字幕 特点 添加 视频

php使用ffmpeg向视频中添加文字字幕,

这篇文章主要介绍了PHP使用ffmpeg给视频增加字幕显示的方法,实例分析了php操作ffmpeg给视频增加字母的技巧,具有一定参考借鉴价值,需要的朋友可以参考下。

本文实例讲述了PHP使用ffmpeg给视频增加字幕显示的方法。分享给大家供大家参考。具体实现方法如下:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

<?php

$dir = './'; // set to current folder

if ($handle = opendir($dir)) {

 while(false!== ($file = readdir($handle))) {

 if ( is_file($dir.$file) ){

 if (preg_match("'\.(avi)$'", $file) ){

 $sub_file = str_ireplace(".avi", ".srt", $dir.$file);

 $idx_file = str_ireplace(".avi", ".idx", $dir.$file);

 $thumb_file = str_ireplace(".avi", ".jpg", $dir.$file);

 $out_file = str_ireplace(".avi", ".mp4", $dir.$file);

 flv_convert_get_thumb($dir.$file, $sub_file, $idx_file, $thumb_file, $out_file);

 }

 else{

 continue;

 }

 }

 }

 closedir($handle);

}

//flv_convert_get_thumb('input.avi', 'input.srt', 'output.jpg', 'output.ogm');

// code provided and updated by steve of phpsnaps ! thanks

// accepts:

// 1: the input video file

// 2: path to thumb jpg

// 3: path to transcoded mpeg?

function flv_convert_get_thumb($in, $in_sub, $in_idx, $out_thumb, $out_vid){

 // get thumbnail

 $cmd = 'ffmpeg -v 0 -y -i '.$in.' -vframes 1 -ss 250 -vcodec mjpeg -f rawvideo -s 286x160 -aspect 16:9 '.$out_thumb;

 $res = shell_exec($cmd);

 // $res is the output of the command

 // transcode video

$cmd = 'mencoder '.$in.' -o '.$out_vid.' -sub '.$in_sub.' -subfont-text-scale 3.0 -subpos 99 -af volume=10 -aspect 16:9 -of avi -noodml -ovc x264 -x264encop$

 $res = shell_exec($cmd);

}

?>

登录后复制

希望本文所述对大家的php程序设计有所帮助。

原文地址:http://www.manongjc.com/article/839.html

相关阅读:

php 源码之使用FFMPEG获取视频缩略图及视频总时长

php 截取视频中的一张图

php ffmpeg截取视频指定帧为图片

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1126844.htmlTechArticlephp使用ffmpeg向视频中添加文字字幕, 这篇文章主要介绍了PHP使用ffmpeg给视频增加字幕显示的方法,实例分析了php操作ffmpeg给视频增加字母的...
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热门文章

仓库:如何复兴队友
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒险:如何获得巨型种子
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
两个点博物馆:所有展览以及在哪里可以找到它们
3 周前 By 尊渡假赌尊渡假赌尊渡假赌

热门文章

仓库:如何复兴队友
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒险:如何获得巨型种子
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
两个点博物馆:所有展览以及在哪里可以找到它们
3 周前 By 尊渡假赌尊渡假赌尊渡假赌

热门文章标签

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

CakePHP 日期和时间 CakePHP 日期和时间 Sep 10, 2024 pm 05:27 PM

CakePHP 日期和时间

适用于 Ubuntu 和 Debian 的 PHP 8.4 安装和升级指南 适用于 Ubuntu 和 Debian 的 PHP 8.4 安装和升级指南 Dec 24, 2024 pm 04:42 PM

适用于 Ubuntu 和 Debian 的 PHP 8.4 安装和升级指南

CakePHP 文件上传 CakePHP 文件上传 Sep 10, 2024 pm 05:27 PM

CakePHP 文件上传

CakePHP 路由 CakePHP 路由 Sep 10, 2024 pm 05:25 PM

CakePHP 路由

讨论 CakePHP 讨论 CakePHP Sep 10, 2024 pm 05:28 PM

讨论 CakePHP

CakePHP 项目配置 CakePHP 项目配置 Sep 10, 2024 pm 05:25 PM

CakePHP 项目配置

CakePHP 快速指南 CakePHP 快速指南 Sep 10, 2024 pm 05:27 PM

CakePHP 快速指南

如何设置 Visual Studio Code (VS Code) 进行 PHP 开发 如何设置 Visual Studio Code (VS Code) 进行 PHP 开发 Dec 20, 2024 am 11:31 AM

如何设置 Visual Studio Code (VS Code) 进行 PHP 开发

See all articles