gpt4 book ai didi

android - 在视频上添加文本和图像后。视频质量的输出丢失

转载 作者:行者123 更新时间:2023-12-04 23:13:51 27 4
gpt4 key购买 nike

我正在使用 ffmpeg 在图像上添加图像和文本。该命令工作正常,但视频质量下降。如何保持视频质量。

   String  imgcmd[]=new String[]{"-i", videopath ,"-i", imgpath,"-filter_complex", "[1]scale=720:1280[b];[0][b] overlay=main_w-overlay_w:main_h-overlay_h,drawtext=text="+text+":fontcolor=#FFFFFF:fontsize=18:x=(w-text_w)/2:y=(h-text_h)-145:fontfile="+fontpath ,  "-preset" ,"ultrafast","-codec:a", "copy",output};


public void LoadFFmpegLibrary()
{
if(ffmpeg!=null)
{

try {
ffmpeg.loadBinary(new LoadBinaryResponseHandler() {

@Override
public void onStart() {
Log.e("ffmpeg","Start to load");
}

@Override
public void onFailure() {
Log.e("ffmpeg","failed to load");
}

@Override
public void onSuccess() {

imageprogressDialog=

ConstantClass.ShowProgressDialog(VideoRecordingActivity.this,"Loading");
imageprogressDialog.show();
SharedPreferences
sharedPreferences=getSharedPreferences("shared",MODE_PRIVATE);
String
imgpath=sharedPreferences.getString("imgpath","");
String
fontpath=sharedPreferences.getString("fontpath","");
String
videopath=sharedPreferences.getString("videopath","");
//"-crf" ,"24"0
String imgcmd[]=new String[]{"-i", videopath ,"-i",
imgpath,"-filter_complex", "[1]scale=720:1280[b];[0][b]
overlay=main_w-overlay_w:main_h-
overlay_h,drawtext=text="+text+":fontcolor=#FFFFFF:fontsize=18:x=
(w-text_w)/2:y=(h-text_h)-145:fontfile="+fontpath , "-preset"
,"ultrafast","-codec:a", "copy",output};

ImageCommand(imgcmd);

}

@Override
public void onFinish() {

}
});
} catch (FFmpegNotSupportedException e) {
// Handle if FFmpeg is not supported by device
Log.e("ffmpeg",e.toString());
}
}
}





public void ImageCommand(String command[])
{

ffmpeg = FFmpeg.getInstance(VideoRecordingActivity.this);
try {
// to execute "ffmpeg -version" command you just need to pass "-version"
ffmpeg.execute(command, new ExecuteBinaryResponseHandler() {

@Override
public void onStart() {
Log.e("ffmpeg","Exaction Start");
}

@Override
public void onProgress(String message) {}

@Override
public void onFailure(String message) {
imageprogressDialog.dismiss();
Log.e("ok",message);
}

@Override
public void onSuccess(String message) {
imageprogressDialog.dismiss();

Toast.makeText(VideoRecordingActivity.this,"Video Edited Successfully", Toast.LENGTH_LONG).show();
PlayVideo();
playvideo.setVisibility(View.VISIBLE);

}

@Override
public void onFinish() {
imageprogressDialog.dismiss();
Log.e("ffmpeg","Exaction Start");
}
});
} catch (FFmpegCommandAlreadyRunningException e) {
imageprogressDialog.dismiss();
Log.e("ffmpeg",e.toString());
}
}

最佳答案

这个答案是关于您的评论,您询问在视频末尾添加文本的问题,例如 youtube 视频。这是一个命令执行,让我知道

ffmpeg -i input.mp4 -i 1.jpg -f lavfi -t 5 -i color=#000000:s=1280x720 -filter_complex "[0][1]overlay=main_w-overlay_w:main_h-overlay_h,drawtext=text="text":fontcolor=#FFFFFF:fontsize=18:x=(w-text_w)/2:y=(h-text_h)-145[video];[2]drawtext=text="FINAL_VIDEO_TEST":fontcolor=#FFFFFF:fontsize=50:x=(w-text_w)/2:y=(h-text_h)-145[textOverlay];[video][textOverlay]concat=n=2:v=1:a=0" -preset ultrafast -codec:a copy mvm/testOut.mp4

关于android - 在视频上添加文本和图像后。视频质量的输出丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56801711/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com