1

我正在建立一个用 PHP 构建的 CMS,现在我需要添加一个部分,用户可以将视频从 FLV 转换为 MP4 格式。我已经搜索了脚本和解决方案,但没有任何效果。我准备为该软件付费,但“Aviberry”软件售价 5000 美元,而“sothinkmedia”在 Linux 服务器上无法正常运行。如果有人有一些肯定会起作用的东西,我将不胜感激所有建议。

4

2 回答 2

2

MPlayer的mencoder部分应该可以做到这一点,或者试试ffmpeg。两者都可以从命令行(或脚本)调用以进行转换。

于 2012-05-16T13:18:06.907 回答
1

在 java 代码中尝试 ffmpeg 命令,或者使用 Xuggler API 的另一个解决方案,它将视频文件转换为任何扩展名。

/* Sample Code For converting Videos in server side */

import java.io.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;


public class Quality {

public static void main(String args[]) {

    String s = null;

    try {

    // run the Unix "ps -ef" command
        // using the Runtime exec method:
        Process p = Runtime.getRuntime().exec("ffmpeg -i /home/praveen/videos/Oracle.mp4 
-vcodec libvpx -acodec libvorbis -f webm /home/praveen/videos/Oracle.webm");
        //Process p = Runtime.getRuntime().exec("ffmpeg -i /home/praveen/resize
 images/Videos/RaymondMadetoMeasure.mp4 -vcodec libvpx -acodec libvorbis -f webm 
 /home/praveen/resize images/Videos/Raymond.webm");

        BufferedReader stdInput = new BufferedReader(new 
             InputStreamReader(p.getInputStream()));

        BufferedReader stdError = new BufferedReader(new 
             InputStreamReader(p.getErrorStream()));

        // read the output from the command
        System.out.println("Here is the standard output of the command:\n");
        while ((s = stdInput.readLine()) != null) {
            System.out.println(s);
        }

        // read any errors from the attempted command
        System.out.println("Here is the standard error of the command (if any):\n");
        while ((s = stdError.readLine()) != null) {
            System.out.println(s);
        }

        System.exit(0);
    }
    catch (IOException e) {
        System.out.println("exception happened - here's what I know: ");
        e.printStackTrace();
        System.exit(-1);
    }
 }
 }
于 2014-04-24T07:20:33.133 回答