- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试从图像、gif 和音乐创建视频。
这是我使用的代码:
{"-y", "-i", imagepath, "-ignore_loop", "0", "-i", gif, "-filter_complex", "[1:v]scale=" + filterdBitmap.getWidth() + ":" + filterdBitmap.getHeight() + "[ovrl];[0:v][ovrl]overlay=0:0", "-ss", "" + startMs / 1000, "-t", "" + endMs / 1000, "-i", songpath, "-c:v", "libx264", "-preset", "ultrafast", "-r", "30", "-pix_fmt", "yuva420p", "-c:a", "aac", "-shortest", outputLocation.getPath()};
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
2020-02-29 10:16:01.043 14913-14913/com.photocreator E/fail: ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.8 (GCC)
configuration: --target-os=linux --cross-prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/vagrant/SourceCode/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, png_pipe, from 'file:///storage/emulated/0/1582951553006.jpg':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: png, rgba(pc), 639x812, 25 tbr, 25 tbn, 25 tbc
Input #1, gif, from 'http://13.232.145.224:3003/getpath/video_maker/new/35.gif':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: gif, bgra, 288x480, 15 fps, 15 tbr, 100 tbn, 100 tbc
[mp3 @ 0xaea97200] Skipping 0 bytes of junk at 253.
Input #2, mp3, from '/storage/emulated/0/Download/supnaringtone-49332.mp3':
Metadata:
encoder : Lavf58.20.100
Duration: 00:00:21.76, start: 0.025057, bitrate: 64 kb/s
Stream #2:0: Audio: mp3, 44100 Hz, stereo, s16p, 64 kb/s
Metadata:
encoder : Lavc58.35
Incompatible pixel format 'yuva420p' for codec 'libx264', auto-selecting format 'yuv420p'
[libx264 @ 0xaeacfc00] width not divisible by 2 (639x812)
Output #0, mp4, to '/storage/emulated/0/allkotlin/video/movie_1582951554388.mp4':
Stream #0:0: Video: h264, none, q=2-31, 128 kb/s, 30 fps (default)
Metadata:
encoder : Lavc57.24.102 libx264
Stream #0:1: Audio: aac, 0 channels, 128 kb/s
Metadata:
encoder : Lavc57.24.102 aac
Stream mapping:
Stream #0:0 (png) -> overlay:main (graph 0)
Stream #1:0 (gif) -> scale (graph 0)
overlay (graph 0) -> Stream #0:0 (libx264)
Stream #2:0 -> #0:1 (mp3 (native) -> aac (native))
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
public class PhotoEditing extends AppCompatActivity implements GetGifAdapter.GlideInterface, SdCardSongAdapter.MediaInterface
, FiltersListFragmentListener, EmojiFragmentListener, AddTextFragmentListener {
public static final String FILE_PROVIDER_AUTHORITY = "com.burhanrashid52.photoeditor.fileprovider";
@Nullable
@VisibleForTesting
Uri mSaveImageUri;
PhotoEditorView image_preview;
ImageView image_gif/*,image_preview*/;
ImageView save, back;
LinearLayout linearLayout;
public String sessionId, sessionId1;
Uri image_selected_uri;
public Bitmap originalBitmap, filterdBitmap, finalBitmap;
LinearLayout btn_music_list, btn_music_cut, btn_add_gif, btn_filters_list, btn_emoji, btn_add_text;
MediaPlayer mediaPlayer;
String mediaData;
LinearLayout relativeLayout;
RelativeLayout seekbar_layout, fm;
RelativeLayout.LayoutParams layoutparam;
RangeSeekBar rangeSeekBar;
Runnable r;
Handler mHandler;
private int duration;
private TextView tvLeft, tvRight;
RelativeLayout rl_replace, music_fragment;
FilterListFragment filterListFragment;
EmojiFragment emojiFragment;
PhotoEditor photoEditor;
int screenWidth, screenHeight;
Bitmap bitmap;
int brightnessFinal = 0;
int saturationFinal = 0;
int constrantFinal = 0;
int hue = 0;
String glideData;
FFmpeg ffmpeg;
String s;
String imageHeight;
String imageWidth ;
private static final String TAG = "BRIJESH";
Context context = this;
static {
System.loadLibrary("NativeImageProcessor");
}
public Bitmap resizeImageToNewSize(Bitmap bitmap, int i, int i2) {
try {
int width = bitmap.getWidth();
int height = bitmap.getHeight();
float f = (float) i;
float f2 = (float) i2;
if (!(height == i2 && width == i)) {
float f3 = (float) width;
float f4 = f / f3;
float f5 = (float) height;
float f6 = f2 / f5;
if (f4 < f6) {
f6 = f4;
}
f = f3 * f6;
f2 = f5 * f6;
}
Bitmap bitmap1 = Bitmap.createScaledBitmap(bitmap, (int) f, (int) f2, true);
fm.removeView(image_preview);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(bitmap1.getWidth(), bitmap1.getHeight());
params.addRule(RelativeLayout.CENTER_HORIZONTAL);
image_preview.setLayoutParams(params);
fm.addView(image_preview);
return bitmap1;
} catch (Exception unused) {
fm.removeView(image_preview);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(200, 100);
params.addRule(RelativeLayout.CENTER_IN_PARENT);
image_preview.setLayoutParams(params);
fm.addView(image_preview);
return bitmap;
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_photo_editing);
initialize(this);
image_preview = findViewById(R.id.image_preview);
image_preview.getSource().setScaleType(ImageView.ScaleType.FIT_XY);
photoEditor = new PhotoEditor.Builder(this, image_preview)
.setPinchTextScalable(true)
.build();
image_gif = findViewById(R.id.image_gif);
linearLayout = findViewById(R.id.linearLayout);
btn_music_list = findViewById(R.id.btn_music_list);
// btn_music_cut = findViewById(R.id.btn_music_cut);
btn_add_gif = findViewById(R.id.btn_add_gif);
btn_filters_list = findViewById(R.id.btn_filters_list);
btn_emoji = findViewById(R.id.btn_emoji);
btn_add_text = findViewById(R.id.btn_add_text);
fm = findViewById(R.id.frame);
rl_replace = findViewById(R.id.replace_fragment);
music_fragment = findViewById(R.id.music_fragment);
seekbar_layout = findViewById(R.id.seekbar_layout);
rangeSeekBar = findViewById(R.id.rangeSeekBar);
rangeSeekBar.setNotifyWhileDragging(true);
mHandler = new Handler();
tvLeft = findViewById(R.id.tvLeft);
tvRight = findViewById(R.id.tvRight);
relativeLayout = findViewById(R.id.relativeLayout);
save = findViewById(R.id.btndone);
back = findViewById(R.id.btnhome);
mediaPlayer = new MediaPlayer();
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mediaPlayer.isPlaying()) {
mediaPlayer.stop();
onBackPressed();
} else onBackPressed();
}
});
sessionId1 = getIntent().getStringExtra("gallary");
sessionId = getPathFromUri(PhotoEditing.this, Uri.parse(sessionId1));
image_selected_uri = Uri.parse(sessionId);
loadImage();
btn_music_list.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// if (seekbar_layout.getVisibility() == View.GONE){
if (mediaPlayer != null && mediaPlayer.isPlaying()) {
mediaPlayer.stop();
}
MusicListFragment musicListFragment = new MusicListFragment();
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.replace(R.id.replace_fragment, musicListFragment);
transaction.addToBackStack(null);
transaction.commit();
seekbar_layout.setVisibility(View.VISIBLE);
// }
// else if (seekbar_layout.getVisibility() == View.VISIBLE) {
// seekbar_layout.setVisibility(View.GONE);
// }
}
});
// btn_music_cut.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// if (seekbar_layout.getVisibility() == View.GONE) {
// if (mediaPlayer != null && mediaPlayer.isPlaying()) {
// seekbar_layout.setVisibility(View.VISIBLE);
// }
// } else if (seekbar_layout.getVisibility() == View.VISIBLE) {
// seekbar_layout.setVisibility(View.GONE);
// }
// }
// });
btn_add_gif.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
GIfFragment gIfFragment = new GIfFragment();
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.replace(R.id.replace_fragment, gIfFragment);
transaction.addToBackStack(null);
transaction.commit();
}
});
save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// image_preview.getSource().setDrawingCacheEnabled(true);
// Bitmap b = image_preview.getSource().getDrawingCache();
// MediaStore.Images.Media.insertImage(context.getContentResolver(), b,"", "");
saveImageToGallery();
}
});
}
private void loadImage() {
bitmap = BitmapFactory.decodeFile(image_selected_uri.toString());
originalBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
originalBitmap = modifyOrientation(originalBitmap, sessionId);
finalBitmap = originalBitmap.copy(Bitmap.Config.ARGB_8888, true);
filterdBitmap = originalBitmap.copy(Bitmap.Config.ARGB_8888, true);
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int f3672y = displayMetrics.widthPixels;
int f3673z = displayMetrics.heightPixels;
float f = getResources().getDisplayMetrics().density;
int i = f3672y - ((int) (40.0f * f));
int i2 = f3673z - ((int) (f * 100.0f));
image_preview.getSource().setImageBitmap(resizeImageToNewSize(bitmap, i, i2));
}
private void getDropboxIMGSize(Uri uri){
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(new File(uri.getPath()).getAbsolutePath(), options);
imageHeight= String.valueOf(options.outHeight);
imageWidth = String.valueOf(options.outWidth);
}
@SuppressLint("MissingPermission")
private void saveImageToGallery() {
File file = new File(Environment.getExternalStorageDirectory()
+ File.separator + ""
+ System.currentTimeMillis() + ".jpg");
try {
file.createNewFile();
SaveSettings saveSettings = new SaveSettings.Builder()
.setClearViewsEnabled(true)
.setTransparencyEnabled(true)
.build();
photoEditor.saveAsFile(file.getAbsolutePath(), saveSettings, new PhotoEditor.OnSaveListener() {
@Override
public void onSuccess(@NonNull String imagePath) {
Toast.makeText(context, "Image Saved", Toast.LENGTH_SHORT).show();
mSaveImageUri = Uri.fromFile(new File(imagePath));
getDropboxIMGSize(mSaveImageUri);
executeCmd(String.valueOf(mSaveImageUri), mediaData, glideData, rangeSeekBar.getSelectedMinValue().intValue() * 1000, rangeSeekBar.getSelectedMaxValue().intValue() * 1000);
}
@Override
public void onFailure(@NonNull Exception exception) {
}
});
} catch (IOException e) {
e.printStackTrace();
}
}
private void executeCmd(String imagepath, String songpath, String gif, int startMs, int endMs) {
File outputLocation = getConvertedFile(outputPath() + "video", "movie_" + System.currentTimeMillis() + ".mp4");
Log.e("videofilepath", songpath);
String[] complexCommand = {"-y", "-i", imagepath,
"-ignore_loop", "0",
"-i", gif, "-filter_complex", "[1:v]scale=w='bitand(iw,65534)':h='bitand(ih,65534)' [ovrl];[0:v][ovrl]overlay=0:0",
"-ss", "" + startMs / 1000, "-t", "" + endMs / 1000, "-i", songpath,
"-c:v", "libx264", "-preset", "ultrafast", "-r", "30", "-pix_fmt", "yuva420p", "-c:a", "aac", "-shortest", outputLocation.getPath()};
try {
ffmpeg.execute(complexCommand, new ExecuteBinaryResponseHandler() {
@Override
public void onSuccess(String s) {
Log.e("onSuccess", s);
}
@Override
public void onFailure(String s) {
Log.e("fail", s);
}
});
} catch (FFmpegCommandAlreadyRunningException e) {
Log.e("catch", e.getMessage());
}
}
}
最佳答案
正如错误消息所说,width not divisible by 2 (639x812)
.添加比例过滤器以使流尺寸均匀,例如叠加后,[0:v][ovrl]overlay=0:0,scale=w='bitand(iw,65534)':h='bitand(ih,65534)'
关于android - 打开输出流编码器时出错 #0 :0 for Creating Video from image, Gif,music,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60462126/
SQLite、Content provider 和 Shared Preference 之间的所有已知区别。 但我想知道什么时候需要根据情况使用 SQLite 或 Content Provider 或
警告:我正在使用一个我无法完全控制的后端,所以我正在努力解决 Backbone 中的一些注意事项,这些注意事项可能在其他地方更好地解决......不幸的是,我别无选择,只能在这里处理它们! 所以,我的
我一整天都在挣扎。我的预输入搜索表达式与远程 json 数据完美配合。但是当我尝试使用相同的 json 数据作为预取数据时,建议为空。点击第一个标志后,我收到预定义消息“无法找到任何内容...”,结果
我正在制作一个模拟 NHL 选秀彩票的程序,其中屏幕右侧应该有一个 JTextField,并且在左侧绘制弹跳的选秀球。我创建了一个名为 Ball 的类,它实现了 Runnable,并在我的主 Draf
这个问题已经有答案了: How can I calculate a time span in Java and format the output? (18 个回答) 已关闭 9 年前。 这是我的代码
我有一个 ASP.NET Web API 应用程序在我的本地 IIS 实例上运行。 Web 应用程序配置有 CORS。我调用的 Web API 方法类似于: [POST("/API/{foo}/{ba
我将用户输入的时间和日期作为: DatePicker dp = (DatePicker) findViewById(R.id.datePicker); TimePicker tp = (TimePic
放宽“邻居”的标准是否足够,或者是否有其他标准行动可以采取? 最佳答案 如果所有相邻解决方案都是 Tabu,则听起来您的 Tabu 列表的大小太长或您的释放策略太严格。一个好的 Tabu 列表长度是
我正在阅读来自 cppreference 的代码示例: #include #include #include #include template void print_queue(T& q)
我快疯了,我试图理解工具提示的行为,但没有成功。 1. 第一个问题是当我尝试通过插件(按钮 1)在点击事件中使用它时 -> 如果您转到 Fiddle,您会在“内容”内看到该函数' 每次点击都会调用该属
我在功能组件中有以下代码: const [ folder, setFolder ] = useState([]); const folderData = useContext(FolderContex
我在使用预签名网址和 AFNetworking 3.0 从 S3 获取图像时遇到问题。我可以使用 NSMutableURLRequest 和 NSURLSession 获取图像,但是当我使用 AFHT
我正在使用 Oracle ojdbc 12 和 Java 8 处理 Oracle UCP 管理器的问题。当 UCP 池启动失败时,我希望关闭它创建的连接。 当池初始化期间遇到 ORA-02391:超过
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 9 年前。 Improve
引用这个plunker: https://plnkr.co/edit/GWsbdDWVvBYNMqyxzlLY?p=preview 我在 styles.css 文件和 src/app.ts 文件中指定
为什么我的条形这么细?我尝试将宽度设置为 1,它们变得非常厚。我不知道还能尝试什么。默认厚度为 0.8,这是应该的样子吗? import matplotlib.pyplot as plt import
当我编写时,查询按预期执行: SELECT id, day2.count - day1.count AS diff FROM day1 NATURAL JOIN day2; 但我真正想要的是右连接。当
我有以下时间数据: 0 08/01/16 13:07:46,335437 1 18/02/16 08:40:40,565575 2 14/01/16 22:2
一些背景知识 -我的 NodeJS 服务器在端口 3001 上运行,我的 React 应用程序在端口 3000 上运行。我在 React 应用程序 package.json 中设置了一个代理来代理对端
我面临着一个愚蠢的问题。我试图在我的 Angular 应用程序中延迟加载我的图像,我已经尝试过这个2: 但是他们都设置了 src attr 而不是 data-src,我在这里遗漏了什么吗?保留 d
我是一名优秀的程序员,十分优秀!