- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 JMF jar 文件,但我只能听声音但无法观看电影。
Unable to handle format: RLE , 800x600, FrameRate=14.6, Length=31280
Failed to realize: com.sun.media.PlaybackEngine@17590db
Error: Unable to realize com.sun.media.PlaybackEngine@17590db
我在尝试播放视频时遇到一些错误。
最佳答案
JMF 基本上已死
您可以使用xuggler在java swing中播放wmv文件。
package com.xuggle.xuggler.demos;
import com.xuggle.xuggler.demos.VideoImage;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
import com.xuggle.xuggler.IAudioSamples;
import com.xuggle.xuggler.IContainer;
import com.xuggle.xuggler.IPacket;
import com.xuggle.xuggler.IStream;
import com.xuggle.xuggler.IStreamCoder;
import com.xuggle.xuggler.ICodec;
public class DecodeAndPlayAudio
{
private static SourceDataLine mLine;
/**
* Takes a media container (file) as the first argument, opens it,
* opens up the default audio device on your system, and plays back the audio.
*
* @param args Must contain one string which represents a filename
*/
public static void main(String[] args)
{
if (args.length <= 0)
throw new IllegalArgumentException("must pass in a filename as the first argument");
String filename = args[0];
// Create a Xuggler container object
IContainer container = IContainer.make();
// Open up the container
if (container.open(filename, IContainer.Type.READ, null) < 0)
throw new IllegalArgumentException("could not open file: " + filename);
// query how many streams the call to open found
int numStreams = container.getNumStreams();
// and iterate through the streams to find the first audio stream
int audioStreamId = -1;
IStreamCoder audioCoder = null;
for(int i = 0; i < numStreams; i++)
{
// Find the stream object
IStream stream = container.getStream(i);
// Get the pre-configured decoder that can decode this stream;
IStreamCoder coder = stream.getStreamCoder();
if (coder.getCodecType() == ICodec.Type.CODEC_TYPE_AUDIO)
{
audioStreamId = i;
audioCoder = coder;
break;
}
}
if (audioStreamId == -1)
throw new RuntimeException("could not find audio stream in container: "+filename);
/*
* Now we have found the audio stream in this file. Let's open up our decoder so it can
* do work.
*/
if (audioCoder.open() < 0)
throw new RuntimeException("could not open audio decoder for container: "+filename);
/*
* And once we have that, we ask the Java Sound System to get itself ready.
*/
openJavaSound(audioCoder);
/*
* Now, we start walking through the container looking at each packet.
*/
IPacket packet = IPacket.make();
while(container.readNextPacket(packet) >= 0)
{
/*
* Now we have a packet, let's see if it belongs to our audio stream
*/
if (packet.getStreamIndex() == audioStreamId)
{
/*
* We allocate a set of samples with the same number of channels as the
* coder tells us is in this buffer.
*
* We also pass in a buffer size (1024 in our example), although Xuggler
* will probably allocate more space than just the 1024 (it's not important why).
*/
IAudioSamples samples = IAudioSamples.make(1024, audioCoder.getChannels());
/*
* A packet can actually contain multiple sets of samples (or frames of samples
* in audio-decoding speak). So, we may need to call decode audio multiple
* times at different offsets in the packet's data. We capture that here.
*/
int offset = 0;
/*
* Keep going until we've processed all data
*/
while(offset < packet.getSize())
{
int bytesDecoded = audioCoder.decodeAudio(samples, packet, offset);
if (bytesDecoded < 0)
throw new RuntimeException("got error decoding audio in: " + filename);
offset += bytesDecoded;
/*
* Some decoder will consume data in a packet, but will not be able to construct
* a full set of samples yet. Therefore you should always check if you
* got a complete set of samples from the decoder
*/
if (samples.isComplete())
{
playJavaSound(samples);
}
}
}
else
{
/*
* This packet isn't part of our audio stream, so we just silently drop it.
*/
do {} while(false);
}
}
/*
* Technically since we're exiting anyway, these will be cleaned up by
* the garbage collector... but because we're nice people and want
* to be invited places for Christmas, we're going to show how to clean up.
*/
closeJavaSound();
if (audioCoder != null)
{
audioCoder.close();
audioCoder = null;
}
if (container !=null)
{
container.close();
container = null;
}
}
private static void openJavaSound(IStreamCoder aAudioCoder)
{
AudioFormat audioFormat = new AudioFormat(aAudioCoder.getSampleRate(),
(int)IAudioSamples.findSampleBitDepth(aAudioCoder.getSampleFormat()),
aAudioCoder.getChannels(),
true, /* xuggler defaults to signed 16 bit samples */
false);
DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat);
try
{
mLine = (SourceDataLine) AudioSystem.getLine(info);
/**
* if that succeeded, try opening the line.
*/
mLine.open(audioFormat);
/**
* And if that succeed, start the line.
*/
mLine.start();
}
catch (LineUnavailableException e)
{
throw new RuntimeException("could not open audio line");
}
}
private static void playJavaSound(IAudioSamples aSamples)
{
/**
* We're just going to dump all the samples into the line.
*/
byte[] rawBytes = aSamples.getData().getByteArray(0, aSamples.getSize());
mLine.write(rawBytes, 0, aSamples.getSize());
}
private static void closeJavaSound()
{
if (mLine != null)
{
/*
* Wait for the line to finish playing
*/
mLine.drain();
/*
* Close the line.
*/
mLine.close();
mLine=null;
}
}
}
关于java - 如何在Java Swing中播放mov和wmv视频格式文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5048934/
我需要在我正在构建的 Django 网络应用程序中只接受 MP4 视频和 WMV 视频。为此,我会在文件到达服务器后检查文件的 MIME 类型。 据我所知,MP4 文件具有“video/mp4”mim
我目前正在进行的一个项目需要能够将视频从其他格式转换为 WMV 格式。我们需要能够将几乎任何常用的视频格式转换为 WMV 格式。我正在寻找一种解决方案,例如 On2 的 flix 引擎将其他视频类型转
我的网页 View 中嵌入了一个 Windows 媒体播放器:
任何使用 ffmpeg 的人 我有一个相当简单的 wmv,由电影制作者的用户导出,具有标准输出,并希望使用转换为 .flv C:>ffmpeg -i "E:\Jab Core 4 Recounters
我在 SharePoint 中托管了一个 wmv 视频。我创建了一个包含一些自定义内容的内容编辑器 Web 部件,并放置了一个指向视频 的简单链接。点击查看 . 这里真的没有什么特别的。一些用户可以
我想获取一个视频文件并使用 java“加密”它。目前加密只是翻转位。我希望视频仍然能够播放,因此 header 需要完好无损。我发现很难找到标题有多大。我尝试使用 .avi 文件并使用此链接 AVI
我想显示我网站上列出的视频的缩略图,我想从视频(从特定时间)获取单个帧并将它们显示为缩略图。 这可能使用 .Net 吗? (C# 或 VB) 最佳答案 是的,这是可能的。您需要使用 DirectSho
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
This example on Code Project几乎正是我所需要的...除了 saveFrameFromVideo 采用百分比而不是帧数... 我如何使用它从 WMV 文件中提取 X 帧? 我
有谁知道是否可以使用 C# 从位置 X 上的视频 (.wmv) 抓取帧/图像,而无需安装 DirectX 并在 Windows 2008 上工作(我希望尽可能少安装网络服务器)。 或者甚至是使用 di
我以非常标准的方式使用 MPMoviePlayerController。 MPMoviePlayerController *player = [self.movieController moviePl
我似乎无法让 FFMpeg 使用该库。每次我尝试将 asf 文件转换为 wmv。我在运行时遇到以下问题: [wmv1 @ 0x81ee000]error, slice code was 2 [wmv1
前奏: 我将以此作为开头,我在工作的业余时间一直在学习 C#,并且我已经盯着代码整整两天试图解决这个问题。我正在开发一些与通过 USB 连接到标准台式 PC 的可视化器一起使用的软件,该软件检测捕获设
我正在尝试为客户制作我的桌面应用程序的动画。 我想用一个循环为背景制作动画,并在此之上提供特定于区域的动画(允许透明胶片看到下面的分层动画)。 这对 WMV 来说可能吗?如果不能,是否可以使用其他视频
有没有一种方法可以在视频的特定点(例如 5 秒或第 25 帧)从视频文件(mpg、wmv、flv 等)中捕获单个帧?然后保存为图片? [编辑]YouTube 做的一些链接。不能全部手动完成吗? ;)
请指导我如何解决这个问题。下面是我尝试将 wmv 格式文件转换为 .flv 时得到的结果。 ffmpeg -i full.wmv -ar 48000 -ab 192000 -b 293000 -r 1
这就是我使用的命令 ffmpeg -i full.wmv -sameq -ab 128 -s 640x480 full.flv FFmpeg version SVN-r13582, Copyrig
我已经为此工作了很长时间,但仍然没有找到有效的解决方案。我需要一个方法 直播转换 (转码)用于在 html5 网络播放器中播放的 .wmv 文件。 我有一个 linux 服务器 (Apache) 设置
我正在将大量 WMV 文件转换为 MP4。 命令是: ffmpeg -loglevel 0 -y -i source.wmv destination.mp4 我大约有 100GB 需要转换。 24 小
对于 Azure 媒体服务编码任务,状态多次显示“正在处理...”,然后进入错误状态。没有显示错误消息。我正在关注这个https://www.windowsazure.com/en-us/develo
我是一名优秀的程序员,十分优秀!