어제 테스트해서 보니, 압축 방식을 어떻게 하느냐에 따라서 압축률이 증가한다는걸 알아 냈다.


 답은 TAR로 한번 폴더와 파일을 한 파일로 몰아 넣은 후에 압축하면, 상대적으로 엄청 많은 압축률을 보여준다.


 ZIP이나 ZIPX는 압축률이 높은 알고리즘을 사용한다.

 특히, ZIPX는 최근에 발전된 방식의 압축 방식이다.

 여기서 ZIP과 ZIPX의 공통점은 LZ77을 이용한다는 점이다.(ZIP은 DEFLATE, ZIPX는 LZMA)

 여기서 압축률이 가장 높은것은 LZMA이다.

 그런데, LZMA의 압축률이 높은 것은 LZ77의 사전의 크기가 크기 때문에 그런 것이다.


 LZ77의 사전 크기는 압축률을 뜻하고.

 사전를 빠르게 탐색하는 것은 압축 속도를 높이는 장치이다.


 즉, 검색 알고리즘이 발전하면, 압축속도가 높아진다.

 사전 크기(저장하는 데이터)가 커지면, 압축률이 높고, 이 사전에 검색을 빠르게 하는 알고리즘을 적용하면, 빠르고 압축률이 높은 알고리즘이 생긴다.


 일단, ZIP은 LZ77의 최대 사전 크기가 32kb이다.

 하지만, ZIPX는 LZ77의 최대 사전 크기가 4Gb이다.


 그래서 LZMA(LZ77의 사전 크기가 4Gb)가 압축률이 가장 높다.


 그럼, 왜 TAR을 했던것과 그냥 하는 것과 압축률이 엄청 차이나는가?


 TAR을 이용하여, ZIPX을 적용하면, 사전을 전부다 적용 시킬 수 있기 때문이다.


 ZIPX는 각 파일마다 LZMA 압축을 하기 때문에 제대로된 압축이 되지 않는다.


 7Z는 TAR처럼 한번 압축을 거치기 때문인지 ZIPX보다 압축률이 높을때가 높다.

 TAR+ZIPX을 한것과 비슷하거나 조금더 압축이 된다.

 그래서 7Z을 사용하거나 TAR+ZIPX을 쓰는게 더 이득이다.

Posted by JunkMam
,

 요즘 Google에서 Open Source로 공개한, Brotli라는게 있다.

 이게 압축율이 좋다고 한다.


 좁플라이보다 개량되서 20% 향상되었다고 한다.[각주:1]

 그래서 구글링을 해서 exe파일로 구해봤다.[각주:2]


 현재, 테스트 해본 결과


 mp4파일(원본) : 297624674kbyte = 100%

 zip[반디집] : 266413245 = 89.51%

 zipx[반디집] : 41239013 = 13.85%

 brotli : 40981074 = 13.76%

 paq8o10t [8] : 40088746 = 13.47%

 

 

 이렇게 압축파일의 효율적으로 처리되는걸 알 수 있다.


 압축 속도는 zipx(LZMA) 보다 느리나, 압축율과 압축 해제속도는 상대적으로 비슷하거나 높음을 알 수 있다.


 하지만, 역시 PAQ알고리즘보단, 낮다.

 단, 속도를 비교해보니, PAQ가 시간이 엄청오래 걸리고 메모리를 많이 먹는 것 비해.

 이정도(약 1Mb차이)면, 괜찮은 것 같다.


 --2015.10.07--


 확인해보니 아직 brotli는 문제점이 있는 것 같다.

 반디집의 zipx을 이용하는 것과 brotli을 이용하는걸 비교해보니, zipx가 오히려 더 이득적인게 있다.

 그냥, 반디집의 zipx을 이용하는게 더 이득이다.(속도로나 압축률로 보나...)



Brotli.exe


'연습' 카테고리의 다른 글

구글 포토스 - JPEG와 PNG의 차이점.  (0) 2015.10.08
- 잡소리 - 압축 프로그램 이용 방법  (0) 2015.10.07
- 잡소리 - 단일 처리와 병렬 처리  (0) 2015.10.05
base64 -1 : base64 응용 -  (0) 2015.10.04
base64 - 0 : 이론 -  (0) 2015.10.03
Posted by JunkMam
,

webM은 일반적으로 데이터를 보는게 불가능한 것 같다.

그래서 프로그램을 사용해야되는데, ffprobe라는 걸 이용하면 된다.

ffprobe를 이용해서 데이터를 얻을 수 있다.[각주:1]


예)

ffprobe.exe -show_streams "input file"


이렇게 하면, 다음과 같은 형태를 얻을 수 있게 된다.


ffprobe version N-75185-gf58e011 Copyright (c) 2007-2015 the FFmpeg developers  built with gcc 4.9.3 (GCC)

  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-opencl --enable-zlib

  libavutil      55.  2.100 / 55.  2.100

  libavcodec     57.  1.100 / 57.  1.100

  libavformat    57.  0.100 / 57.  0.100

  libavdevice    57.  0.100 / 57.  0.100

  libavfilter     6.  1.100 /  6.  1.100

  libswscale      4.  0.100 /  4.  0.100

  libswresample   2.  0.100 /  2.  0.100

  libpostproc    54.  0.100 / 54.  0.100

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '.\moveCap.mp4':

  Metadata:

    major_brand     : isom

    minor_version   : 512

    compatible_brands: isomiso2avc1mp41

    encoder         : Lavf57.0.100

  Duration: 00:01:00.00, start: 0.040998, bitrate: 3498 kb/s

    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 800x600 [SAR 1:1 DAR 4:3], 3512 kb/s, 23.81 fps, 60 tbr, 48k tbn, 50 tbc (default)

    Metadata:

      handler_name    : VideoHandler

    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, stereo, fltp, 94 kb/s (default)

    Metadata:

      handler_name    : SoundHandler

