'MP4'에 해당되는 글 1건

  1. 2009.06.14 FFMPEG /X264를 MAC에서 빌드
Embedded2009. 6. 14. 09:05

FFMPEG /X264를 MAC에서 빌드


반드시 맥이 아니더라도 상관은 없을것 같습니다만,


1. FFMPEG 빌드


홈페이지는 아래와 같습니다.


http://ffmpeg.org



다운로드는 SVN으로 합니다.


svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg


그럼 열심히 다운로드가 됩니다.


빌드에 참고가 되는 페이지는 아래와 같습니다.

http://stephenjungels.com/jungels.net/articles/ffmpeg-howto.html


폴더에 들어가서

./configure

make


사용법은 쉽습니다.


 ./ffmpeg -s 4cif -i ../../TestStream/SOCCER_704x576_30_orig_02.yuv -b 2000k test_2M.avi


 주의할 점은..

입력이 YUV이면,  파일에 대한 정보가 하나도 없으므로, 커맨드라인에서 옵션을 줍니다.

이때, 옵션은 입력 파일 이름보다 먼저 나와야 합니다.



2. X264 빌드


이제 x264를 구합니다.

홈페이지는 다음과 같습니다.


http://www.videolan.org/developers/x264.html


다운로드는 다음과 같습니다.


git clone git://git.videolan.org/x264.git

빌드는 다음과 같습니다.

./configure

make

sudo make install


이러면 설치가 됩니다.


3. 테스트 / 오류

이제 ffmpeg으로 264 엔코딩을 수행하기로 합니다.


옵션 할 것도 많기 때문에 makefile로 스크립트를 만들어서 처리하면 쉽습니다.

makefile의 내용은 아래와 같습니다.

-----------------

# Options


# option for highprofile

options_hp=-vcodec libx264 -b 512k -flags +loop+mv4 -cmp 256 \

-partitions +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 \

-me_method hex -subq 7 -trellis 1 -refs 5 -bf 3 \

-flags2 +bpyramid+wpred+mixed_refs+dct8x8 -coder 1 -me_range 16 \

-g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qmin 10\

-qmax 51 -qdiff 4


# Option for Baseprofile

options_bp=-vcodec libx264 -b 512k -flags +loop+mv4 -cmp 256 \

  -partitions +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 \

  -me_method hex -subq 7 -trellis 1 -refs 5 -bf 0 \

  -flags2 +mixed_refs -coder 0 -me_range 16 \

           -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qmin 10\

  -qmax 51 -qdiff 4



# FFMPEG

FFMPEG = ./FFMPEG/ffmpeg/ffmpeg


# OUTPUT

OUTPUT = ./output


# Test Stream

ICE_704x576 = ./TestStream/ICE_704x576_30_orig_02_yuv/ICE_704x576_30_orig_02.yuv


####################################

all : ICE_264_HP  ICE_264_BP



ICE_264_HP :

${FFMPEG}  -s 4cif -y -i ${ICE_704x576}  -an -pass 1 ${options_hp}  ${OUTPUT}/ice_hp.h264


ICE_264_BP :

${FFMPEG}  -s 4cif -y -i ${ICE_704x576}  -an -pass 1 ${options_bp}  ${OUTPUT}/ice_bp.h264


ffmpeg_help :

${FFMPEG} -h

-----------------


다만 실행하면 다음과 같은 오류가 발생합니다


Unknown encoder 'libx264'


찾아보면 아래의 페이지에서 해결책이 있습니다.

http://ffmpeg.arrozcru.org/forum/viewtopic.php?f=1&t=870


