破译 Xuggle/ffmpeg 错误(新手)

发布于 2024-09-12 08:18:33 字数 2508 浏览 9 评论 0原文

我最近开始与 Xuggle 合作,将各种格式的视频文件转换为相应的 FLV(通过 jwplayer 在我们的网站上播放)。我使用的代码非常简单;本质上是他们在基本视频转换教程中展示的内容:

IMediaReader reader = ToolFactory.makeReader(file.getPath());
reader.addListener(ToolFactory.makeWriter(tempFileName, reader));

while (reader.readPacket() == null)
;

这对于我尝试过的大约 50% 的视频效果很好。但是,我在某些视频(我遇到的所有 .MP4 以及一些 .MOV)中遇到以下错误,

Caused by: java.lang.RuntimeException: Error Operation not permitted, failed to write header to container com.xuggle.xuggler.IContainer@-635072136[url:/tmp/1280786368521.flv;type:WRITE;format:com.xuggle.xuggler.IContainerFormat@-631842520[oname:flv;olongname:FLV format;omimetype:video/x-flv;oextensions:flv;];] while establishing stream com.xuggle.xuggler.IStream@-615272544[index:1;id:2;streamcoder:com.xuggle.xuggler.IStreamCoder@-677475184[codec=com.xuggle.xuggler.ICodec@-635131032[type=CODEC_TYPE_AUDIO;id=CODEC_ID_MP3;name=libmp3lame;];time base=1/48000;frame rate=0/0;sample rate=48000;channels=2;];framerate:0/0;timebase:1/90000;direction:OUTBOUND;]
        at com.xuggle.mediatool.MediaWriter.getStream(MediaWriter.java:1065)
        at com.xuggle.mediatool.MediaWriter.encodeAudio(MediaWriter.java:837)
        at com.xuggle.mediatool.MediaWriter.onAudioSamples(MediaWriter.java:1448)
        at com.xuggle.mediatool.AMediaToolMixin.onAudioSamples(AMediaToolMixin.java:89)
        at com.xuggle.mediatool.MediaReader.dispatchAudioSamples(MediaReader.java:628)
        at com.xuggle.mediatool.MediaReader.decodeAudio(MediaReader.java:555)
        at com.xuggle.mediatool.MediaReader.readPacket(MediaReader.java:469)
        ... 10 more

我很难确定错误的根本原因是否与 Xuggle/ffmpeg/ 有关跛脚/等等。安装,或者我的代码是否有问题。

我认为第一步是破译错误日志并使用该信息尝试使用本机 ffmpeg 调用转换视频。如果可行,我认为有理由相信这些组件已正确安装?

因此,对于像这样的日志消息:

Error Operation not permitted, failed to write header to container com.xuggle.xuggler.IContainer@-635072136
[url:/tmp/1280786368521.flv;type:WRITE;format:com.xuggle.xuggler.IContainerFormat@-631842520[oname:flv;olongname:FLV format;omimetype:video/x-flv;oextensions:flv;];] 

while establishing stream com.xuggle.xuggler.IStream@-615272544
[index:1;id:2;streamcoder:com.xuggle.xuggler.IStreamCoder@-677475184[codec=com.xuggle.xuggler.ICodec@-635131032[type=CODEC_TYPE_AUDIO;id=CODEC_ID_MP3;name=libmp3lame;];time base=1/48000;frame rate=0/0;sample rate=48000;channels=2;];framerate:0/0;timebase:1/90000;direction:OUTBOUND;]

我如何将其转换为 ffmpeg 命令?

对于这个 Xuggle 新手,还有其他调试技巧吗?

I've recently started working with Xuggle to convert video files of various formats into corresponding FLVs (to be played on our site via jwplayer). The code I'm using is trivially simple; essentially what they show for the basic video conversion tutorial:

IMediaReader reader = ToolFactory.makeReader(file.getPath());
reader.addListener(ToolFactory.makeWriter(tempFileName, reader));

