使用 Xuggler 将 MXF 转为 FLV

发布于 2024-12-05 21:13:25 字数 2511 浏览 0 评论 0原文

我正在尝试使用 Xuggler 将 mxf 文件转码为 flv 类型。

但我遇到了这个异常 -

2011-09-23 11:48:06,328 [main] WARN  com.xuggle.xuggler - Got error: picture is not of the same PixelType as this Coder expected (../../../../../../../csrc/com/xuggle/xuggler/StreamCoder.cpp:1204)

我的代码非常简单,看起来像这样 -

public static void main(String[] args) {

    // create a media reader
    IMediaReader mediaReader = ToolFactory.makeReader(inputFilename);

    // create a media writer
    IMediaWriter mediaWriter = ToolFactory.makeWriter(outputFilename,
            mediaReader);

    // add a writer to the reader, to create the output file
    mediaReader.addListener(mediaWriter);

    // create a media viewer with stats enabled
    // IMediaViewer mediaViewer = ToolFactory.makeViewer(true);

    // add a viewer to the reader, to see the decoded media
    // mediaReader.addListener(mediaViewer);

    // read and decode packets from the source file and
    // and dispatch decoded audio and video to the writer
    while (mediaReader.readPacket() == null)
        ;

}

它适用于 MP4 和 MOV 类型等文件。

请任何指点。

由于没有人回复并且我找不到任何解决方案,我决定使用 Java 中的命令参数。

我尝试了这个,但出现错误 -

public class FfmpegCommandTest {

public static void main(String args[]) {

    String commandStr[] = { "ffmpeg -f dv -i \"C:\temp\0001NY.MXF\" -ar 44100 -v codec libx264 -maxrate 2000k -bufsize 2000k -vf scale=\"iw/2:ih/2\" -strict experimental -vstats_file \"C:\nasir\progress.txt\" \"C:\temp\0001NYoutput-short1.mov\"" };
    // print the command to execute
    for (String x : commandStr) {
        System.out.print(x + " ");
    }

    // execute ffmpeg with the command generated by the previous segment
    try {
        ProcessBuilder proc =  new ProcessBuilder(commandStr);
        proc.directory(new File("C:\temp"));
        //proc.command(commandStr);
        proc.start();

    } catch (IOException ex) {          
        ex.getMessage();
        ex.printStackTrace();
    }
}
}

错误是

    The system cannot find the file specified
    at java.lang.ProcessBuilder.start(Unknown Source)
    at com.xuggle.xuggler.demos.FfmpegCommandTest.main(FfmpegCommandTest.java:21)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(Unknown Source)
    at java.lang.ProcessImpl.start(Unknown Source)

I am trying to transcode an mxf file to flv type using Xuggler.

But I am getting this exception -

2011-09-23 11:48:06,328 [main] WARN  com.xuggle.xuggler - Got error: picture is not of the same PixelType as this Coder expected (../../../../../../../csrc/com/xuggle/xuggler/StreamCoder.cpp:1204)

My code is very simple and it looks like this -

public static void main(String[] args) {

    // create a media reader
    IMediaReader mediaReader = ToolFactory.makeReader(inputFilename);

    // create a media writer
    IMediaWriter mediaWriter = ToolFactory.makeWriter(outputFilename,
            mediaReader);

    // add a writer to the reader, to create the output file
    mediaReader.addListener(mediaWriter);

    // create a media viewer with stats enabled
    // IMediaViewer mediaViewer = ToolFactory.makeViewer(true);

    // add a viewer to the reader, to see the decoded media
    // mediaReader.addListener(mediaViewer);

    // read and decode packets from the source file and
    // and dispatch decoded audio and video to the writer
    while (mediaReader.readPacket() == null)
        ;

}

It works for files like MP4 and MOV types.

Any pointers please.

Since no one replied and I could not find any solution, I decided to do using command arguments from Java.

I tried this and I am getting errors -

public class FfmpegCommandTest {

public static void main(String args[]) {

    String commandStr[] = { "ffmpeg -f dv -i \"C:\temp\0001NY.MXF\" -ar 44100 -v codec libx264 -maxrate 2000k -bufsize 2000k -vf scale=\"iw/2:ih/2\" -strict experimental -vstats_file \"C:\nasir\progress.txt\" \"C:\temp\0001NYoutput-short1.mov\"" };
    // print the command to execute
    for (String x : commandStr) {
        System.out.print(x + " ");
    }

    // execute ffmpeg with the command generated by the previous segment
    try {
        ProcessBuilder proc =  new ProcessBuilder(commandStr);
        proc.directory(new File("C:\temp"));
        //proc.command(commandStr);
        proc.start();

    } catch (IOException ex) {          
        ex.getMessage();
        ex.printStackTrace();
    }
}
}

the error is

    The system cannot find the file specified
    at java.lang.ProcessBuilder.start(Unknown Source)
    at com.xuggle.xuggler.demos.FfmpegCommandTest.main(FfmpegCommandTest.java:21)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(Unknown Source)
    at java.lang.ProcessImpl.start(Unknown Source)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嘴硬脾气大 2024-12-12 21:13:25

对于命令内容:使用 \"C:\\temp\\0001NY.MXF\" 而不是 \"C:\temp\0001NY.MXF\"。

请参阅双反斜杠。

for the command stuff: use \"C:\\temp\\0001NY.MXF\" instead of \"C:\temp\0001NY.MXF\".

See double back-slash.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文