Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play H264 Video file using VideoToolbox.framework in iOS 8?

I want to play a .H264 video file in iOS 8 with use of VideoToolbox.framework and not with ffmpeg library.

I have found few Tutorials + Reference links to understand VideoToolbox.framework, but still couldn't find, "how to play .H264 in iOS?".

Few Examples :

  • https://github.com/manishganvir/iOS-h264Hw-Toolbox

  • https://github.com/McZonk/VideoToolboxPlus

Reference Links :

  • https://developer.apple.com/library/mac/releasenotes/General/APIDiffsMacOSX10_8/VideoToolbox.html

  • https://developer.apple.com/videos/wwdc/2014/?include=513#513

  • Decoding H264 VideoToolkit API fails with Error -8971 in VTDecompressionSessionCreate

You can download a test (.H264) video for Testing from here.

like image 850
Vishal Khatri Avatar asked Jul 17 '15 12:07

Vishal Khatri


2 Answers

VideoToolbox.framework is not used to display video files on screen but rather for decoding and conversion of video data. Use AVKit.framework or AVFoundation.framework to play a H264 video instead.

See Apples documentation of the Media Layer:

The Video Toolbox framework comprises the 64-bit replacement for the QuickTime Image Compression Manager. Video Toolbox provide services for video compression and decompression, and for conversion between raster image formats stored in Core Video pixel buffers.

like image 154
der_michael Avatar answered Oct 04 '22 13:10

der_michael


It depends on what your trying to decode. If you have a File or valid end point. AVFoundation is what your looking for.

The VideoToolBox is for decoding video manually. Which is used in real-time streaming. For this case you will be required to parse the NAL units from each payload and follow this tutorial:

https://stackoverflow.com/a/29525001/2878935

like image 26
redbrain Avatar answered Oct 04 '22 14:10

redbrain