与MediaExtractor问题 [英] Problems with MediaExtractor

查看:1410
本文介绍了与MediaExtractor问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得在特定的时间特定的帧作为使用来自电影图像 MediaExtractor 媒体codeC 。我能成功地做到这一点,如果:

I am trying to get specific frames at specific times as images from a movie using MediaExtractor and MediaCodec. I can do it successfully if:

  • 我用 extractor.seekTo(时间,MediaExtractor.SEEK_TO_ preVIOUS_SYNC); ,然而,这只是给最近的同步帧而不是目标帧
  • 在我按顺序使用 extractor.advance()提取所有的帧; ,但我需要得到目标帧不是所有
  • I use extractor.seekTo(time, MediaExtractor.SEEK_TO_PREVIOUS_SYNC); , however, this only gives the nearest sync frame not the target frame.
  • I sequentially extract all frames using extractor.advance(); , but I need to get the target frame not all.

于是,我尝试以下方法:

So, I try the following:

extractor.seekTo(time, MediaExtractor.SEEK_TO_PREVIOUS_SYNC);
while(extractor.getSampleTime()<time /*target time*/) extractor.advance();

此提供了正确的帧,但由于某些原因图像损坏。它看起来像正确的图像(一个我从成功案例获得),但与一些像素化和陌生的阴霾。

This provides the correct frame, but for some reason the image is corrupted. It looks like the correct image (the one I get from the successful cases), but with some pixelation and a strange haze.

while循环是成功的案例和破坏的人之间不同的唯一的事。怎样做才能推进 MediaExtractor 到一个特定的时间(不只是同步时间)没有得到损坏的图像?

The while-loop is the only thing that is different between the successful cases and the corrupted ones. What to do to advance MediaExtractor to a specific time (not just sync time) without getting a corrupted image?

推荐答案

由于法登的评论,我必须保持喂EN codeR因为 I帧有充分的画面和 P B 帧有分歧(这是怎样的COM pression实现)。所以,我要开始与 I帧(这是一样的同步帧),并再喂另一帧去codeR接收完整的图像。

Thanks to fadden comment, I have to keep feeding the encoder since the I-frame has the full picture and the P and B frames have differences (this is how compression is achieved). So I need to start with an I-frame (it was same as sync frame) and keep feeding the other frames to the decoder to receive the full image.

这篇关于与MediaExtractor问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