In order to have H264 encoding support in ffmpeg, should I build it with x264 lib ? (from http://www.videolan.org/developers/x264.html)

./configure --help | grep 264

--enable-libx264 enable H.264 encoding via x264 [default=no]


Is there built-in support for h264 encoding in ffmpeg source tree (just decode) ?


Building with configuration: --enable-shared --disable-static --enable-memalign-hack


요지는 옵션을 넣어서 컴파일을 해야 한다는 점입니다.


4. 다시 FFMPEG 빌드


다시 ffmpeg을 빌드합니다.

make distclean

./configure --enable-libx264 --enable-shared --disable-static --enable-memalign-hack --enable-gpl

{

ibx264를 쓸려면 gpl을 enable시켜야 합니다. --enable-gpl

}

make

sudo make install


5. 다시 테스트


실행하면 다음과 같습니다.

Macintosh:JSVM kevinim$ make ICE_264_HP

./FFMPEG/ffmpeg/ffmpeg  -s 4cif -y -i ./TestStream/ICE_704x576_30_orig_02_yuv/ICE_704x576_30_orig_02.yuv   -an -pass 1 -vcodec libx264 -b 512k -flags +loop+mv4 -cmp 256 -partitions +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 -me_method hex -subq 7 -trellis 1 -refs 5 -bf 3 -flags2 +bpyramid+wpred+mixed_refs+dct8x8 -coder 1 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qmin 10 -qmax 51 -qdiff 4  ice_hp.h264

FFmpeg version SVN-r19185, Copyright (c) 2000-2009 Fabrice Bellard, et al.

  configuration: --enable-libx264 --enable-shared --disable-static --enable-memalign-hack --enable-gpl

  libavutil     50. 3. 0 / 50. 3. 0

  libavcodec    52.31. 2 / 52.31. 2

  libavformat   52.34. 0 / 52.34. 0

  libavdevice   52. 2. 0 / 52. 2. 0

  libswscale     0. 7. 1 /  0. 7. 1

  built on Jun 14 2009 08:57:59, gcc: 4.0.1 (Apple Inc. build 5490)

Input #0, rawvideo, from './TestStream/ICE_704x576_30_orig_02_yuv/ICE_704x576_30_orig_02.yuv':

  Duration: N/A, start: 0.000000, bitrate: N/A

    Stream #0.0: Video: rawvideo, yuv420p, 704x576, 25 tbr, 25 tbn, 25 tbc

[libx264 @ 0x1805410]using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.1 Cache64

[libx264 @ 0x1805410]profile High, level 3.0

Output #0, h264, to 'ice_hp.h264':

    Stream #0.0: Video: libx264, yuv420p, 704x576, q=10-51, pass 1, 512 kb/s, 90k tbn, 25 tbc

Stream mapping:

  Stream #0.0 -> #0.0

Press [q] to stop encoding

frame=  240 fps= 16 q=-11214781.0 Lsize=     613kB time=9.52 bitrate= 527.1kbits/s    

video:613kB audio:0kB global headers:0kB muxing overhead 0.000000%

[libx264 @ 0x1805410]slice I:1     Avg QP:35.73  size:  5288

[libx264 @ 0x1805410]slice P:60    Avg QP:29.56  size:  4813

[libx264 @ 0x1805410]slice B:179   Avg QP:32.34  size:  1858

[libx264 @ 0x1805410]consecutive B-frames:  0.0%  0.0%  1.3% 98.7%

[libx264 @ 0x1805410]mb I  I16..4: 33.3% 52.3% 14.5%

[libx264 @ 0x1805410]mb P  I16..4:  1.3%  3.8%  2.6%  P16..4: 31.2%  7.3%  4.7%  0.2%  0.2%    skip:48.8%

[libx264 @ 0x1805410]mb B  I16..4:  0.0%  0.2%  0.2%  B16..8: 40.0%  1.3%  2.0%  direct: 0.9%  skip:55.4%  L0:44.1% L1:53.4% BI: 2.5%

[libx264 @ 0x1805410]final ratefactor: 27.11

[libx264 @ 0x1805410]8x8 transform  intra:50.4%  inter:72.3%

[libx264 @ 0x1805410]coded y,uvDC,uvAC intra:48.7% 36.2% 12.9% inter:6.7% 3.0% 0.2%

[libx264 @ 0x1805410]ref P L0  61.8% 16.3%  9.4%  5.3%  7.2%

[libx264 @ 0x1805410]ref B L0  83.4% 10.4%  4.4%  1.8%

[libx264 @ 0x1805410]ref B L1  93.3%  6.7%

[libx264 @ 0x1805410]SSIM Mean Y:0.9466668

[libx264 @ 0x1805410]kb/s:522.2

이상 없이 동작합니다.


결과는 아래와 같습니다.


-끝-







'Embedded' 카테고리의 다른 글

H.264 SVC 참고 사이트 입니다.  (0) 2009.07.04
DM6467 Develop Board  (2) 2009.06.25
H.264 SVC 다운로드 커맨드  (0) 2009.06.12
LVDS Owner’s Manual [3]  (0) 2009.05.16
LVDS Owner’s Manual [2]  (0) 2009.05.15
Posted by GUNDAM_IM