Pouvez-vous me faire savoir, si la commande ci-dessous est le correct pour la fusion audio vidéo?FFmpeg audio vidéo fusion commader
vabsolutePath = fichier vidéo chemin absolu (seulement vidéo),
aabsolutePath = chemin absolu du fichier audio (audio seulement)
String ccommand[] = {"-i",vabsolutePath,"-i",aabsolutePath, "-c:v", "copy", "-c:a", "aac","-shortest", dabsolutePath};
Le code suivant est utilisé dans les applications pour la fusion. Ici le problème est que le code est en cours d'exécution, mais le fichier de fusion en sortie "result.mp4" n'est pas jouable/non produit. Pourriez-vous s'il vous plaît aider à trouver le problème dans le code/commande?
public class Mrge extends AppCompatActivity {
private Button var_button_save,var_button_send;
Uri vuri=null;
public String vabsolutePath=null, aabsolutePath=null, dabsolutePath=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.message_layout);
OutputStream out;
try {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
InputStream ins = getResources().openRawResource(
getResources().getIdentifier("anvkl",
"raw", getPackageName()));
byte[] buf = new byte[1024];
int n;
while (-1 != (n = ins.read(buf)))
stream.write(buf, 0, n);
byte[] bytes = stream.toByteArray();
String root = Environment.getExternalStorageDirectory().getAbsolutePath() + "/";
File createDir = new File(root + "master" + File.separator);
createDir.mkdir();
File file = new File(root + "master" + File.separator + "master.mp4");
file.createNewFile();
out = new FileOutputStream(file);
out.write(bytes);
out.close();
vabsolutePath = file.getAbsolutePath();
//-------------------------------------------------------------------
ins = getResources().openRawResource(
getResources().getIdentifier("audio",
"raw", getPackageName()));
while (-1 != (n = ins.read(buf)))
stream.write(buf, 0, n);
bytes = stream.toByteArray();
root = Environment.getExternalStorageDirectory().getAbsolutePath() + "/";
createDir = new File(root + "audio" + File.separator);
createDir.mkdir();
file = new File(root + "audio" + File.separator + "audio.aac");
file.createNewFile();
out = new FileOutputStream(file);
out.write(bytes);
out.close();
aabsolutePath = file.getAbsolutePath();
root = Environment.getExternalStorageDirectory().getAbsolutePath() + "/";
createDir = new File(root + "result" + File.separator);
createDir.mkdir();
file = new File(root + "result" + File.separator + "result.mp4");
file.createNewFile();
dabsolutePath = file.getAbsolutePath();
//------------------------------------------------------------------------
} catch (IOException e) {
e.printStackTrace();
}
String ccommand[] = {"-y", "-i",vabsolutePath,"-i",aabsolutePath, "-c:v", "copy", "-c:a", "aac","-shortest", dabsolutePath};
loadFFMpegBinary();
execFFmpegBinary(ccommand);
}
FFmpeg ffmpeg;
private void loadFFMpegBinary() {
try {
if (ffmpeg == null) {
ffmpeg = FFmpeg.getInstance(this);
}
ffmpeg.loadBinary(new LoadBinaryResponseHandler() {
@Override
public void onFailure() {
//showUnsupportedExceptionDialog();
}
@Override
public void onSuccess() {
}
});
} catch (FFmpegNotSupportedException e) {
//showUnsupportedExceptionDialog();
} catch (Exception e) {
}
}
private void execFFmpegBinary(final String[] command) {
try {
ffmpeg.execute(command, new ExecuteBinaryResponseHandler()
{
@Override
public void onFailure(String s) {
}
@Override
public void onSuccess(String s) {
}
@Override
public void onProgress(String s) {
}
@Override
public void onStart() {
}
@Override
public void onFinish() {
}
});
} catch (FFmpegCommandAlreadyRunningException e) {
String m="hi";
}
}
}
Pour les prochaines questions, veuillez préciser si vous avez besoin d'aide pour l'implémentation de la commande 'ffmpeg' dans votre code, ou si vous avez besoin d'aide pour utiliser' ffmpeg' lui-même. Si ce dernier cas, supprimez le niveau de complexité supplémentaire du code/script et posez toute nouvelle question sur [su]. Incluez la commande 'ffmpeg', non écrite, et la sortie complète du journal/console de la commande. – LordNeckbeard