Top/article/Encode-H.264-videos-with-ffmpeg
English | Japanese
English | Japanese

Menu

  • Top
  • Akihiko Yamaguchi 山口 明彦
  • Project プロジェクト
  • Text テキスト
  • Recent articles 最近の記事
  • Articles 記事一覧 (a to z)
  • Search 検索

Tags タグ †

  • [c++][bash][python][latex][php]
  • [linux][windows][mac][android]
  • [math][algorithm][idea][trick]
  • [liboctave][opencv][git][ros]
  • [setting][bug][general]
↑

Recent articles 最近の記事 †

2019-07-02
  • article/Display-Unix-Time
  • article/Synchronize-Linux-Time-to-Remote
2018-09-27
  • article/python-multimode-singleton
2018-09-02
  • article/rosinstall-git-default-remote
2017-07-28
  • article/SubMenu
2017-03-05
  • article/Import-a-different-version-of-OpenCV-in-Python
2015-08-17
  • article/DRC-finals-2015
2015-01-05
  • article/Upgrade-Android-to-Lollipop
2015-01-01
  • article/Kernel-panic-of-Linux-when-using-Xtion
  • article/Do-not-skip-freeing-data-when-using-tri-mesh-in-ODE
Access: 3/5274 - Admin

Encode H.264 videos with ffmpeg

ffmpeg で H.264 エンコーディングの動画を作る

[linux][trick]
2010-12-01

HTML5 のvideo要素で使えたり使えなかったりするH.264だが,使えるにこしたことはないと思い,ffmpegでエンコーディングしようとしてみた.少しコツが必要なので,メモしておく.

環境: Debian Squeeze, i686 ffmpeg:

FFmpeg version SVN-r25838, Copyright (c) 2000-2010 the FFmpeg developers
  built on Jan 21 2011 09:10:31 with gcc 4.4.5
  configuration: --enable-libdc1394 --prefix=/usr --extra-cflags='-Wall -g ' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-avfilter --enable-libdirac --disable-decoder=libdirac --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-libvpx --enable-librtmp --extra-libs=-lgcrypt --disable-altivec --disable-armv5te --disable-armv6 --disable-vis

ffmpeg はaptで取得するだけでよかった.

AVI を H.264 でエンコードするコマンド例 †

ffmpeg -i input.avi -vcodec libx264 -b 500k -fpre /usr/share/ffmpeg/libx264-medium.ffpreset output.avi

ポイントは -vcodec libx264 オプション(h264 などではダメ)と, -fpre /usr/share/ffmpeg/libx264-medium.ffpreset オプション(ないとエラー).

仮に -vcodec h264 とかだと,

Unknown encoder 'h264'

というエラーを吐き,-fpre ... がないと,

[scale @ 0x83a1aa0] w:720 h:480 fmt:yuv411p -> w:720 h:480 fmt:yuv420p flags:0xa0000004
[libx264 @ 0x8355100] broken ffmpeg default settings detected
[libx264 @ 0x8355100] use an encoding preset (e.g. -vpre medium)
[libx264 @ 0x8355100] preset usage: -vpre <speed> -vpre <profile>
[libx264 @ 0x8355100] speed presets are listed in x264 --help
[libx264 @ 0x8355100] profile is optional; x264 defaults to high
Output #0, avi, to 'hoge.avi':
    Stream #0.0: Video: libx264, yuv420p, 720x480 [PAR 8:9 DAR 4:3], q=2-31, 500 kb/s, 90k tbn, 29.97 tbc
Stream mapping:
  Stream #0.0 -> #0.0
Error while opening encoder for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height

などというエラーを吐く.

↑

参考 †

  • http://www.fedoraforum.org/forum/showthread.php?t=208066
  • http://ffmpeg-users.933282.n4.nabble.com/libx264-preset-file-not-found-td1017369.html



Last-modified:2015-01-01 (Thu) 09:25:32 (3838d)
Site admin: Akihiko Yamaguchi.
Written by: Akihiko Yamaguchi.
System: PukiWiki 1.5.0. PHP 5.2.17. HTML conversion time: 0.008 sec.