4.3的MediaMuxer或ffmpeg的:在Android中添加水印位图在视频位图、水印、视频、MediaMuxer

2023-09-05 03:17:02 作者:一颗心、只装你一人

下面是我的情况:

从网上下载的AVI电影 打开一个位图资源 覆盖此位图的所有帧的电影底部的背景 在保存上extarnal存储的视频 在该视频时长为15秒通常是

这是可能实现使用MediaMuxer?关于此事的任何信息被欣然接受

Is this possible to achieve using MediaMuxer ? Any info on the matter is gladly received

我一直在寻找http://bigflake.com/media$c$cc/#De$c$cEditEn$c$cTest (感谢@fadden)和它说: 解码帧并将​​其复制到一个的ByteBuffer与glReadPixels()需要大约8毫秒的的Nexus 5,很容易不够快跟上30fps的输入速度,但需要额外的步骤将其保存到磁盘作为PNG价格昂贵(约半第二次),因此有近1秒/帧是不能接受的。从我在想一个办法是将每一帧保存为PNG,打开它,添加位图覆盖它,然后将其保存。然而,这将需要巨大的时间来完成。我不知道是否有一种方法可以做这样的事情: 从外部存储1.打开视频文件 2.启动对其进行解码 3.每个去codeD架将与内存中的位图覆盖改变 4.帧发送到一间codeR。

I've been looking to http://bigflake.com/mediacodec/#DecodeEditEncodeTest (Thanks @fadden) and it says there: "Decoding the frame and copying it into a ByteBuffer with glReadPixels() takes about 8ms on the Nexus 5, easily fast enough to keep pace with 30fps input, but the additional steps required to save it to disk as a PNG are expensive (about half a second)" so having almost 1 sec/frame is not acceptable. From what I am thinking one way would be to save each frame as PNG, open it, add the bitmap overlay on it and then save it. However this would take an enormous time to accomplish. I wonder if there is a way to do things like this: 1. Open video file from external storage 2. Start decoding it 3. Each decoded frame will be altered with the bitmap overlay in memory 4. The frame is sent to an encoder.

在iOS上我看到有一个方法,采取原始的音频+原始视频+图片,并将其添加到容器中,然后就连接code整个事情...

On iOS I saw that there a way to take the original audio + original video + an image and add them in a container and then just encode the whole thing...

我应该切换到FFmpeg的?如何稳定和兼容是的ffmpeg?难道我冒着与Android 4.0+设备的兼容性问题?有没有办法使用的ffmpeg来acomplish呢?我是新来这个领域,仍然做研究。

Should I switch to ffmpeg ? How stable and compatible is ffmpeg ? Am I risking compatibility issues with android 4.0+ devices ? Is there a way to use ffmpeg to acomplish this ? I am new to this domain and still doing research.

推荐答案

我不知道很多有关MediaMuxer但ffmpeg的不支持覆盖功能。 FFMPEG有各种过滤器其中之一是叠加滤波器。我的理解是要叠加图像(即PNG)上的视频,ffmpeg的肯定是一个有用的框架来做好这项工作。您可以设置输出格式,您可以设置坐标将被夸大的形象。

I don't know much about the MediaMuxer but ffmpeg does support overlaying functionality. FFMPEG has various filters one of them is overlay filter. What I understand is you want to overlay an image (i.e. png) on the video, ffmpeg surely is a useful framework to do this job. You can set the output format you can set the co-ordinates of the image which is to be overplayed.

例如。

ffmpeg -i input.avi -i logo.png -filter_complex 'overlay=10:main_h-overlay_h-10' output.avi

上面的命令在左下角的input.avi视频文件添加叠加logo.png。

Above command adds overlays logo.png on the input.avi video file in bottom left corner.

有关过滤器的详细信息,请访问

More information about the filters is available at following website,

https://www.ffmpeg.org/ffmpeg-filters.html#覆盖-1

如果这是一个解决问题的方法,你需要等同于上述命令C $ C $℃。您还需要看到的ffmpeg的性能,因为它纯粹的软件框架。

If this is a solution to your problem you need the C code equivalent to the above command. You also need to see the performance of the ffmpeg because it a pure software framework.

希望我正确地理解你的问题,这会有所帮助。

Hope I have understood your question correctly and this helps.