Tag: mediamuxer

使用MediaCodec和MediaMuxer编码和混合video

我正在开发一个应用程序,我解码一个video,并replace某些帧,并使用MediaMuxer和MediaCodec重新编码。 该应用程序的作品,如果我不replace任何帧(除了1080p的video,我下面解释),但是当我这样做,replace后的帧是像素化,video是断断续续的。 另外,当我用1920×1080的video试用我的应用程序时,我得到一个奇怪的输出,video没有显示任何东西,直到我滚动到video的开始,然后video开始出现(但与之前提到的相同的问题编辑后的pixalation。 以下是我如何configuration我的编码器: Video_format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, interval); Video_format.setInteger(MediaFormat.KEY_BIT_RATE, bitRate); Video_format.setInteger(MediaFormat.KEY_FRAME_RATE, frameRate); Video_format.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, 0); int color_format=MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420SemiPlanar; Video_format.setInteger(MediaFormat.KEY_COLOR_FORMAT, color_format); encoder.configure(Video_format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE); 所以总结一下,我有两个问题: 1-像素化帧和修改后的帧video波涛汹涌。 2-破坏1920x1080video,除非我滚动到开始。 编辑 这是一个未经编辑的1080pvideo样本,当我在VLC上播放时,会出现一个绿色屏幕,并且在电话上播放不正确,除非我开始在YouTube上滚动并且现在奇怪地正常工作,除了开始时的绿框 这里是一个720p的video样本,编辑时也是一个绿色的框架和编辑后的清晰的像素化和滞后 这里是我用来解码重新编码的代码: do{ Bitmap b1; if(edited_frames.containsKey(extractor.getSampleTime())) b1=BitmapFactory.decodeFile(edited_frames.get(extractor.getSampleTime())); else b1=decode(extractor.getSampleTime(),Preview_width,Preview_Height); if(b1==null) continue; Bitmap b_scal=Bitmap.createScaledBitmap(b1, Preview_width, Preview_Height, false); if(b_scal==null) continue; encode(b_scal, encoder, muxer, videoTrackIndex); lastTime=extractor.getSampleTime(); }while(extractor.advance()); 解码方法: private Bitmap decode(final long time,final […]