简体   繁体   English

如何在Android中将图像编码为H264?

[英]How to encode image to h264 in android?

For some reason, I want to encode image frame to h264 in android. 由于某种原因,我想在Android中将图像帧编码为h264。 In order to get a better performance, I used ffmpeg with android ndk to encode image. 为了获得更好的性能,我将ffmpeg与android ndk一起使用对图像进行编码。 I'm so strange that it's easy to decode h264 frame to image while it's so hard to encode image to h264 frame. 我很奇怪,很容易将h264帧解码为图像,而很难将图像编码为h264帧。 When I try to use avcodec_encode_video2 function the eclipse always shows a message An internal error occurred during: "Launching MyApp". 当我尝试使用av​​codec_encode_video2函数时,eclipse始终显示一条消息:在“启动MyApp”期间发生内部错误。 java.lang.NullPointerException which make me crazy. java.lang.NullPointerException这让我发疯。 I'm also so angry that the android ndk do not show any message useful to tell me what happen. 我也很生气,android ndk没有显示任何有用的消息告诉我发生了什么。 Can anyone help me? 谁能帮我?

h264 encoder is not an integral part of ffmpeg. h264编码器不是ffmpeg的组成部分。 Usually we use the opensource x264 encoder, but this has significant legal consequences. 通常,我们使用开源x264编码器,但这会产生重大的法律后果。 x264 is GPL, while usually builds of ffmpeg are LGPL. x264是GPL,而通常ffmpeg的构建是LGPL。 You can build ffmpeg with x264, or use x264 standalone. 您可以使用x264构建ffmpeg,也可以独立使用x264。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM