ノート/ノート
訪問者 4095   最終更新 2007-12-24 (月) 17:55:47

Linuxでビデオデータを作る

ビデオデータフォーマットをいろいろと変更してみたい。そのためには エンコーダに手を加える必要がある。Linuxでないと不都合。

ググった結果

まず、画面キャプチャによってソースデータを作ってみる。

H264へのエンコード

FFmpeg version SVN-r11168, Copyright (c) 2000-2007 Fabrice Bellard, et al.
  configuration: --enable-gpl --enable-libx264 --enable-libxvid  --enable-pthreads --enable-libmp3lame
  libavutil version: 49.5.0
  libavcodec version: 51.48.0
  libavformat version: 52.1.0
  built on Dec 20 2007 16:36:33, gcc: 4.1.2 20070925 (Red Hat 4.1.2-33)
Input #0, avi, from 'nmr1_raw_1.avi':
  Duration: 00:00:20.0, start: 0.000000, bitrate: 753983 kb/s
    Stream #0.0: Video: rawvideo, rgb32, 1028x764 [PAR 0:1 DAR 0:1], 30.00 tb(r)
Output #0, yuv4mpegpipe, to 'nmr1_raw_1.y4m':
    Stream #0.0: Video: rawvideo, yuv420p, 1028x764 [PAR 0:1 DAR 0:1], q=2-31,  200 kb/s, 30.00 tb(c)
Stream mapping:
  Stream #0.0 -> #0.0
Press [q] to stop encoding
frame=  601 fps=  6 q=0.0 Lsize=  691440kB time=20.0 bitrate=282742.6kbits/s
video:0kB audio:0kB global headers:0kB muxing overhead inf%

次にx264でYUV⇒H264変換

Linux上にインストールしたx264(ホームはここ)を使うと

yuv4mpeg: 1028x764@30/1fps, 0:0
x264 [warning]: width or height not divisible by 16 (1028x764), compression will  suffer.
x264 [info]: using cpu capabilities: MMX MMXEXT SSE SSE2 Cache64
x264 [info]: slice I:3     Avg QP:30.33  size: 49692  PSNR Mean Y:35.30 U:44.42 V:45.02 Avg:36.77 Global:32.51
x264 [info]: slice P:598   Avg QP:24.87  size:  1544  PSNR Mean Y:44.38 U:48.10 V:48.42 Avg:45.26 Global:41.27
x264 [info]: mb I  I16..4: 75.5%  0.0% 24.5%
x264 [info]: mb P  I16..4:  2.5%  0.0%  0.2%  P16..4:  6.0%  0.4%  0.2%  0.0%  0.0%    skip:90.8%
x264 [info]: final ratefactor: 37.17
x264 [info]: SSIM Mean Y:0.9924697
x264 [info]: PSNR Mean Y:44.337 U:48.078 V:48.405 Avg:45.219 Global:41.134  kb/s:428.27

encoded 601 frames, 4.22 fps, 428.80 kb/s

もう1度少し小さいデータで同じプロセスを行う

[root@salt nmr1]# ffmpeg -i nmr2_raw.avi -pix_fmt yuv420p -f yuv4mpegpipe nmr2_raw.y4m
FFmpeg version SVN-r11168, Copyright (c) 2000-2007 Fabrice Bellard, et al.
  configuration: --enable-gpl --enable-libx264 --enable-libxvid --enable-pthreads  --enable-libmp3lame
  libavutil version: 49.5.0
  libavcodec version: 51.48.0
  libavformat version: 52.1.0
  built on Dec 20 2007 16:36:33, gcc: 4.1.2 20070925 (Red Hat 4.1.2-33)
Input #0, avi, from 'nmr2_raw.avi':
  Duration: 00:00:08.5, start: 0.000000, bitrate: 317038 kb/s
    Stream #0.0: Video: rawvideo, rgb32, 688x480 [PAR 0:1 DAR 0:1], 30.00 tb(r)
File 'nmr2_raw.y4m' already exists. Overwrite ? [y/N] y
Output #0, yuv4mpegpipe, to 'nmr2_raw.y4m':
   Stream #0.0: Video: rawvideo, yuv420p, 688x480 [PAR 0:1 DAR 0:1], q=2-31, 200  kb/s, 30.00 tb(c)
Stream mapping:
  Stream #0.0 -> #0.0
