ffmpeg 톺아보기

Codec

비디오 용량

일반적으로 비디오 용량은 대용량이다.

toppf = 1080 * 1920 //total_of_pixels_per_frame (width * height)
cpp = 3 //cost_per_pixel (3 bytes per pixcel - 24b bit color)
tis = 30 * 60 //time_in_seconds (30분 동안)
fps = 24 //frames_per_second (1초동안 프레임 수)

required_storage = tis * fps * toppf * cpp

약 250.28GB 혹은 1.11Gbps brandwidth 필요, 따라서 코덱을 이용하여 압축 필요

container

video audio를 포함한 것

FFmpeg

container converter

container 변환 명령어

$ ffmpeg -i input.mp4 output.avi # convert from mp4 container to avi container

transcoding

  1. 비디오 코덱 변경
  2. TV나 스마트폰 등 에서 지원하지 않는 비디오 코덱을 지원하는 코덱으로 변경하기 위해 사용 (압축률)
$ ffmpeg \
-i bunny_1080p_60fps.mp4 \
-c:v libx265 \
bunny_1080p_60fps_h265.mp4

transmuxing

  1. 비디오 포멧 변경
  2. TV나 스마트폰 등 에서 지원하지 않는 비디오 포멧을 지원하는 포멧으로 변경하기 위해 사용 (포멧 특징)
$ ffmpeg \
-i bunny_1080p_60fps.mp4 \
-c copy \ # just saying to ffmpeg to skip encoding
bunny_1080p_60fps.webm

Transrating

  1. 비트레이트 변경 = producing other renditions. -> adaptive streaming
  2. 2G 스마트폰에서는 비트레이트를 낮춰야 함
$ ffmpeg \
-i bunny_1080p_60fps.mp4 \
-minrate 964K -maxrate 3856K -bufsize 2000K \
bunny_1080p_60fps_transrating_964_3856.mp4

Transsizing

  1. 해상도 변경 -> adaptive streaming
  2. Transrating과 같은 이유로 같이 사용

adaptive streaming

  1. 영상을 여러 많은 비트레이트와 해상도로 프로듀싱하여 특정 조건의 되면 해당 조건의 영상을 http로 청크단위로 서빙한다.
  2. DASH를 사용한 WebM
# video streams
$ ffmpeg -i bunny_1080p_60fps.mp4 -c:v libvpx-vp9 -s 160x90 -b:v 250k -keyint_min 150 -g 150 -an -f webm -dash 1 video_160x90_250k.webm

$ ffmpeg -i bunny_1080p_60fps.mp4 -c:v libvpx-vp9 -s 320x180 -b:v 500k -keyint_min 150 -g 150 -an -f webm -dash 1 video_320x180_500k.webm

$ ffmpeg -i bunny_1080p_60fps.mp4 -c:v libvpx-vp9 -s 640x360 -b:v 750k -keyint_min 150 -g 150 -an -f webm -dash 1 video_640x360_750k.webm

$ ffmpeg -i bunny_1080p_60fps.mp4 -c:v libvpx-vp9 -s 640x360 -b:v 1000k -keyint_min 150 -g 150 -an -f webm -dash 1 video_640x360_1000k.webm

$ ffmpeg -i bunny_1080p_60fps.mp4 -c:v libvpx-vp9 -s 1280x720 -b:v 1500k -keyint_min 150 -g 150 -an -f webm -dash 1 video_1280x720_1500k.webm

# audio streams
$ ffmpeg -i bunny_1080p_60fps.mp4 -c:a libvorbis -b:a 128k -vn -f webm -dash 1 audio_128k.webm

# the DASH manifest
$ ffmpeg \
 -f webm_dash_manifest -i video_160x90_250k.webm \
 -f webm_dash_manifest -i video_320x180_500k.webm \
 -f webm_dash_manifest -i video_640x360_750k.webm \
 -f webm_dash_manifest -i video_640x360_1000k.webm \
 -f webm_dash_manifest -i video_1280x720_500k.webm \
 -f webm_dash_manifest -i audio_128k.webm \
 -c copy -map 0 -map 1 -map 2 -map 3 -map 4 -map 5 \
 -f webm_dash_manifest \
 -adaptation_sets "id=0,streams=0,1,2,3,4 id=1,streams=5" \
 manifest.mpd

좋은 웹페이지 즐겨찾기