while (reader.readPacket() == null)
;

This works well for about 50% of the videos I've attempted. However, I get the following error for some videos (all .MP4s I've come across, as well as some .MOVs)

Caused by: java.lang.RuntimeException: Error Operation not permitted, failed to write header to container com.xuggle.xuggler.IContainer@-635072136[url:/tmp/1280786368521.flv;type:WRITE;format:com.xuggle.xuggler.IContainerFormat@-631842520[oname:flv;olongname:FLV format;omimetype:video/x-flv;oextensions:flv;];] while establishing stream com.xuggle.xuggler.IStream@-615272544[index:1;id:2;streamcoder:com.xuggle.xuggler.IStreamCoder@-677475184[codec=com.xuggle.xuggler.ICodec@-635131032[type=CODEC_TYPE_AUDIO;id=CODEC_ID_MP3;name=libmp3lame;];time base=1/48000;frame rate=0/0;sample rate=48000;channels=2;];framerate:0/0;timebase:1/90000;direction:OUTBOUND;]
        at com.xuggle.mediatool.MediaWriter.getStream(MediaWriter.java:1065)
        at com.xuggle.mediatool.MediaWriter.encodeAudio(MediaWriter.java:837)
        at com.xuggle.mediatool.MediaWriter.onAudioSamples(MediaWriter.java:1448)
        at com.xuggle.mediatool.AMediaToolMixin.onAudioSamples(AMediaToolMixin.java:89)
        at com.xuggle.mediatool.MediaReader.dispatchAudioSamples(MediaReader.java:628)
        at com.xuggle.mediatool.MediaReader.decodeAudio(MediaReader.java:555)
        at com.xuggle.mediatool.MediaReader.readPacket(MediaReader.java:469)
        ... 10 more

I'm having a hard time determining if the root cause for the error is related to the Xuggle/ffmpeg/lame/etc. installation, or whether there's an issue with my code.

I figure the first step is deciphering the error log and using that info to try to convert the video using native ffmpeg calls. If that works, I assume it's reasonable to believe that those components are installed correctly?

So for a log message like:

Error Operation not permitted, failed to write header to container com.xuggle.xuggler.IContainer@-635072136
[url:/tmp/1280786368521.flv;type:WRITE;format:com.xuggle.xuggler.IContainerFormat@-631842520[oname:flv;olongname:FLV format;omimetype:video/x-flv;oextensions:flv;];] 

while establishing stream com.xuggle.xuggler.IStream@-615272544
[index:1;id:2;streamcoder:com.xuggle.xuggler.IStreamCoder@-677475184[codec=com.xuggle.xuggler.ICodec@-635131032[type=CODEC_TYPE_AUDIO;id=CODEC_ID_MP3;name=libmp3lame;];time base=1/48000;frame rate=0/0;sample rate=48000;channels=2;];framerate:0/0;timebase:1/90000;direction:OUTBOUND;]

how would I translate that to a ffmpeg command?

any other debugging tips for this Xuggle newbie?

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

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

发布评论

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

评论(2

永言不败 2024-09-19 08:18:33

问题解决了。这是因为 FLV 仅支持采样率为 44.1、22.05 和 22.05 的音频流。 11.025 kHz。在自定义 MediaTool 侦听器中使用 Xuggle 的 IAudioResampler 类来侦听 onAudioSamples(),以将音频重新采样到支持的速率。

Problem solved. It was due to FLV only supporting audio streams with sample rates of 44.1, 22.05 & 11.025 kHz. Used Xuggle's IAudioResampler class from within a custom MediaTool listener listening to onAudioSamples() to resample the audio to a supported rate.

情释 2024-09-19 08:18:33

我最近也遇到了同样的问题。花了几天时间,直到我找到答案 此处

I also recently ran across this same issue. Spent couple of days on this till I found the answer here.

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