Press [q] to stop encoding
frame=  257 fps= 15 q=0.0 Lsize=  124325kB time=8.6 bitrate=118887.9kbits/s
video:0kB audio:0kB global headers:0kB muxing overhead inf%
[root@salt nmr1]# x264 -B 512 -o nmr2_raw.mkv nmr2_raw.y4m
yuv4mpeg: 688x480@30/1fps, 0:0
x264 [info]: using cpu capabilities: MMX MMXEXT SSE SSE2 Cache64
x264 [info]: slice I:2     Avg QP:23.00  size: 34874  PSNR Mean Y:46.35 U:49.65  V:49.39 Avg:47.11 Global:40.06
x264 [info]: slice P:255   Avg QP:12.06  size:  1423  PSNR Mean Y:55.65 U:58.76  V:58.13 Avg:56.31 Global:49.35
x264 [info]: mb I  I16..4: 63.6%  0.0% 36.4%
x264 [info]: mb P  I16..4:  2.5%  0.0%  0.7%  P16..4: 10.5%  0.2%  0.2%  0.0%   0.0%    skip:85.7%
x264 [info]: final ratefactor: 14.31
x264 [info]: SSIM Mean Y:0.9982503
x264 [info]: PSNR Mean Y:55.577 U:58.687 V:58.065 Avg:56.237 Global:49.101  kb/s:403.98

encoded 257 frames, 10.71 fps, 404.53 kb/s
yuv4mpeg: 688x480@30/1fps, 0:0
x264 [info]: using cpu capabilities: MMX MMXEXT SSE SSE2 Cache64
x264 [debug]: frame=   0 QP=36 NAL=3 Slice:I Poc:0   I:1290 P:0    SKIP:0    size=7529 bytes PSNR Y:35.96 U:41.02 V:41.08 SSIM Y:0.9744 9
x264 [debug]: frame=   1 QP=36 NAL=2 Slice:P Poc:10  I:6    P:49   SKIP:1235 size=197 bytes PSNR Y:35.99 U:41.03 V:41.10 SSIM Y:0.97476
x264 [debug]: frame=   2 QP=38 NAL=0 Slice:B Poc:2   I:0    P:0    SKIP:1288 size=63 bytes PSNR Y:35.97 U:41.02 V:41.10 SSIM Y:0.97469
x264 [debug]: frame=   3 QP=38 NAL=0 Slice:B Poc:4   I:1    P:3    SKIP:1285 size=180 bytes PSNR Y:35.94 U:41.02 V:41.10 SSIM Y:0.97474
x264 [debug]: frame=   4 QP=38 NAL=0 Slice:B Poc:6   I:0    P:1    SKIP:1287 size=101 bytes PSNR Y:35.96 U:41.02 V:41.10 SSIM Y:0.97470
x264 [debug]: frame=   5 QP=38 NAL=0 Slice:B Poc:8   I:0    P:1    SKIP:1287 size=87 bytes PSNR Y:35.94 U:41.02 V:41.10 SSIM Y:0.97469
x264 [debug]: frame=   6 QP=35 NAL=2 Slice:P Poc:20  I:10   P:35   SKIP:1245 size=358 bytes PSNR Y:36.00 U:41.04 V:41.17 SSIM Y:0.97487
x264 [debug]: frame=   7 QP=38 NAL=0 Slice:B Poc:12  I:0    P:4    SKIP:1285 size=75 bytes PSNR Y:36.00 U:41.04 V:41.15 SSIM Y:0.97491
x264 [debug]: frame=   8 QP=38 NAL=0 Slice:B Poc:14  I:0    P:4    SKIP:1285 size=111 bytes PSNR Y:35.99 U:41.04 V:41.15 SSIM Y:0.97484
x264 [debug]: frame=   9 QP=38 NAL=0 Slice:B Poc:16  I:0    P:2    SKIP:1285 size=98 bytes PSNR Y:35.99 U:41.04 V:41.15 SSIM Y:0.97484
x264 [debug]: frame=  10 QP=37 NAL=0 Slice:B Poc:18  I:0    P:4    SKIP:1285 size=86 bytes PSNR Y:36.00 U:41.04 V:41.15 SSIM Y:0.97484
x264 [debug]: frame=  11 QP=33 NAL=2 Slice:P Poc:30  I:33   P:179  SKIP:1078 size=1027 bytes PSNR Y:36.47 U:41.05 V:41.21 SSIM Y:0.97632
x264 [debug]: frame=  12 QP=37 NAL=0 Slice:B Poc:22  I:0    P:3    SKIP:1286 size=109 bytes PSNR Y:36.36 U:41.05 V:41.20 SSIM Y:0.97604
x264 [debug]: frame=  13 QP=36 NAL=0 Slice:B Poc:24  I:0    P:3    SKIP:1286 size=138 bytes PSNR Y:36.36 U:41.05 V:41.20 SSIM Y:0.97604
x264 [debug]: frame=  14 QP=36 NAL=0 Slice:B Poc:26  I:0    P:4    SKIP:1286   size=77 bytes PSNR Y:36.33 U:41.05 V:41.20 SSIM Y:0.97606
x264 [debug]: frame=  15 QP=36 NAL=0 Slice:B Poc:28  I:0    P:3    SKIP:1286 size=120 bytes PSNR Y:36.37 U:41.05 V:41.20 SSIM Y:0.97604

RGP/BMP ⇒ YUVの変換について

AVI形式

MEncoder (MPlayerと同梱)

x264ソースを見る


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2007-12-24 (月) 17:55:47 (3445d)