2013-01-07 9 views
6

AVAssetReaderAVAssetWriter은 기본적으로 Video Encoding using AVAssetWriter - CRASHES에 언급 된 스타일로 비디오를 읽고 사진 갤러리/자산 라이브러리에서 가져온 비디오를 읽은 다음 다른 비트 전송률로 작성하여 (최종 네트워크 업로드의 경우) 크기를 줄입니다. AVAssetReader와 함께 사용하기 위해 픽셀 형식 유형 (kCVPixelBufferPixelFormatTypeKey)을 선택하는 방법은 무엇입니까?

NSDictionary *outputSettings = [NSDictionary 
    dictionaryWithObject:[NSNumber numberWithInt:kCVPixelFormatType_32BGRA] 
        forKey:(id)kCVPixelBufferPixelFormatTypeKey];  
readerTrackOutput = 
    [[AVAssetReaderTrackOutput alloc] initWithTrack:src_track 
            outputSettings:outputSettings]; 

그래서 기본적으로 우리가 kCVPixelBufferPixelFormatTypeKey 키의 kCVPixelFormatType_32BGRA 값을 사용 :

우리를 위해 일을이를 얻는 데 트릭

AVAssetReaderTrackOutput에 이런 일을 outputSettingskCVPixelBufferPixelFormatTypeKey 키와 값을 지정하는 것이 었습니다.

분명히 우리가 선택할 수있는 많은 가능한 픽셀 형식 유형이 있습니다. 아이폰 OS 6.0.1 아이폰 장치에 Technical Q&A QA1501: Core Video - Available Pixel Formats에서 언급 한 코드를 실행, 여기가 보여지지 픽셀 포맷 형식의 목록입니다 :

Core Video Supported Pixel Format Types: 
Core Video Pixel Format Type: 32 
Core Video Pixel Format Type: 24 
Core Video Pixel Format Type: 16 
Core Video Pixel Format Type (FourCC): L565 
Core Video Pixel Format Type (FourCC): 2vuy 
Core Video Pixel Format Type (FourCC): yuvs 
Core Video Pixel Format Type (FourCC): yuvf 
Core Video Pixel Format Type: 40 
Core Video Pixel Format Type (FourCC): L008 
Core Video Pixel Format Type (FourCC): 2C08 
Core Video Pixel Format Type (FourCC): r408 
Core Video Pixel Format Type (FourCC): v408 
Core Video Pixel Format Type (FourCC): y408 
Core Video Pixel Format Type (FourCC): y416 
Core Video Pixel Format Type (FourCC): BGRA 
Core Video Pixel Format Type (FourCC): b64a 
Core Video Pixel Format Type (FourCC): b48r 
Core Video Pixel Format Type (FourCC): b32a 
Core Video Pixel Format Type (FourCC): b16g 
Core Video Pixel Format Type (FourCC): R10k 
Core Video Pixel Format Type (FourCC): v308 
Core Video Pixel Format Type (FourCC): v216 
Core Video Pixel Format Type (FourCC): v210 
Core Video Pixel Format Type (FourCC): v410 
Core Video Pixel Format Type (FourCC): r4fl 
Core Video Pixel Format Type (FourCC): grb4 
Core Video Pixel Format Type (FourCC): rgg4 
Core Video Pixel Format Type (FourCC): bgg4 
Core Video Pixel Format Type (FourCC): gbr4 
Core Video Pixel Format Type (FourCC): 420v 
Core Video Pixel Format Type (FourCC): 420f 
Core Video Pixel Format Type (FourCC): 411v 
Core Video Pixel Format Type (FourCC): 411f 
Core Video Pixel Format Type (FourCC): 422v 
Core Video Pixel Format Type (FourCC): 422f 
Core Video Pixel Format Type (FourCC): 444v 
Core Video Pixel Format Type (FourCC): 444f 
Core Video Pixel Format Type (FourCC): y420 
Core Video Pixel Format Type (FourCC): f420 
Core Video Pixel Format Type (FourCC): a2vy 
Core Video Pixel Format Type (FourCC): L00h 
Core Video Pixel Format Type (FourCC): L00f 
Core Video Pixel Format Type (FourCC): 2C0h 
Core Video Pixel Format Type (FourCC): 2C0f 
Core Video Pixel Format Type (FourCC): RGhA 
Core Video Pixel Format Type (FourCC): RGfA 

에도 kCVPixelFormatType_32BGRA 불구하고 우리를 위해 (적어도 겉으로는) 일, 우리는 호기심 위 목록에있는 것보다 더 나은 선택이 있는지 여부. 올바른 픽셀 형식 유형을 선택하는 방법은 무엇입니까?

+0

도 참조하십시오. 이것은 GL과 화면 색 공간으로 변환하는 데 사용 된 프래그먼트 셰이더로 넘겨 질 수 있습니다. – MrMaxP

답변

1

다른 설정으로 실험하고 성능을 비교할 수 있습니다. 인코더에 버퍼를 다른 픽셀 형식으로 제공하면 인코딩 성능이 달라질 수 있습니다. 하드웨어 가속 엔코더는 종종 "420v"를 사용합니다. 디코딩 원시 비디오 프레임을위한 하드웨어 호환 텍스처 형식이 있다면, 당신은 그 형식으로 점점 예를 들어 RGB로 변환하는 것보다 빠를 것이라고 생각 Query for optimal pixel format when capturing video on iOS?