ffmpeg:如何为视频添加恒定的颜色边距

时间:2017-10-24 18:11:40

标签: ffmpeg

我有一个视频,我想在视频的顶部和底部添加黑色背景填充以获得方形输出。 enter image description here 是否可以使用 int oh1 = resized.getHeight(); System.out.println("Resize height-->" + oh1 + "resize width-->" + resized.getWidth()); Matrix matrix = new Matrix(); matrix.postRotate(90.0f); Bitmap createBitmap = Bitmap.createBitmap(resized, 0, 0, resized.getWidth(), resized.getHeight(), matrix, true); Bitmap mutableBitmap = createBitmap.copy(Config.ARGB_8888, true); Canvas canvas = new Canvas(mutableBitmap); Paint paint = new Paint(); paint.setColor(Color.YELLOW); paint.setTextSize(20.0f); paint.setTextAlign(Align.CENTER); simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); String dateTime = simpleDateFormat.format(Calendar.getInstance().getTime()); System.out.println(dateTime); canvas.drawText(dateTime, 150.0f, 100.0f, paint); 执行此操作?

1 个答案:

答案 0 :(得分:1)

假设宽度大于高度,

ffmpeg -i input.mp4 -vf pad=iw:iw:0:(oh-ih)/2:color=black -c:a copy out.mp4