wma 形式のファイルを Mac でも再生できるフォーマットに変換しようとしたときに、FFmpeg がいいというのは見かけたけどインストールがよくわからなくて、Homebrew なら簡単らしいけど Homebrew 自体何するものかよくわからないので使いたくない、便利で簡単だけで仕組みがわからないままではいたくない!で断念したんですが(それなら便利な道具を使った方がいいんでないかというのはおいといて…)Facebook のコメントで再び見かけてしまったのでがんばったよー!
GitHub で FFmpeg/FFmpeg をダウンロード。インストール方法を見ながら解凍して、ターミナルでそのフォルダに移動して
$ ./configure
そしてエラー。
If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "config.log" produced by configure as this will help
solving the problem.
config.log を見てみなさいって。
config.log を確認
暗号が並んでいたけどエラーっぽいのが最後にあった!
yasm/nasm not found or too old. Use --disable-yasm for a crippled build.
–disable-yasm つけれって言われてる。
$ ./configure --disable-yasm
いけたっ!
WARNING: pkg-config not found, library detection may fail.
今ログ見直してたら警告出てたけど、インストール終わってるから別にいいよね…?
make!
$ make
おおー動いてるー!
sudo make install!
$ sudo make install
なんともかっちょいいコマンドですよね。よくわからないログもだだだーっと出てくるし、私今すごいことやってる感がジワジワでニヨニヨです。そして無事完了した!
FFmpeg のヘルプ
$ ffmpeg -h
ffmpeg version 2.2.1 Copyright (c) 2000-2014 the FFmpeg developers
built on May 2 2014 18:45:48 with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
configuration: --disable-yasm
libavutil 52. 66.100 / 52. 66.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 2.100 / 4. 2.100
libswscale 2. 5.102 / 2. 5.102
libswresample 0. 18.100 / 0. 18.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
Getting help:
-h -- print basic options
-h long -- print more options
-h full -- print all options (including all format and codec specific options, very long)
See man ffmpeg for detailed description of the options.
Print help / information / capabilities:
-L show license
-h topic show help
-? topic show help
-help topic show help
--help topic show help
-version show version
-buildconf show build configuration
-formats show available formats
-codecs show available codecs
-decoders show available decoders
-encoders show available encoders
-bsfs show available bit stream filters
-protocols show available protocols
-filters show available filters
-pix_fmts show available pixel formats
-layouts show standard channel layouts
-sample_fmts show available audio sample formats
-colors show available color names
Global options (affect whole program instead of just one file:
-loglevel loglevel set logging level
-v loglevel set logging level
-report generate a report
-max_alloc bytes set maximum size of a single allocated block
-y overwrite output files
-n never overwrite output files
-stats print progress report during encoding
-max_error_rate ratio of errors (0.0: no errors, 1.0: 100% error maximum error rate
-bits_per_raw_sample number set the number of bits per raw sample
-vol volume change audio volume (256=normal)
Per-file main options:
-f fmt force format
-c codec codec name
-codec codec codec name
-pre preset preset name
-map_metadata outfile[,metadata]:infile[,metadata] set metadata information of outfile from infile
-t duration record or transcode "duration" seconds of audio/video
-to time_stop record or transcode stop time
-fs limit_size set the limit file size in bytes
-ss time_off set the start time offset
-timestamp time set the recording timestamp ('now' to set the current time)
-metadata string=string add metadata
-target type specify target file type ("vcd", "svcd", "dvd", "dv", "dv50", "pal-vcd", "ntsc-svcd", ...)
-apad audio pad
-frames number set the number of frames to record
-filter filter_graph set stream filtergraph
-filter_script filename read stream filtergraph description from a file
-reinit_filter reinit filtergraph on input parameter changes
Video options:
-vframes number set the number of video frames to record
-r rate set frame rate (Hz value, fraction or abbreviation)
-s size set frame size (WxH or abbreviation)
-aspect aspect set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)
-bits_per_raw_sample number set the number of bits per raw sample
-vn disable video
-vcodec codec force video codec ('copy' to copy stream)
-timecode hh:mm:ss[:;.]ff set initial TimeCode value.
-pass n select the pass number (1 to 3)
-vf filter_graph set video filters
-b bitrate video bitrate (please use -b:v)
-dn disable data
Audio options:
-aframes number set the number of audio frames to record
-aq quality set audio quality (codec-specific)
-ar rate set audio sampling rate (in Hz)
-ac channels set number of audio channels
-an disable audio
-acodec codec force audio codec ('copy' to copy stream)
-vol volume change audio volume (256=normal)
-af filter_graph set audio filters
Subtitle options:
-s size set frame size (WxH or abbreviation)
-sn disable subtitle
-scodec codec force subtitle codec ('copy' to copy stream)
-stag fourcc/tag force subtitle tag/fourcc
-fix_sub_duration fix subtitles duration
-canvas_size size set canvas size (WxH or abbreviation)
-spre preset set the subtitle options to the indicated preset
mp4 動画から音声のみを m4a 形式で抽出
Facebook で教えていただいたのがこちら。
ffmpeg -i in.mp4 -vn -acodec copy out.m4a
FFmpeg のヘルプから抜粋。
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
-vn disable video
-acodec codec force audio codec ('copy' to copy stream)
-i は入力ファイルがある場合に必要で、-vn はビデオの無効化、-acodec copy は入力ファイルの音声コーデックをそのまま使うってことで、out.m4a は出力ファイル名。
wma を m4a に変換
wma 形式のファイルを Mac でも再生できるフォーマットに変換でやったことを FFmpeg でやってみます!テスト用変換元データのファイルサイズは 797 KB のものを使用。
$ ffmpeg -i in.wma
ffmpeg version 2.2.1 Copyright (c) 2000-2014 the FFmpeg developers
built on May 2 2014 18:45:48 with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
configuration: --disable-yasm
libavutil 52. 66.100 / 52. 66.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 2.100 / 4. 2.100
libswscale 2. 5.102 / 2. 5.102
libswresample 0. 18.100 / 0. 18.100
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, asf, from 'in.wma':
Duration: 00:03:14.36, start: 0.000000, bitrate: 32 kb/s
Stream #0:0: Audio: wmav2 (a[1][0][0] / 0x0161), 44100 Hz, mono, fltp, 32 kb/s
普通に変換すると、
$ ffmpeg -i in.wma out.m4a
[aac @ 0x7ff8a901d000] The encoder 'aac' is experimental but experimental codecs are not enabled, add '-strict -2' if you want to use it.
-strict -2 つけてねって言われてる。ヘルプにないぞこれ。
$ ffmpeg -i in.wma -strict -2 out.m4a
Output #0, ipod, to 'out.m4a':
Metadata:
encoder : Lavf55.33.100
Stream #0:0: Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 128 kb/s
でけた!しかしファイルサイズが 3.2 MB でかすぎるw iTunes の AAC エンコーダ 設定「音声 Podcast」の詳細を参考に、ビットレートとサンプリングレートを設定をしてみる。設定方法はこちらを参考にさせていただきました!ffmpeg 使い方|てくめも@ecoop.net
$ ffmpeg -i in.wma -strict -2 -ab 32k -ar 22050 -ac 1 out.m4a
Output #0, ipod, to 'out.m4a':
Metadata:
encoder : Lavf55.33.100
Stream #0:0: Audio: aac (mp4a / 0x6134706D), 22050 Hz, mono, fltp, 32 kb/s
これでファイルサイズ 803 KB になりました。iTunes の方にある「ボイスフィルタを使用、MMX/SSE2 に最適化」をというのはよくわからんけど、iTunes の変換結果と同じくらいのファイルサイズになったんで、これでよしとします。
ボイスレコーダーのファイルを変換するのに、いちいち Windows の iTunes 起動しなくてもよくなったー!やったー!