背景
Black Box Explorerを使用して書き出した動画が納得いかなかったので調べてみました。
追記)この認識がそもそもの間違いとわかりましたが、それはまた後ほど(^^;
Black Boxログを映像化するツール
blackbox_renderというコマンドラインツールがあります。
https://github.com/cleanflight/blackbox-tools/releases
macOS用のバイナリをダウンロード、解凍後適当なパスの通ったフォルダにコピーする。
$ blackbox_render --help
Blackbox flight log renderer by Nicholas Sherlock (v0.4.3, Jan 25 2017 12:52:40)
Usage:
blackbox_render [options] <logfilename.txt>
Options:
--help This page
--index <num> Choose which log from the file should be rendered
--width <px> Choose the width of the image (default 1920)
--height <px> Choose the height of the image (default 1080)
--fps FPS of the resulting video (default 30)
--threads Number of threads to use to render frames (default 3)
--prefix <filename> Set the prefix of the output frame filenames
--start <x:xx> Begin the log at this time offset (default 0:00)
--end <x:xx> End the log at this time offset
--[no-]draw-pid-table Show table with PIDs and gyros (default on)
--[no-]draw-craft Show craft drawing (default on)
--[no-]draw-sticks Show RC command sticks (default on)
--[no-]draw-time Show frame number and time in bottom right (default on)
--[no-]plot-motor Draw motors on the upper graph (default on)
--[no-]plot-pid Draw PIDs on the lower graph (default off)
--[no-]plot-gyro Draw gyroscopes on the lower graph (default on)
--smoothing-pid <n> Smoothing window for the PIDs (default 4)
--smoothing-gyro <n> Smoothing window for the gyroscopes (default 2)
--smoothing-motor <n> Smoothing window for the motors (default 2)
--unit-gyro <raw|degree> Unit for the gyro values in the table (default raw)
--prop-style <name> Style of propeller display (pie/blades, default pie)
--gapless Fill in gaps in the log with straight lines
--raw-amperage Print the current sensor ADC value along with computed amperage
$
$
$ blackbox_render LOG00002.BFL
デフォルトは1920x1080、30fpsで連番のpngファイルが生成されます。スティック動作はMODE2固定っぽいですね。MODE1な方にはバイナリではなくソースからビルドして設定を変える必要があるのかもしれません。
連番画像ファイルを動画にする
ffmpegで連番画像から動画生成 / 動画から連番画像を生成
のように画像ファイルから動画を作りDVR動画と合成できる準備をします。
何時入れたのか記憶にないffmpegのインストールは割愛。検索すれば山ほど出てくると思います。
$ ffmpeg -framerate 30 -i LOG00002.01.000%03d.png -vcodec libx264 -pix_fmt yuv420p -r 60 out.mp4
これだと背景が黒になってしまうのでアルファチャンネルを扱えるフォーマットを調べます。
Raw Video、QT Animation、Apple ProRes、Ut video等々。基本的に可逆圧縮でないとアルファの保持ができないっぽいですね。ベタ塗りが多い場合の圧縮効率が良くなるQT Animationを使用するようにします。
$ ffmpeg -framerate 30 -i LOG00002.01.000%03d.png -vcodec libx264 -pix_fmt argb -c:v qtrle -r 60 out.mov
動画を編集する
iMovieはアルファチャンネル動画の合成をサポートしておりますので、あとは、iMovieにてDVR映像にout.movを重ねると・・・バッチリですね。
ログを検証するのが目的なのか綺麗に動画を仕上げるのが目的なのか・・・orz
と思って色々調べていたら、そもそもBlackBox Explorerでログを読み込んだ後に、ビデオファイルを読み込んだら、GUIで簡単にいろんな設定ができることがわかりました。今までできなかったのはDVRの保存したAVIファイルを直接指定して読み込ませようとしていましたが、フォーマットが対応していないのか?そのままでは読み込めず一度mp4などに変換する必要があったみたいですorz