私はこのコマンドを使用して、新しいオーディオを持っている。ここFILE1 FILE2は私のaudio.mp3と出力がoutput.mp4だろうで、私のvideo.mp4です:Androidでffmpegコマンドを実行すると、「 '-map 0:v:0 -map 1:a:0'」の適切な出力形式を見つけることができません。
以下complexCommand = new String[]{"-y", "-i", file1.toString(), "-i", file2.toString(), "-c", "copy", " -map 0:v:0 -map 1:a:0", rootPath + "/output.mp4"};
は私のコードです:
以下private void changeAudioofVideo(String selectedUri, String videoPath) {
String[] complexCommand;
File f = new File("/storage/emulated/0");
if (!f.getParentFile().exists())
f.getParentFile().mkdirs();
if (!f.exists())
try {
f.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
file1 = new File(videoPath);
if (file1.exists()) {
Log.d("yes", "File 1 exists");
} else {
Log.d("no", "File 1 not exists");
}
file2 = new File(selectedUri);
if (file2.exists()) {
Log.d("yes", "File 1 exists");
} else {
Log.d("no", "File 1 not exists");
}
String rootPath = f.getPath();
complexCommand = new String[]{"-y", "-i", file1.toString(), "-i", file2.toString(), "-c", "copy", " -map 0:v:0 -map 1:a:0", rootPath + "/output.mp4"};
FFmpeg ffmpeg = FFmpeg.getInstance(this);
try {
//Load the binary
ffmpeg.loadBinary(new LoadBinaryResponseHandler() {
@Override
public void onStart() {
}
@Override
public void onFailure() {
}
@Override
public void onSuccess() {
}
@Override
public void onFinish() {
}
});
} catch (FFmpegNotSupportedException e) {
// Handle if FFmpeg is not supported by device
Toast.makeText(getApplicationContext(), "Not Supported by Device", Toast.LENGTH_LONG).show();
}
try {
final String finalRootPath = rootPath;
ffmpeg.execute(complexCommand, new FFmpegExecuteResponseHandler() {
@Override
public void onSuccess(String message) {
Log.d("Success", message);
Toast.makeText(getApplicationContext(), "Successful" + finalRootPath.toString(), Toast.LENGTH_LONG).show();
Uri path = Uri.parse(finalRootPath + "/output.mp4");
playVideo(path.toString());
}
@Override
public void onProgress(String message) {
Log.d("progress", message);
pd.show();
}
@Override
public void onFailure(String message) {
Log.d("failure", message);
pd.dismiss();
}
@Override
public void onStart() {
Log.d("Start", "merge started");
}
@Override
public void onFinish() {
Log.d("finish", "merge finish");
pd.dismiss();
}
});
} catch (FFmpegCommandAlreadyRunningException e) {
e.printStackTrace();
}
}
は私の出力です:
05-26 18:39:35.533 29188-29188/com.example.codal.videotm D/failure: 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-and roid/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, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/videokit/out2.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf56.23.100
comment : Courtesy of National Geographic. Used by Permission.
Duration: 00:00:04.20, start: 0.046440, bitrate: 577 kb/s
Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v/0x7634706D), yuv420p, 160x120 [SAR 9:16 DAR 3:4], 521 kb/s, 30 fps, 30 tbr, 15360 tbn, 30 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a/0x6134706D), 22050 Hz, stereo, fltp, 50 kb/s (default)
Metadata:
handler_name : SoundHandler
[mp3 @ 0xb86ade60] Skipping 0 bytes of junk at 132692.
[mjpeg @ 0xb86c9980] Changing bps to 8
[mp3 @ 0xb86ade60] Estimating duration from bitrate, this may be inaccurate
Input #1, mp3, from '/storage/emulated/0/Download/01 Kaari Kaari - Dobaara.mp3':
Metadata:
album : Dobaara (SongsMp3.Co)
artist : Arko , Asees Kaur
album_artist : Arko & Asees Kaur
composer : Arko
performer : SongsMp3.Co
copyright : SongsMp3.Co
disc : 1/1
encoded_by : iTunes 12.6.0.100
genre : Bollywood
TEXT : SongsMp3.Co
TPE4 : SongsMp3.Co
TRSN : SongsMp3.Co
TOPE : SongsMp3.Co
TOLY : SongsMp3.Co
publisher : SongsMp3.Co
title : Kaari Kaari (SongsMp3.Co)
track : 1/1
date : 2017
Duration: 00:03:46.72, start: 0.000000, bitrate: 324 kb/s
Stream #1:0: Audio: mp3, 44100 Hz, stereo, s16p, 320 kb/s
Stream #1:1: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 600x600 [SAR 96:96 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
Metadata:
comment : Cover (front)
[NULL @ 0xb86cab70] Unable to find a suitable output format for ' -map 0:v:0 -map 1:a:0'
-map 0:v:0 -map 1:a:0: Invalid argument
05-26 18:39:35.543 29188-29188/com.example.codal.videotm D/ViewRootImpl: #3 mView = null
05-26 18:39:35.543 29188-29188/com.example.codal.videotm D/finish: merge finish
、ffmpegのは、その*出力*ファイルがあることを言います/ out1.mp4 -i/storage/emulated/0 /ダウンロード/ 01 Kaari Kaari - Dobaara.mp3コーデックコピー - ショート/ストレージ/エミュレート/ 0/output.mp4 " - 明らかに間違っている、ストレージ/エミュレート/ 0 /出力。あなたのコマンドは適切にフォーマットされていないので、ソースコードからffmpegを呼び出す方法にエラーがあるはずです。しかし、完全なコードや 'complexCommand'の値は表示していません。 – slhck
@slhck私の質問が更新されました –