
Recherche avancée
Médias (91)
-
Valkaama DVD Cover Outside
4 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Image
-
Valkaama DVD Label
4 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Image
-
Valkaama DVD Cover Inside
4 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Image
-
1,000,000
27 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Demon Seed
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
The Four of Us are Dying
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
Autres articles (96)
-
Mise à disposition des fichiers
14 avril 2011, parPar défaut, lors de son initialisation, MediaSPIP ne permet pas aux visiteurs de télécharger les fichiers qu’ils soient originaux ou le résultat de leur transformation ou encodage. Il permet uniquement de les visualiser.
Cependant, il est possible et facile d’autoriser les visiteurs à avoir accès à ces documents et ce sous différentes formes.
Tout cela se passe dans la page de configuration du squelette. Il vous faut aller dans l’espace d’administration du canal, et choisir dans la navigation (...) -
Amélioration de la version de base
13 septembre 2013Jolie sélection multiple
Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...) -
Formulaire personnalisable
21 juin 2013, parCette page présente les champs disponibles dans le formulaire de publication d’un média et il indique les différents champs qu’on peut ajouter. Formulaire de création d’un Media
Dans le cas d’un document de type média, les champs proposés par défaut sont : Texte Activer/Désactiver le forum ( on peut désactiver l’invite au commentaire pour chaque article ) Licence Ajout/suppression d’auteurs Tags
On peut modifier ce formulaire dans la partie :
Administration > Configuration des masques de formulaire. (...)
Sur d’autres sites (4617)
-
4 ways to create more effective funnels
24 février 2020, par Jake Thornton — Uncategorized -
Error while opening encoder for output stream #0:0 for Creating Video from image,Gif,music
29 février 2020, par brijeshI am trying to create a video from image,gif and music.
Here is the code I used :
{"-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()};
The error I received was this :
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Specifically, here is the complete response :
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 heightIf I use -s 560x560 , it works great, except then I can’t keep on using my aspect ratio :
And here is my code :
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());
}
}
}Any idea what is going on here ? Thanks !
-
When i used ffmpeg to trim a video ,i observed an error [closed]
6 mars 2020, par israfillli wanna use ffmpeg to trim a video but when i build app i see this I/System.out : ssssCANNOT LINK EXECUTABLE "/data/user/0/com.example.newapplication/files/ffmpeg" : "/data/data/com.example.newapplication/files/ffmpeg" has text relocations (https://android.googlesource.com/platform/bionic/+/master/androg-’changes-for-ndk-developers.md#Text-Relocations-Enforced-for-API-level-23)
why didn’t i use this library
public class MainActivity extends AppCompatActivity {
String outPutFile;
Uri filePath, filePathSecond, photoUri, AudioUri;
ProgressDialog progressDialog;
private int REQUEST_TAKE_GALLERY_VIDEO = 110;
private int REQUEST_TAKE_GALLERY_VIDEO_2 = 115;
private FFmpeg ffmpeg;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if(ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED){
ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},1);
}
progressDialog = new ProgressDialog(this);
findViewById(R.id.selectVideo).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setType("video/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Video"), REQUEST_TAKE_GALLERY_VIDEO);
}
});
findViewById(R.id.start).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (filePath != null) {
executeCutVideoCommand(1000, 4 * 1000, filePath);
}
}
});
findViewById(R.id.marge_video).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (filePath != null && filePathSecond != null)
executeMargeVideoCommand(filePath, filePathSecond);
}
});
findViewById(R.id.selectVideo_2).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setType("video/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Video"), REQUEST_TAKE_GALLERY_VIDEO_2);
}
});
findViewById(R.id.filter_video).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(filePath!=null){
executeFilterCommand(filePath);
}
}
});
loadFFMpegBinary();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_TAKE_GALLERY_VIDEO) {
Uri uri = data.getData();
if (uri != null) {
filePath = uri;
}
}
if (requestCode == REQUEST_TAKE_GALLERY_VIDEO_2) {
Uri uri = data.getData();
if (uri != null) {
filePathSecond = uri;
}
}
}
// video trim
private void executeCutVideoCommand(int startMs, int endMs, Uri filePath) {
File moviesDir = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_MOVIES
);
String filePrefix = "cut_video";
String fileExtn = ".mp4";
String yourRealPath = getPath(MainActivity.this, filePath);
File dest = new File(moviesDir, filePrefix + fileExtn);
int fileNo = 0;
while (dest.exists()) {
fileNo++;
dest = new File(moviesDir, filePrefix + fileNo + fileExtn);
}
/* Log.d(TAG, "startTrim: src: " + yourRealPath);
Log.d(TAG, "startTrim: dest: " + dest.getAbsolutePath());
Log.d(TAG, "startTrim: startMs: " + startMs);
Log.d(TAG, "startTrim: endMs: " + endMs);*/
outPutFile = dest.getAbsolutePath();
//String[] complexCommand = {"-i", yourRealPath, "-ss", "" + startMs / 1000, "-t", "" + endMs / 1000, dest.getAbsolutePath()};
String[] complexCommand = {"-ss",
"" + (startMs / 1000),
"-y",
"-i",
yourRealPath,
"-t",
"" + ((endMs - startMs) / 1000),
"-vcodec",
"mpeg4",
"-b:v",
"2097152",
"-b:a",
"48000",
"-ac",
"2",
"-ar",
"22050",
outPutFile};
execFFmpegBinary(complexCommand);
}
private String getPath(final Context context, final Uri uri) {
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
// DocumentProvider
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
// ExternalStorageProvider
if (isExternalStorageDocument(uri)) {
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
final String type = split[0];
if ("primary".equalsIgnoreCase(type)) {
return Environment.getExternalStorageDirectory() + "/" + split[1];
}
// TODO handle non-primary volumes
}
// DownloadsProvider
else if (isDownloadsDocument(uri)) {
final String id = DocumentsContract.getDocumentId(uri);
final Uri contentUri = ContentUris.withAppendedId(
Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
return getDataColumn(context, contentUri, null, null);
}
// MediaProvider
else if (isMediaDocument(uri)) {
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
final String type = split[0];
Uri contentUri = null;
if ("image".equals(type)) {
contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
} else if ("video".equals(type)) {
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
} else if ("audio".equals(type)) {
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
}
final String selection = "_id=?";
final String[] selectionArgs = new String[]{
split[1]
};
return getDataColumn(context, contentUri, selection, selectionArgs);
}
}
// MediaStore (and general)
else if ("content".equalsIgnoreCase(uri.getScheme())) {
return getDataColumn(context, uri, null, null);
}
// File
else if ("file".equalsIgnoreCase(uri.getScheme())) {
return uri.getPath();
}
}
return null;
}
private boolean isExternalStorageDocument(Uri uri) {
return "com.android.externalstorage.documents".equals(uri.getAuthority());
}
/**
* @param uri The Uri to check.
* @return Whether the Uri authority is DownloadsProvider.
*/
private boolean isDownloadsDocument(Uri uri) {
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
}
/**
* @param uri The Uri to check.
* @return Whether the Uri authority is MediaProvider.
*/
private boolean isMediaDocument(Uri uri) {
return "com.android.providers.media.documents".equals(uri.getAuthority());
}
private String getDataColumn(Context context, Uri uri, String selection,
String[] selectionArgs) {
Cursor cursor = null;
final String column = "_data";
final String[] projection = {
column
};
try {
cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs,
null);
if (cursor != null && cursor.moveToFirst()) {
final int column_index = cursor.getColumnIndexOrThrow(column);
return cursor.getString(column_index);
}
} finally {
if (cursor != null)
cursor.close();
}
return null;
}
private void loadFFMpegBinary() {
try {
if (ffmpeg == null) {
ffmpeg = FFmpeg.getInstance(this);
}
ffmpeg.loadBinary(new LoadBinaryResponseHandler() {
@Override
public void onFailure() {
}
@Override
public void onSuccess() {
}
});
} catch (FFmpegNotSupportedException e) {
} catch (Exception e) {
}
}
private void execFFmpegBinary(final String[] command) {
progressDialog.show();
try {
ffmpeg.execute(command, new ExecuteBinaryResponseHandler() {
@Override
public void onFailure(String s) {
System.out.println("ssss"+s);
}
@Override
public void onSuccess(String s) {
// Log.d(TAG, "SUCCESS with output : " + s);
Toast.makeText(MainActivity.this, "SUCCESS" + outPutFile, Toast.LENGTH_LONG).show();
}
@Override
public void onProgress(String s) {
}
@Override
public void onStart() {
progressDialog.setMessage("Processing...");
progressDialog.show();
}
@Override
public void onFinish() {
progressDialog.dismiss();
}
});
} catch (Exception e ) {
Toast.makeText(MainActivity.this, "EXCEPTION", Toast.LENGTH_LONG).show();
// do nothing for now
}
}
private void executeMargeVideoCommand(Uri filePath, Uri filePathSecond) {
File moviesDir = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_MOVIES
);
String filePrefix = "marge_change_video";
String fileExtn = ".mp4";
String yourRealPath = getPath(MainActivity.this, filePath);
String yourRealPath2 = getPath(MainActivity.this, filePathSecond);
File dest = new File(moviesDir, filePrefix + fileExtn);
int fileNo = 0;
while (dest.exists()) {
fileNo++;
dest = new File(moviesDir, filePrefix + fileNo + fileExtn);
}
outPutFile = dest.getAbsolutePath();
String complexCommand[] = {"-y", "-i", yourRealPath, "-i", yourRealPath2, "-strict", "experimental", "-filter_complex",
"[0:v]scale=iw*min(1920/iw\\,1080/ih):ih*min(1920/iw\\,1080/ih), pad=1920:1080:(1920-iw*min(1920/iw\\,1080/ih))/2:(1080-ih*min(1920/iw\\,1080/ih))/2,setsar=1:1[v0];[1:v] scale=iw*min(1920/iw\\,1080/ih):ih*min(1920/iw\\,1080/ih), pad=1920:1080:(1920-iw*min(1920/iw\\,1080/ih))/2:(1080-ih*min(1920/iw\\,1080/ih))/2,setsar=1:1[v1];[v0][0:a][v1][1:a] concat=n=2:v=1:a=1",
"-ab", "48000", "-ac", "2", "-ar", "22050", "-s", "1920x1080", "-vcodec", "libx264", "-crf", "27",
"-q", "4", "-preset", "ultrafast", outPutFile};
execFFmpegBinary(complexCommand);
}
private void executeFilterCommand(Uri filePath) {
File moviesDir = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_MOVIES
);
String filePrefix = "filter_change_video";
String fileExtn = ".mp4";
String yourRealPath = getPath(MainActivity.this, filePath);
File dest = new File(moviesDir, filePrefix + fileExtn);
int fileNo = 0;
while (dest.exists()) {
fileNo++;
dest = new File(moviesDir, filePrefix + fileNo + fileExtn);
}
outPutFile = dest.getAbsolutePath();
// String complexCommand[] = {"-i", yourRealPath,"-r", "15", "-aspect" ,""+w+":"+""+h ,"-strict" ,"-2",outPutFile};
String complexCommand[] = { "-i",yourRealPath,"-vf", "split [main][tmp]; [tmp] lutyuv=","y=val*5"," [tmp2]; [main][tmp2] overlay", outPutFile};
execFFmpegBinary(complexCommand);
}}