2017-05-18 5 views
0

元のビデオにテキストを追加して新しいビデオを作成するのにかかる時間を短縮したいFFmpeg 私は検索しようとしていました。FFmpegで変換/圧縮時間を短縮する方法とコマンドをマージする方法は?

-y -i /sdcard/videokit/in.mp4 -strict experimental -vcodec libx264 -preset ultrafast -crf 24 -acodec aac -ar 44100 -ac 2 -b 36000k -s 1280x720 -aspect 16:9 -metadata:s:v:0 rotate=0 /sdcard/videokit/out3.mp4 

は今、私はビデオにテキストを追加すると、それは、このコマンドとその100%の作業により、FFmpegので行われます。

String[] addTextCommand = { 
      "-i", 
      "" + realFilePath, 
      "-vf", 
      "drawtext=fontsize=50:fontfile=/storage/emulated/0/Download/Cerbetica-regular.ttf:fontcolor=red:text='" 
        + strText + 
        "':x=0:y=0: box=1: [email protected]:boxborderw=10: x=0: y=(h-text_h)/2", 
      "-strict", 
      "-2", 
      outputFilePath}; 

今私の問題は、私は、この2つのコードをマージして1つのコマンドは、編集したビデオを作成し、また、新しい動画を作成するために、少ない時間を取るために作るのですかどのようです。この中で、私はこのコマンドを試しましたが、うまくいきません。

String[] addTextCommand = { 
      "-i", 
      "" + realVideoPath, 
      "-vf", 
      "-c:v", "libx264", 
      "-preset", "ultrafast", 
      "-crf", "24", 
      "-acodec", "aac", 
      "-ar", "44100", 
      "-ac", "2", 
      "-b", "36000k", 
      "-s", "1280x720", 
      "-aspect", "16:9", 
      "-metadata:s:v:0 rotate=0", 
      "drawtext=fontsize=50:fontfile=/storage/emulated/0/Download/Cerbetica-regular.ttf:fontcolor=red:text='" 
        + strText + 
        "':x=0:y=0: box=1: [email protected]:boxborderw=10: x=0: y=(h-text_h)/2", 
      "-strict", 
      "-2", 
      outputFilePath}; 

誰がFFmpegののコマンドを作成する方法のアイデアを持っている場合はそれを記述し、それを使用する方法を説明してください。

@Mulvyaのコマンドを使用して、コンソールでこれを取得しました。

 D/MainActivity: FAILED with output : WARNING: linker: /data/user/0/com.inheritx.videoprocessing/files/ffmpeg has text relocations. This is wasting memory and prevents security hardening. Please fix. 
        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/i686-linux-android- --arch=x86 --cpu=i686 --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/x86 --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all -march=i686' --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 
        Unrecognized option '2'. 
        Error splitting the argument list: Option not found 
    D/MainActivity: Finished command : ffmpeg -i 
    D/MainActivity: Finished command : ffmpeg /storage/emulated/0/Download/spacetestSMALL_512kb.mp4 
    D/MainActivity: Finished command : ffmpeg -vf 
    D/MainActivity: Finished command : ffmpeg drawtext=fontsize=50:fontfile=/system/fonts/DroidSans.ttf:fontcolor=red:text='Hello':x=0:y=0: box=1: [email protected]:boxborderw=10: x=0: y=(h-text_h)/2 
    D/MainActivity: Finished command : ffmpeg -c:v 
    D/MainActivity: Finished command : ffmpeg libx264 
    D/MainActivity: Finished command : ffmpeg -preset 
    D/MainActivity: Finished command : ffmpeg ultrafast 
    D/MainActivity: Finished command : ffmpeg -crf 
    D/MainActivity: Finished command : ffmpeg 24 
    D/MainActivity: Finished command : ffmpeg -acodec 
    D/MainActivity: Finished command : ffmpeg aac 
    D/MainActivity: Finished command : ffmpeg -ar 
    D/MainActivity: Finished command : ffmpeg 44100 
    D/MainActivity: Finished command : ffmpeg -s 
    D/MainActivity: Finished command : ffmpeg 1280x720 
    D/MainActivity: Finished command : ffmpeg -aspect 
    D/MainActivity: Finished command : ffmpeg 16:9 
    D/MainActivity: Finished command : ffmpeg -metadata:s:v:0 rotate=0 
    D/MainActivity: Finished command : ffmpeg -strict 
    D/MainActivity: Finished command : ffmpeg -2 
    D/MainActivity: Finished command : ffmpeg /storage/emulated/0/Movies/add_text25.mp4 

答えて

0

使用

String[] addTextCommand = { 
      "-i", 
      "" + realVideoPath, 
      "-vf", 
      "drawtext=fontsize=50:fontfile=/storage/emulated/0/Download/Cerbetica-regular.ttf:fontcolor=red:text='" 
        + strText + 
        "':x=0:y=0: box=1: [email protected]:boxborderw=10: x=0: y=(h-text_h)/2", 
      "-c:v", "libx264", 
      "-preset", "ultrafast", 
      "-crf", "24", 
      "-acodec", "aac", 
      "-ar", "44100", 
      "-ac", "2", 
      "-s", "1280x720", 
      "-aspect", "16:9", 
      "-metadata:s:v:0 rotate=0", 
      "-strict", 
      "-2", 
      outputFilePath}; 

のDrawText文字列は、ビデオフィルタオプションの引数ですが、あなたはそれらを分離しました。

+0

私はこのエラーを受け取りました。 "認識できないオプション '2'引数リストの分割エラー:オプションが見つかりません" –

+0

コンソール出力を表示します。 – Mulvya

+0

ログレベルが十分ではありません。 '-report'を追加してください。作成されたログファイルを共有します。 – Mulvya

関連する問題