Как импортировать ffmpeg в Android ProjectAndroid

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Как импортировать ffmpeg в Android Project

Сообщение Anonymous »

Я пытаюсь преобразовать серию изображений в видео. FFMPEG выделен красным. Не могли бы вы дать предложение правильно импортировать библиотеки?
< /code>
< /p>












< /code>

my sutures.gradle file < /p>
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
< /code>
} < /p>
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
< /code>
}
rootproject.name = "timelapselite"
include ': app' < /p>
my build.gradle file < /p>
plugins {
id 'com.android.application'
}

android {
namespace 'ae.vpdev.timelapselite'
compileSdk 33

defaultConfig {
applicationId "ae.vpdev.timelapselite"
minSdk 26
targetSdk 33
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
< /code>
} < /p>
dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.arthenica:mobile-ffmpeg-full:4.5.LTS'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
< /code>
} < /p>
My code in MainActivity
private void convertImagesToVideo() {
StringBuilder imageListFileContent = new StringBuilder();
for (Uri imageUri : selectedImages) {
imageListFileContent.append("file '").append(imageUri.getPath()).append("'\n");
}

try {
File imageListFile = new File(getCacheDir(), "image_list.txt");
FileWriter writer = new FileWriter(imageListFile);
writer.append(imageListFileContent.toString());
writer.flush();
writer.close();

File outputFile = new File(getExternalFilesDir(null), "output_video.mp4");
String outputFilePath = outputFile.getAbsolutePath();

String command = "-f concat -safe 0 -i " + imageListFile.getAbsolutePath() +
" -vf \"scale=-2:720\" -r 30 -c:v libx264 -pix_fmt yuv420p " + outputFilePath;

int rc = FFmpeg.execute(command);

if (rc == RETURN_CODE_SUCCESS) {
Log.d("FFmpeg", "Video conversion completed successfully");
// Now you can use the outputFilePath to play or share the video
} else {
Log.d("FFmpeg", "Video conversion failed");
}
} catch (IOException e) {
e.printStackTrace();
}
}


Подробнее здесь: https://stackoverflow.com/questions/768 ... id-project
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»