android gpu h264,android - How to encode jpeg images to H264 very fast (transform images to video) -...

博客内容讲述了如何使用FFmpeg命令将30张分辨率为480x640的JPEG图片快速编码为H264格式的视频。通过调整参数如预设值(preset)、帧率(r)和比特率(b:v),尝试减少编码时间。目前最快的方法是添加-preset ultrafast选项,将编码时间从90秒降低到15秒,但目标是达到1秒内完成。问题中还提供了在Android应用中运行FFmpeg命令的代码示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I have 30 JPEG images (.jpg) at a resolution of 480 x 640.

Each image takes aboout 20KB (all of them takes about 600KB).

I am using FFmpeg command to encode these images into a video in H264 format.

I need this to be done very fast - about 1 second.

Using the classic command:

ffmpeg -y -f image2 -r 1/5 -i image_%d.jpg -c:v libx264 -r 30 video.mp4

takes about 90 seconds.

After adding -preset ultrafast:

ffmpeg -y -f image2 -r 1/5 -i image_%d.jpg -c:v libx264 -preset ultrafast -r 30 video.mp4

the encoding takes about 15 seconds which is much better, but still not enough

I've tried others parameters also, like:

-profile:v baseline

-qscale:v

-b:v 1000k

-crf 24

but the encoding time does not fall below 10 seconds.

I'm not familiar with FFmpeg commands nor with the parameters I need to use, and this is the reason I post here this question.

The video quality needs to be ok, doesn't need to be perfect.

As a note: I am running these commands in an Android application where I have the ffmpeg executable, using an ProcessBuilder.

Reply1 (to Robert Rowntree):

ArrayList l2 = new ArrayList();

//l2.add("ffmpeg");

l2.add("/data/data/" + packageName + "/ffmpeg");

l2.add("-y");

l2.add("-loop");

l2.add("1");

l2.add("-i");

l2.add("frame_%d.jpg");

// l2.add("-t");

// l2.add(strngs[3]);

l2.add("-r");

l2.add("1/2");

l2.add("-preset");

l2.add("superfast");

l2.add("-tune");

l2.add("zerolatency");

// l2.add("-pass");

// l2.add(Integer.valueOf(pass).toString());

l2.add("-vcodec");

l2.add("libx264");

l2.add("-b:v");

l2.add("200k");

l2.add("-bt");

l2.add("50k");

l2.add("-threads");

l2.add("0");

l2.add("-b_strategy");

l2.add("1");

// if(pass ==1){

// l2.add("-an");

// } else {

// l2.add("-acodec");

// l2.add("copy");

// }

l2.add("-f");

l2.add("mp4");

l2.add("-strict");

l2.add("-2");

// l2.add("-passlogfile");

// l2.add(strngs[4]);

// if(pass ==1){

// l2.add("/dev/null");

// } else {

// l2.add(strngs[5]);

// }

l2.add("video.mp4");

//return l2;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值