rtmpdumpでflv(というかm4a)をキャプチャして、その後にffmpegでmp3にする、って手順がなんだかまどろっこしい。何やらffmpegでlibrtmpというrtmpdumpのライブラリがあるじゃないか、それで一気にやっちゃえば良いんじゃないのか、ということでいろいろやってみる。
うまくいけばこのコマンドでらじる★らじるが録れるんじゃないかと想像。
ffmpeg -i "rtmpe://netradio-r1-flash.nhk.jp playpath=NetRadio_R1_flash@63346 app=live swfUrl=http://www3.nhk.or.jp/netradio/files/swf/rtmpe.swf swfVfy=1 live=1" r1test.mp3
追記:
rtmpdumpとopensslを追加してみましたが、
mini:~ admin$ brew install ffmpeg --with-openssl --with-rtmpdump
だけでいけましたwww
mini:~ admin$ brew info ffmpeg ffmpeg: stable 1.2.1, HEAD http://ffmpeg.org/ /usr/local/Cellar/ffmpeg/1.2 (147 files, 26M) Built from source /usr/local/Cellar/ffmpeg/1.2.1 (147 files, 26M) * Built from source with: --with-rtmpdump, --with-openssl From: https://github.com/mxcl/homebrew/commits/master/Library/Formula/ffmpeg.rb ==> Dependencies Build: pkg-config, yasm Recommended: x264, faac, lame, xvid Optional: theora, libvorbis, libvpx, rtmpdump, opencore-amr, libvo-aacenc, libass, openjpeg, speex, schroedinger, fdk-aac, opus, frei0r, libcaca ==> Options --with-fdk-aac Enable the Fraunhofer FDK AAC library --with-ffplay Enable FFplay media player --with-freetype Build with freetype support --with-frei0r Build with frei0r support --with-libass Enable ASS/SSA subtitle format --with-libcaca Build with libcaca support --with-libvo-aacenc Enable VisualOn AAC encoder --with-libvorbis Build with libvorbis support --with-libvpx Build with libvpx support --with-opencore-amr Build with opencore-amr support --with-openjpeg Enable JPEG 2000 image format --with-openssl Enable SSL support --with-opus Build with opus support --with-rtmpdump Enable RTMP protocol --with-schroedinger Enable Dirac video format --with-speex Build with speex support --with-theora Build with theora support --with-tools Enable additional FFmpeg tools --without-faac Build without faac support --without-lame Disable MP3 encoder --without-x264 Disable H.264 encoder --without-xvid Disable Xvid MPEG-4 video encoder
mini:~ admin$ ffmpeg -protocols ffmpeg version 1.2.1 Copyright (c) 2000-2013 the FFmpeg developers built on Jul 31 2013 09:41:41 with Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn) configuration: --prefix=/usr/local/Cellar/ffmpeg/1.2.1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=cc --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid --enable-librtmp --enable-openssl libavutil 52. 18.100 / 52. 18.100 libavcodec 54. 92.100 / 54. 92.100 libavformat 54. 63.104 / 54. 63.104 libavdevice 54. 3.103 / 54. 3.103 libavfilter 3. 42.103 / 3. 42.103 libswscale 2. 2.100 / 2. 2.100 libswresample 0. 17.102 / 0. 17.102 libpostproc 52. 2.100 / 52. 2.100 Supported file protocols: Input: applehttp cache concat crypto data file gopher hls http httpproxy https mmsh mmst pipe rtp srtp tcp tls udp rtmp rtmpe rtmps rtmpt rtmpte Output: file gopher http httpproxy https md5 pipe rtp srtp tcp tls udp rtmp rtmpe rtmps rtmpt rtmpte
↓ここからは無駄な&勘違いな努力の羅列ですorz
まず先人の知恵を参照。
homebrewでパッケージをインストールする際には、
brew install SOMEPACKAGE
のようなコマンドを叩くわけですが、このままではconfigureオプションを変更する事が出来ません。
homebrewでconfigureオプションを変更するにはどこからかFormulaを探してきて、(大抵 github, homebrewのFormulaの箇所 にあるとは思いますが(brew info SOMEPACKAGE で調べる事も出来ます))Formulaを書き換える必要があります。
http://suttang.tumblr.com/post/15518395930/homebrew-configure
また
では他の方の智慧を。
このhomebrew,ほかにもかゆいところに手が届く,よい機能があります.
パッケージのコンパイルオプションなどをカスタマイズしたいとき,ローカルのレシピをすぐに書き換えて,対応できるのです.例えばmsgpackをコンパイルオプションを変えてインストールしたいとき,%brew edit msgpackとすると.
(中略:msgpackのFormulaがエディタ表示されている)
rubyのスクリプトが開かれて,レシピを書き換えることが出来ます.
Macのパッケージ管理ツールhomebrewを試してみた - とあるつくみんの研究日誌
ではこれに従って。
mini:~ admin$ brew info ffmpeg ffmpeg: stable 1.2, HEAD http://ffmpeg.org/ Depends on: pkg-config, yasm, x264, faac, lame, xvid, theora, libvorbis, libvpx, rtmpdump, opencore-amr, libvo-aacenc, libass, openjpeg, speex, schroedinger, fdk-aac, opus, frei0r, libcaca /usr/local/Cellar/ffmpeg/1.2 (147 files, 26M) * Built from source https://github.com/mxcl/homebrew/commits/master/Library/Formula/ffmpeg.rb ==> Options --with-fdk-aac Enable the Fraunhofer FDK AAC library --with-ffplay Enable FFplay media player --with-freetype Build with freetype support --with-frei0r Build with frei0r support --with-libass Enable ASS/SSA subtitle format --with-libcaca Build with libcaca support --with-libvo-aacenc Enable VisualOn AAC encoder --with-libvorbis Build with libvorbis support --with-libvpx Build with libvpx support --with-opencore-amr Build with opencore-amr support --with-openjpeg Enable JPEG 2000 image format --with-opus Build with opus support --with-rtmpdump Enable RTMP protocol --with-schroedinger Enable Dirac video format --with-speex Build with speex support --with-theora Build with theora support --with-tools Enable additional FFmpeg tools --without-faac Build without faac support --without-lame Disable MP3 encoder --without-x264 Disable H.264 encoder --without-xvid Disable Xvid MPEG-4 video encoder
そしてffmpegのFormulaが
https://github.com/mxcl/homebrew/commits/master/Library/Formula/ffmpeg.rb
にあるとのこと。行ってみるとHistoryになってる。いろいろ更新されていくのでしょう。で、最新のFormulaが https://github.com/mxcl/homebrew/blob/de427522b4e4d1c3fb48d3a1addc5b02371be7e7/Library/Formula/ffmpeg.rb のこれ。
(ローカルには /usr/local/Library/Formula/ffmpeg.rb にある)
require 'formula' class Ffmpeg < Formula homepage 'http://ffmpeg.org/' url 'http://ffmpeg.org/releases/ffmpeg-1.2.tar.bz2' sha1 'e1df2389560da95e1a76f9375f054e630c7e2602' head 'git://git.videolan.org/ffmpeg.git' option "without-x264", "Disable H.264 encoder" option "without-lame", "Disable MP3 encoder" option "without-xvid", "Disable Xvid MPEG-4 video encoder" option "with-rtmpdump", "Enable RTMP protocol" option "with-libvo-aacenc", "Enable VisualOn AAC encoder" option "with-libass", "Enable ASS/SSA subtitle format" option "with-openjpeg", 'Enable JPEG 2000 image format' option 'with-schroedinger', 'Enable Dirac video format' option 'with-ffplay', 'Enable FFplay media player' option 'with-tools', 'Enable additional FFmpeg tools' option 'with-fdk-aac', 'Enable the Fraunhofer FDK AAC library' depends_on 'pkg-config' => :build # manpages won't be built without texi2html depends_on 'texi2html' => :build if MacOS.version >= :mountain_lion depends_on 'yasm' => :build depends_on 'x264' => :recommended depends_on 'faac' => :recommended depends_on 'lame' => :recommended depends_on 'xvid' => :recommended depends_on :freetype => :optional depends_on 'theora' => :optional depends_on 'libvorbis' => :optional depends_on 'libvpx' => :optional depends_on 'rtmpdump' => :optional depends_on 'opencore-amr' => :optional depends_on 'libvo-aacenc' => :optional depends_on 'libass' => :optional depends_on 'openjpeg' => :optional depends_on 'sdl' if build.include? 'with-ffplay' depends_on 'speex' => :optional depends_on 'schroedinger' => :optional depends_on 'fdk-aac' => :optional depends_on 'opus' => :optional depends_on 'frei0r' => :optional depends_on 'libcaca' => :optional def install args = ["--prefix=#{prefix}", "--enable-shared", "--enable-pthreads", "--enable-gpl", "--enable-version3", "--enable-nonfree", "--enable-hardcoded-tables", "--enable-avresample", "--enable-vda", "--cc=#{ENV.cc}", "--host-cflags=#{ENV.cflags}", "--host-ldflags=#{ENV.ldflags}" ] args << "--enable-libx264" if build.with? 'x264' args << "--enable-libfaac" if build.with? 'faac' args << "--enable-libmp3lame" if build.with? 'lame' args << "--enable-libxvid" if build.with? 'xvid' args << "--enable-libfreetype" if build.with? 'freetype' args << "--enable-libtheora" if build.with? 'theora' args << "--enable-libvorbis" if build.with? 'libvorbis' args << "--enable-libvpx" if build.with? 'libvpx' args << "--enable-librtmp" #if build.with? 'rtmpdump' args << "--enable-libopencore-amrnb" << "--enable-libopencore-amrwb" if build.with? 'opencore-amr' args << "--enable-libvo-aacenc" if build.with? 'libvo-aacenc' args << "--enable-libass" if build.with? 'libass' args << "--enable-ffplay" if build.include? 'with-ffplay' args << "--enable-libspeex" if build.with? 'speex' args << '--enable-libschroedinger' if build.with? 'schroedinger' args << "--enable-libfdk-aac" if build.with? 'fdk-aac' args << "--enable-openssl" if build.with? 'openssl' args << "--enable-libopus" if build.with? 'opus' args << "--enable-frei0r" if build.with? 'frei0r' args << "--enable-libcaca" if build.with? 'libcaca' if build.with? 'openjpeg' args << '--enable-libopenjpeg' args << '--extra-cflags=' + %x[pkg-config --cflags libopenjpeg].chomp end # For 32-bit compilation under gcc 4.2, see: # http://trac.macports.org/ticket/20938#comment:22 ENV.append_to_cflags "-mdynamic-no-pic" if Hardware.is_32_bit? && Hardware.cpu_type == :intel && ENV.compiler == :clang system "./configure", *args if MacOS.prefer_64_bit? inreplace 'config.mak' do |s| shflags = s.get_make_var 'SHFLAGS' if shflags.gsub!(' -Wl,-read_only_relocs,suppress', '') s.change_make_var! 'SHFLAGS', shflags end end end system "make install" if build.include? 'with-tools' system "make alltools" bin.install Dir['tools/*'].select {|f| File.executable? f} end end end
これを見ていると、
args << "--enable-librtmp" if build.with? 'rtmpdump'
を
args << "--enable-librtmp" #if build.with? 'rtmpdump'
とコメントアウトすれば良いのかな、と想像。
(注意:いじくるときには元ファイルをバックアップしておきましょう)
インストールしようとすると
mini:~ admin$ brew install ffmpeg Warning: ffmpeg-1.2 already installed
と怒られたのでアンインストール。
mini:~ admin$ brew uninstall ffmpeg Uninstalling /usr/local/Cellar/ffmpeg/1.2...
では実行。
mini:~ admin$ brew install -v ffmpeg==> Downloading http://ffmpeg.org/releases/ffmpeg-1.2.tar.bz2Already downloaded: /Library/Caches/Homebrew/ffmpeg-1.2.tar.bz2 tar xf /Library/Caches/Homebrew/ffmpeg-1.2.tar.bz2 ==> ./configure --prefix=/usr/local/Cellar/ffmpeg/1.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=cc --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid --enable-librtmp ./configure --prefix=/usr/local/Cellar/ffmpeg/1.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=cc --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid --enable-librtmp ERROR: librtmp not found 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. ==> Configuration HOMEBREW_VERSION: 0.9.4 HEAD: b7884284c291d05fbe241136409462407901ab85 CPU: quad-core 64-bit sandybridge OS X: 10.7.5-x86_64 Xcode: 4.6.1 CLT: 4.3.0.0.1.1249367152 LLVM-GCC: build 2336 Clang: 3.1 build 318 X11: 2.6.4 => /usr/X11 ==> ENV CC: cc CXX: c++ MAKEFLAGS: -j4 CMAKE_PREFIX_PATH: /usr/local CMAKE_INCLUDE_PATH: /usr/include/libxml2:/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers/ CMAKE_LIBRARY_PATH: /System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries PKG_CONFIG_PATH: /usr/local/opt/x264/lib/pkgconfig PKG_CONFIG_LIBDIR: /usr/lib/pkgconfig ACLOCAL_PATH: /usr/local/share/aclocal OBJC: cc PATH: /usr/local/Library/ENV/4.3:/usr/local/opt/pkg-config/bin:/usr/local/opt/yasm/bin:/usr/local/opt/x264/bin:/usr/local/opt/faac/bin:/usr/local/opt/lame/bin:/usr/bin:/bin:/usr/sbin:/sbin Error: ffmpeg did not build Logs: /Users/admin/Library/Logs/Homebrew/ffmpeg/config.log
…怒られた。
ERROR: librtmp not found
ですか。
ではさらに調べる。
96 :名称未設定:2010/04/08(木) 11:14:30 id:NLi+ok1m0
>>95
rtmpdumpのlibrtmpをインストールして
ffmpegを--enable-librtmpで./configureしても
ERROR: librtmp not found になる…ibrtmpサポート版ffmpeg/mplayerってsvnの最新でいいの?
97 :名称未設定:2010/04/08(木) 11:42:55 id:dXj8Lz010
>>96
うちでは configure オプションに、
--extra-libs="-lssl -lcrypto"
を追加、でビルドできたよ。
http://anago.2ch.net/test/read.cgi/mac/1269337470/96-97
ということで
args <<
がたくさん並んでいる下に
args << "--extra-libs='-lssl -lcrypto'"
を追加してみた。
mini:~ admin$ brew install -v ffmpeg ==> Downloading http://ffmpeg.org/releases/ffmpeg-1.2.tar.bz2 Already downloaded: /Library/Caches/Homebrew/ffmpeg-1.2.tar.bz2 tar xf /Library/Caches/Homebrew/ffmpeg-1.2.tar.bz2 ==> ./configure --prefix=/usr/local/Cellar/ffmpeg/1.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=cc --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid --enable-librtmp --extra-libs='-lssl -lcrypto' ./configure --prefix=/usr/local/Cellar/ffmpeg/1.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=cc --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid --enable-librtmp --extra-libs='-lssl -lcrypto' cc is unable to create an executable file. If cc is a cross-compiler, use the --enable-cross-compile option. Only do this if you know what cross compiling means. C compiler test failed. (以下略)
またNG。コンパイラの問題ですよね。うーむ…。なお環境はLionです。
ffmpeg ver 0.6でlibrtmpが使えるようになったがなぜかうまく動かないのでrtmpdumの標準出力からffmpegの標準入力でどうにかしてしまうのが一番確実ww
メモ/rtmp - PukiWiki
ってことかしら。