이 프로젝트는 초안이며 다른 사람이 사용하기위한 것이 아닙니다.
vtcff 는 비디오 제작 파이프 라인의 품질과 색 깊이 유지에 중점을 둔 비디오 형식을 트랜스 코딩하기위한 라이브러리입니다. 스튜디오 작업에서 비디오 초는 기가 바이트를 차지하며 품질 타협은 가장 바람직하지 않습니다.
vtcff 품질을 최대화하여 속도와 디스크 공간을 희생하는 경향이 있습니다.
vtcff 는 실제로 가장 직관적 인 비디오 도구 인 ffmpeg 의 래퍼입니다.
$ pip3 install vtcff이 명령은 패키지를 설치하지만 ffmpeg 자체는 아닙니다.
$ pip3 install git+https://github.com/rtmigo/vtcff_py@staging#egg=vtcff import subprocess
from vtcff import FfmpegCommand , Scale , Transpose , Hevc
cmd = FfmpegCommand ()
cmd . src_file = '/path/to/source.mov'
cmd . dst_file = '/path/to/target.mov'
# set set some filters
cmd . scale = Scale ( 1920 , 1080 )
cmd . transpose = Transpose . CLOCKWISE
# set compression format
cmd . dst_codec_video = Hevc ( mbps = 100 )
# run command
subprocess . check_call ( list ( cmd )) import subprocess , os
from vtcff import FfmpegCommand , Prores
cmd = FfmpegCommand ()
cmd . src_file = 'source.mov'
cmd . dst_file = 'target.mov'
cmd . dst_codec_video = Prores ()
print ( str ( cmd ))
# ffmpeg -i source.mov -codec:v prores_ks target.mov
print ( list ( cmd ))
# ['ffmpeg', '-i', 'source.mov', '-codec:v', 'prores_ks', 'target.mov']
# running in different ways:
os . system ( str ( cmd ))
subprocess . run ( list ( cmd ))객체를 사용하면 FFMPEG 인수를 수동으로 지정할 수 있습니다. 이런 식으로 주어진 인수는 객체에 의해 생성 된 인수보다 우선합니다.
from vtcff import FfmpegCommand
cmd = FfmpegCommand ()
# set arguments as string
cmd . custom . video . string = "-codec:v libx265"
cmd . custom . video . string += "-x265-params lossless=1"
# or as list
cmd . custom . video . list = [ "-codec:v" , "libx265" ]
cmd . custom . video . list . extend ([ "-x265-params" , "lossless=1" ]) cmd.custom 에는 4 개의 필드가 포함되어 있으며 독립적으로 수정할 수 있습니다.
-i source 전에 삽입 할 인수 :
custom.before_i -i source 다음에 삽입 할 인수 :
custom.after_icustom.videocustom.audio ffmpeg 에는 색상 및 프레임 크기 변환을위한 두 개의 비디오 필터가 있습니다.
scale (libswscale)은 더 다재다능합니다zscale (ZIMG)는보다 예측 가능한 품질을 제공합니다 기본적으로 vtcff zscale 사용합니다. 때로는 "Colorspaces 사이의 경로 없음"오류가 발생할 수 있습니다. 다른 방법이 도움이되지 않으면 zscale scale 로 간단히 바꿀 수 있습니다.
cmd.use_zscale == True means zscale 이 사용됩니다cmd.use_zscale == False scale 사용됩니다 from vtcff import FfmpegCommand , Scale
cmd = FfmpegCommand ()
assert cmd . use_zscale == True # by default, it's 'zscale' (zimg)
cmd . use_zscale = False # switching to 'scale' (libswscale)
# properties affected:
cmd . scale = Scale ( 1920 , 1080 )
cmd . src_color_space = 'bt709'
cmd . dst_color_space = 'bt2020ncl'
cmd . src_range_full = True
cmd . dst_range_full = False use_zscale=True , Zimg은 객체 속성에 의해 명시 적으로 설정된 변환에 사용될 것임을 의미합니다. 이러한 변환은 고품질이기 때문에 좋습니다.
그러나 암시 적 전환도 필요할 수 있습니다. 예를 들어, zscale 으로 16 비트 PNG를 처리하기 전에 픽셀 형식을 rgba64be 에서 gbrap16le 로 변환해야합니다. FFMPEG는 use_zscale 속성에 관계없이 libswscale 로 자동으로 수행합니다.
from vtcff import FfmpegCommand , Scale , Crop
# crop 10 pixels, then scale
a = FfmpegCommand ()
a . crop = Crop ( left = 10 )
a . scale = Scale ( 1920 , 1080 )
# scale, then crop 10 pixels
b = FfmpegCommand ()
b . scale = Scale ( 1920 , 1080 )
b . crop = Crop ( left = 10 ) from vtcff import FfmpegCommand , Scale
cmd = FfmpegCommand ()
# set height to 1080, automatically compute width
cmd . scale = Scale ( - 1 , 1080 )
# set height to 1080, select the width as the closest factor
# of two to the proportional size
cmd . scale = Scale ( - 2 , 1080 ) from vtcff import FfmpegCommand
cmd = FfmpegCommand ()
# Full/Data/PC range to Limited/Video/TV
cmd . src_range_full = True
cmd . dst_range_full = False
# rec.709 to rec.2020
cmd . src_color_space = 'bt709'
cmd . dst_color_space = 'bt2020ncl' from vtcff import FfmpegCommand , Prores , ProresProfile
cmd = FfmpegCommand ()
# by default it will encode to ProRes 4:2:2
cmd . dst_codec_video = Prores ()
# encode to ProRes 4:2:2 HQ instead
cmd . dst_codec_video = Prores ( profile = ProresProfile . HQ ) from vtcff import FfmpegCommand , Hevc , VcPreset
cmd = FfmpegCommand ()
# ideal quality
cmd . dst_codec_video = Hevc ( lossless = True )
# best for bitrate quality
cmd . dst_codec_video = Hevc ( near_lossless = True , mbps = 100 )
# default quality
cmd . dst_codec_video = Hevc ( mbps = 100 )
# all modes can be tweaked with optional speed presets:
cmd . dst_codec_video = Hevc ( mbps = 100 ,
preset = VcPreset . N7_SLOW ) 기본적으로 near_lossless 품질을 최대화하려고 노력하기 때문에 가능한 VcPreset.N10_PLACEBO 가장 느리게 설정합니다. 결과가 수명 내에 나타나도록 더 빠른 사전 설정을 선택할 수 있습니다.
기본적으로, lossless 가능한 가장 빠른 VcPreset.N1_ULTRAFAST 로 설정되어 있습니다. 여기서 품질을 잃지 않기 때문입니다. 결과 크기는 Prores HQ/XQ와 대략 비교할 수 있으며 인코딩 시간은 합리적입니다.
미디어 스트림은 다시 인코딩하지 않고 품질 손실없이 복사 할 수 있습니다.
그러나 메타 데이터 손실 (예 : 색상 범위 및 색상 공간에 대한 정보가있을 수 있습니다.
from vtcff import FfmpegCommand , VideoCopy , NoAudio
cmd = FfmpegCommand ()
# changing container from mp4 to mov
cmd . src_file = "source.mp4"
cmd . dst_file = "source.mov"
# keeping video, removing audio
cmd . dst_codec_video = VideoCopy ()
cmd . dst_codec_audio = NoAudio ()타임 랩스 또는 CGI 프레임 시퀀스를 Prores 비디오 파일로 변환합니다.
import subprocess
from vtcff import FfmpegCommand , Prores , ProresProfile
cmd = FfmpegCommand ()
# input directory will be automatically transformed
# to a pattern like '/my/dir_with_frames/img_%04.png'
cmd . src_file = '/my/dir_with_frames'
cmd . src_fps = 29.97
cmd . dst_file = '/videos/timelapse.mov'
cmd . dst_codec_video = Prores ( profile = ProresProfile . HQ )
# images usually have Full/Data/PC color range,
# but most NLEs assume that videos have Limited/Video/TV range
cmd . src_range_full = True
cmd . dst_range_full = False
# we will treat sRGB like Rec.709,
# although it's a little sad
cmd . src_color_space = 'bt709'
cmd . dst_color_space = 'bt709'
# run command
subprocess . check_call ( list ( cmd ))