Java:编写自定义视频编解码器的指南
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10114413/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java: Guide to write a custom video codec
提问by Tony Bogdanov
I have quite a weird question, but here it is:
我有一个很奇怪的问题,但这里是:
Is it possible, and are there any guides for writing a custom video codec in C++ or Java?
是否有可能,是否有任何使用 C++ 或 Java 编写自定义视频编解码器的指南?
Here's the weird part: I don't need to dive into those tons of info about audio and motion picture I don't understand. What I actually need is the technical stuff behind how to make a software layer between a movie player and a movie file.
这是奇怪的部分:我不需要深入研究我不理解的有关音频和电影的大量信息。我真正需要的是如何在电影播放器和电影文件之间制作软件层背后的技术内容。
Here's why: I would like to create a library or ultimately 2 functions - encode / decode - in C++ / Java, which will take the RAW binary input of any type of file and encode / decode it according to a given password or something like that. Then I need to put this processing between a movie player and a movie file. The final result will be a password protected mp4 / avi / mpeg / wmv (doesn't really matter) file, that could be played only with this "codec". The internal logic of the codec is not the issue right now.
原因如下:我想创建一个库或最终的 2 个函数 - 编码/解码 - 在 C++/Java 中,它将获取任何类型文件的 RAW 二进制输入,并根据给定的密码或类似的东西对其进行编码/解码. 然后我需要把这个处理放在一个电影播放器和一个电影文件之间。最终结果将是一个受密码保护的 mp4/avi/mpeg/wmv(无关紧要)文件,只能用这个“编解码器”播放。编解码器的内部逻辑现在不是问题。
How I imagine it is like a stream, movie player request the file and calls my encode()
function, it takes a chunk of the file, decodes it (it has been previously encoded) and returns the correct bytes in wmv/mp4 and so on format.
我如何想象它就像一个流,电影播放器请求文件并调用我的encode()
函数,它需要一个文件块,对其进行解码(它之前已经编码)并以 wmv/mp4 等格式返回正确的字节。
Is any of this possible and how?
这是否可能以及如何实现?
采纳答案by Elnaz
A codec generally takes image blocks and context information, transforms and quantizes the data, applies predictions, then encodes the resulting error stream using one of any number of coding schemes.
编解码器通常采用图像块和上下文信息,转换和量化数据,应用预测,然后使用任意数量的编码方案之一对产生的错误流进行编码。
The API is usually simple. For encode, you send blocks of image data (frames) to the encoder, and it generates a stream of bits. You may be responsible for writing the container (file format) yourself. For decode, you stream bits in and frames come out.
API 通常很简单。对于编码,您将图像数据块(帧)发送到编码器,它会生成位流。您可能负责自己编写容器(文件格式)。对于解码,您输入比特并输出帧。
There is absolutely no standard to any of this -- the technologies used in the codecs are sometimes standardised, but the exact interfaces are not.
任何这些都绝对没有标准——编解码器中使用的技术有时是标准化的,但确切的接口不是。
MediaTool Introduction is a simple Application Programming Interface (API) for decoding, encoding and modifying video in Java: http://wiki.xuggle.com/MediaTool_Introduction#How%5FTo%5FTake%5FSnapshots%5FOf%5FYour%5FDesktop
MediaTool 介绍是一个简单的应用程序编程接口 (API),用于在 Java 中解码、编码和修改视频:http://wiki.xuggle.com/MediaTool_Introduction#How%5FTo%5FTake%5FSnapshots%5FOf%5FYour%5FDesktop
Java Media frame work tutorial: http://wwwinfo.deis.unical.it/fortino/teaching/gdmi0708/materiale/jmf2_0-guide.pdf
Java Media 框架工作教程:http: //wwwinfo.deis.unical.it/fortino/teaching/gdmi0708/materiale/jmf2_0-guide.pdf
maybe helps you!
也许对你有帮助!