[STREAM]

index=0

codec_name=h264

codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10

profile=High

codec_type=video

codec_time_base=1/50

codec_tag_string=avc1

codec_tag=0x31637661

width=800

height=600

coded_width=800

coded_height=608

has_b_frames=0

sample_aspect_ratio=1:1

display_aspect_ratio=4:3

pix_fmt=yuv420p

level=40

color_range=N/A

color_space=unknown

color_transfer=unknown

color_primaries=unknown

chroma_location=left

timecode=N/A

refs=1

is_avc=1

nal_length_size=4

id=N/A

r_frame_rate=60/1

avg_frame_rate=86375/3628

time_base=1/48000

start_pts=94752

start_time=1.974000

duration_ts=2786304

duration=58.048000

bit_rate=3512905

max_bit_rate=N/A

bits_per_raw_sample=8

nb_frames=1382

nb_read_frames=N/A

nb_read_packets=N/A

DISPOSITION:default=1

DISPOSITION:dub=0

DISPOSITION:original=0

DISPOSITION:comment=0

DISPOSITION:lyrics=0

DISPOSITION:karaoke=0

DISPOSITION:forced=0

DISPOSITION:hearing_impaired=0

DISPOSITION:visual_impaired=0

DISPOSITION:clean_effects=0

DISPOSITION:attached_pic=0

TAG:language=eng

TAG:handler_name=VideoHandler

[/STREAM]

[STREAM]

index=1

codec_name=aac

codec_long_name=AAC (Advanced Audio Coding)

profile=LC

codec_type=audio

codec_time_base=1/22050

codec_tag_string=mp4a

codec_tag=0x6134706d

sample_fmt=fltp

sample_rate=22050

channels=2

channel_layout=stereo

bits_per_sample=0

id=N/A

r_frame_rate=0/0

avg_frame_rate=0/0

time_base=1/22050

start_pts=904

start_time=0.040998

duration_ts=1323007

duration=60.000317

bit_rate=94706

max_bit_rate=128000

bits_per_raw_sample=N/A

nb_frames=1292

nb_read_frames=N/A

nb_read_packets=N/A

DISPOSITION:default=1

DISPOSITION:dub=0

DISPOSITION:original=0

DISPOSITION:comment=0

DISPOSITION:lyrics=0

DISPOSITION:karaoke=0

DISPOSITION:forced=0

DISPOSITION:hearing_impaired=0

DISPOSITION:visual_impaired=0

DISPOSITION:clean_effects=0

DISPOSITION:attached_pic=0

TAG:language=eng

TAG:handler_name=SoundHandler

[/STREAM]


'연습' 카테고리의 다른 글

OpenCL 프로그래밍 공부 -시작-  (0) 2015.10.02
CSS3 -3D Flip Animation-  (0) 2015.09.30
ffmpeg 사용 -mp4 to webm convert(mp4을 webm으로 변환)-  (0) 2015.09.29
ffmpeg -이미지 추출-  (0) 2015.09.28
ffmpeg -동영상 자르기-  (0) 2015.09.28
Posted by JunkMam
,

mp4를 webm으로 변환시키는 방법이 있다.


mp4 -> webM 변환 사이트


하지만, ffmpeg을 사용해도 간단하게 변환이 가능하다.


예)[각주:1]

./ffmpeg -i input-file.mp4 -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis output-file.webm


-c:a : 오디오 인코딩용 라이브러리

-b:v : 버퍼속도(비트 속도)

-crf : bit-rate 설정 인걸로 추정.

-c:v : 오디오 인코딩용 라이브러리


그 외

-buffsize : 평균 bit rate을 설정한다.


libvpx와 libvorbis을 라이브러리로 연결해서 webm으로 변환 시키는 작업을 한다.(vp8형 소스가 나온다.)


vp9형으로 변경할려면, 다음과 같이 하면 된다고 나와있다.


예)[각주:2]

ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 1M -c:a libvorbis output.webm


libvpx-vp라이브러리명. 이런 차이가 있다.


음성 제거 방법은 

-an을 붙이면 된다.

Posted by JunkMam
,

ffmpeg -이미지 추출-

연습 2015. 9. 28. 19:31


ffmpeg를 이용하면, 


ffmpeg사이트


./ffmpeg -i 추출할 영상.mp4 -an -r 1 -y -s 가로x세로 추출할 이미지명.png


-an : 오디오 무시

-r : 1초당 몇 프레임 추출할 것인지 설정.

-y : 같은 이름 있을시 덮어 쓰기.

-s : 추출될 이미지 사이즈 설정.


이미지 명에 %d을 이용하면, 정수로 해당 이미지 갯수가 정수로 출력된다.

Posted by JunkMam
,

ffmpeg을 이용해서 mp4등 영상 파일을 자를 수 있다.


ffmpeg사이트


여기서 ffmpeg을 구한 후에 다음과 같이 사용하면 된다.


 .\ffmpeg.exe -i .\자를 영상.mp4 -ss 53 -t 300 -vcodec copy -acodec copy 잘린 영상.mp4


-ss : 초단위로 자를 위치 설정.

-t : 초단위로 자를 량 설정.

-vcodec copy : 비디오 코덱 카피

-acodec copy : 오디오 코덱 카피


이렇게 사용하면 된다.

Posted by JunkMam
,