Android ffmpeg无法将音频(.wav文件)与视频(.mp4文件)合并

时间:2015-04-08 05:00:31

标签: android audio video ffmpeg

我正在使用FFMPEG库,我正在使用以下命令将音频(.wav文件)与视频(.mp4文件)合并在一起:

*String commandStr=    "ffmpeg,-y,-i,mnt/sdcard/Scatta/Scattatemp.mp4,-i,/storage/emulated/0/MicDroid/recordings/video.wav ,-strict,experimental,-map,0:0,-map,1:0,-vcodec,mpeg4,-vb,15496k,-ab,128k,-ac,2,-ar,22050,-shortest,mnt/sdcard/Scatta/mergedFile.mp4";

因为我使用以下代码,但我的命令不起作用,我得到Commandvalidation失败异常

GeneralUtils.deleteFileUtil(workFolder + "/vk.log");

        PowerManager powerManager = (PowerManager)_act.getSystemService(Activity.POWER_SERVICE);
        WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "VK_LOCK"); 
        Log.d("Prefs.TAG", "Acquire wake lock");
        wakeLock.acquire();
String commandStr=  "ffmpeg,-y,-i,mnt/sdcard/Scatta/Scattatemp.mp4,-i,/storage/emulated/0/MicDroid/recordings/video.wav ,-strict,experimental,-map,0:0,-map,1:0,-vcodec,mpeg4,-vb,15496k,-ab,128k,-ac,2,-ar,22050,-shortest,mnt/sdcard/Scatta/mergedFile.mp4"   ;

LoadJNI vk = new LoadJNI();
        try {

            vk.run(GeneralUtils.utilConvertToComplex(commandStr), workFolder, getApplicationContext());
            GeneralUtils.copyFileToFolder(vkLogPath, demoVideoFolder);

        } catch (CommandValidationException e) {
            Log.e("Prefs.TAG", "vk run exeption.", e);
            commandValidationFailedFlag = true;
        } catch (Throwable e) {
            Log.e("Prefs.TAG", "vk run exeption.", e);
        }
        finally {
            if (wakeLock.isHeld())
                wakeLock.release();
            else{
                Log.i("Prefs.TAG", "Wake lock is already released, doing nothing");
            }
        }
        Log.i("Prefs.TAG", "doInBackground finished");
    }
    catch(Exception e){
        e.printStackTrace();
        System.out.println(".exception"+e.toString());
    }

我正在接受例外

 04-08 10:00:38.891: D/ffmpeg4android(7781): deleteing: /data/data/org.scatta.androidclient/files//vk.log isdeleted: false
 04-08 10:00:38.891: D/Prefs.TAG(7781): Acquire wake lock
 04-08 10:00:38.896: I/System.out(7781): <--- command strffmpeg -i  mnt/sdcard/Scatta/Scattatemp.mp4 -i    /storage/emulated/0/MicDroid/recordings/video.wav -acodec copy mnt/sdcard/Scatta/mergedFile.mp4
 04-08 10:00:38.896: E/ffmpeg4android(7781): Command validation failed.
 04-08 10:00:38.896: E/ffmpeg4android(7781): Check if input file exists: /storage/emulated/0/MicDroid/recordings/video.wav
    04-08 10:00:38.896: E/Prefs.TAG(7781): vk run exeption.
  04-08 10:00:38.896: E/Prefs.TAG(7781): com.netcompss.ffmpeg4android.CommandValidationException
    04-08 10:00:38.896: E/Prefs.TAG(7781):  at com.netcompss.loader.LoadJNI.run(LoadJNI.java:26)
  04-08 10:00:38.896: E/Prefs.TAG(7781):    at com.scatta.androidclient.ui.PlaybackScreen$TranscdingBackground.doInBackground(PlaybackScreen.java:159)
   04-08 10:00:38.896: E/Prefs.TAG(7781):   at com.scatta.androidclient.ui.PlaybackScreen$TranscdingBackground.doInBackground(PlaybackScreen.java:1)
   04-08 10:00:38.896: E/Prefs.TAG(7781):   at android.os.AsyncTask$2.call(AsyncTask.java:287)
    04-08 10:00:38.896: E/Prefs.TAG(7781):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
    04-08 10:00:38.896: E/Prefs.TAG(7781):  at java.util.concurrent.FutureTask.run(FutureTask.java:137)
  04-08 10:00:38.896: E/Prefs.TAG(7781):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
   04-08 10:00:38.896: E/Prefs.TAG(7781):   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
  04-08 10:00:38.896: E/Prefs.TAG(7781):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
 04-08 10:00:38.896: E/Prefs.TAG(7781):     at java.lang.Thread.run(Thread.java:856)

1 个答案:

答案 0 :(得分:0)

- 您可以看到有错误调用检查您的文件,因此首先检查您的文件是否真的存在或不是您尝试合并。

另一件事是检查命令

Check here

- 以上是与您的回答相关的链接,谢谢!