2013-01-07 17 views
6

Chúng tôi đang sử dụng AVAssetReaderAVAssetWriter phần nào theo phong cách như được ghi chú trong Video Encoding using AVAssetWriter - CRASHES về cơ bản để đọc video mà chúng tôi nhận được từ thư viện ảnh/thư viện tài sản, sau đó viết nó với tốc độ bit khác nhau để giảm kích thước của nó (để tải lên mạng cuối cùng).Cách chọn loại định dạng pixel (kCVPixelBufferPixelFormatTypeKey) để sử dụng với AVAssetReader?

Bí quyết để nhận được để làm việc này đối với chúng tôi là để chỉ định khóa kCVPixelBufferPixelFormatTypeKey và giá trị trong outputSettings trên AVAssetReaderTrackOutput, một cái gì đó như thế này:

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

Vì vậy, về cơ bản chúng ta sử dụng giá trị kCVPixelFormatType_32BGRA cho phím kCVPixelBufferPixelFormatTypeKey.

Nhưng dường như có nhiều loại định dạng pixel có thể mà chúng tôi có thể chọn. Chạy mã lưu ý trong Technical Q&A QA1501: Core Video - Available Pixel Formats trên thiết bị iOS 6.0.1 iPhone, đây là danh sách các loại định dạng hỗ trợ pixel nó cho thấy:

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 

Mặc dù kCVPixelFormatType_32BGRA làm việc (ít nhất là dường như) đối với chúng tôi, chúng tôi rất tò mò cho dù có một sự lựa chọn tốt hơn so với từ danh sách trên. Chúng ta nên chọn loại định dạng pixel phù hợp với chúng ta như thế nào?

+0

Nếu có một phần cứng định dạng kết cấu tương thích với khung video thô được giải mã, bạn sẽ nghĩ rằng nhận được ở định dạng đó sẽ nhanh hơn chuyển sang RGB ví dụ. Điều này có thể được chuyển giao cho GL và một shader mảnh được sử dụng để chuyển đổi sang không gian màu màn hình. – MrMaxP

Trả lời

1

Bạn có thể thử nghiệm với các cài đặt khác nhau và so sánh hiệu suất. Việc cung cấp bộ đệm cho bộ mã hóa theo các định dạng pixel khác nhau có thể dẫn đến sự khác biệt về mã hóa hiệu quả. Bộ mã hóa tăng tốc phần cứng thường sử dụng "420v".

Xem thêm, Query for optimal pixel format when capturing video on iOS?

Các vấn đề liên quan