这里我试图创建一个带有顶部和底部文本的视频编辑器。我可以在顶部和底部设置2个文本,使用不同的文本大小,颜色和字体,我将该文本转换为图像并添加为水印。
但是当视频分辨率降低时,水印图像的大小会增加,反之亦然。我正在使用ffmpeg命令。现在我的计算方法如下所示。
if (video_width <= 300) {
Log.e("less than", "300");
water_resolution_bt = String.valueOf(getDPsFromPixels(getApplicationContext(), tv_bt_width / 2 + 30) + ":" + getDPsFromPixels(getApplicationContext(), tv_bt_height / 2 + 15));
water_resolution = String.valueOf(getDPsFromPixels(getApplicationContext(), tv_top_width / 2 + 30) + ":" + getDPsFromPixels(getApplicationContext(), tv_top_height / 2 + 15));
} else if (video_width > 300 && video_width <= 400) {
Log.e("less than", "400");
water_resolution_bt = String.valueOf(getDPsFromPixels(getApplicationContext(), tv_bt_width / 2 + 130) + ":" + getDPsFromPixels(getApplicationContext(), tv_bt_height / 2 + 70));
water_resolution = String.valueOf(getDPsFromPixels(getApplicationContext(), tv_top_width / 2 + 130) + ":" + getDPsFromPixels(getApplicationContext(), tv_top_height / 2 + 70));
} else if (video_width > 400 && video_width <= 600) {
Log.e("btw ", "400 and 600");
water_resolution_bt = String.valueOf(getDPsFromPixels(getApplicationContext(), tv_bt_width + 80) + ":" + getDPsFromPixels(getApplicationContext(), tv_bt_height + 40));
water_resolution = String.valueOf(getDPsFromPixels(getApplicationContext(), tv_top_width + 80) + ":" + getDPsFromPixels(getApplicationContext(), tv_top_height + 40));
} else if (video_width > 600 && video_width <= 1000) {
Log.e("btw ", "600 and 1000");
water_resolution_bt = String.valueOf(getDPsFromPixels(getApplicationContext(), tv_bt_width + 100) + ":" + getDPsFromPixels(getApplicationContext(), tv_bt_height + 100));
water_resolution = String.valueOf(getDPsFromPixels(getApplicationContext(), tv_top_width + 100) + ":" + getDPsFromPixels(getApplicationContext(), tv_top_height + 100));
} else if (video_width > 1000) {
Log.e("grthr than ", "1000");
water_resolution = String.valueOf(getDPsFromPixels(getApplicationContext(), tv_top_width * 2 + 20) + ":" + getDPsFromPixels(getApplicationContext(), tv_top_height * 2 + 20));
water_resolution_bt = String.valueOf(getDPsFromPixels(getApplicationContext(), tv_bt_width * 2 + 20) + ":" + getDPsFromPixels(getApplicationContext(), tv_bt_height * 2 + 20));
}
这不会给出准确的结果。任何人都可以建议任何其他计算方法。我也试过&#34; drawtext&#34;方法。它也有同样的问题。