首页 > 其他分享 >use a circular buffer for video frames on iOS

use a circular buffer for video frames on iOS

时间:2023-06-02 19:31:43浏览次数:50  
标签:use buffer iOS but video TPCircularBuffer com circular


https://stackoverflow.com/questions/33581369/how-to-use-tpcircularbuffer-for-video

https://github.com/jeremytregunna/Ring

https://www.codesd.com/item/is-it-possible-to-use-a-circular-buffer-for-video-images-on-ios.html

http://atastypixel.com/blog/a-simple-fast-circular-buffer-implementation-for-audio-processing/

http://www.boost.org/doc/libs/1_39_0/libs/circular_buffer/doc/circular_buffer.html

https://github.com/lmtanco/videoDelayLine


How to use TPCircularBuffer for Video?

TPCircularBufferTPCircularBuffer for Video buffering also. I have searched a lot but didn't find anything useful on "Using TPCircularBuffer

could copy your video frame's pixels into a TPCircularBuffer, and you'd technically have a video ring buffer, but you've already lost the efficiency race at that point because you don't have time to copy that much data around. You need to keep a reference to your frames.really wanted to mash a solution into TPCircularBuffer, you could write the CMSampleBuffer pointers into the buffer (carefully respecting retain and release). But that seems heavy handed, as you're really not gaining anything from TPCircularBuffer's magical memory mapping wrapping because pointers are so small.CMSampleBufferRef ring buffer. You can grab a prebuilt circular buffer or do the clock arithmetic yourself:

CMSampleBufferRef  ringBuffer[10]; // or some other number

 ringBuffer[(++i) % 10] = frame;

Of course your real problem is not the ring buffer itself, but dealing with the fact that decompressed video is very high bandwidth, e.g. each frame is 8MB for 1080p, or 200MB to store 1 second's worth at 24fps, so you're going to have to get pretty creative if you need anything other than a microscopic video buffer.

Some suggestions:

  • the above numbers are for RGBA, so try working in YUV, where the numbers become 3MB and 75MB/s
  • try lower resolutions

I'm currently looking for a way to create a "live photos"-like functionality in iOS, but using videos. The goal is to have the application store a few seconds of frames prior to starting taking a video. I'm thinking a circular buffer would serve well here, but most of the libraries I've seen are for audio only. Given that the live photos functionality is exclusive to iPhone 6S, I'm wondering if a functionality like this is possible on a device with equal amount of RAM, for example an iPad Air 2, or a device with lesser RAM, for example iPhone 6.


In theory, it would be possible to store and loop video, but in practice you will find that it is unlikely to actually work for full screen video at a fast FPS rate like 30 FPS. The problem is total amount of memory used for video. Each pixel is 32 bits of data (RGBX) each pixel is basically a word and you need to multiply by W x H to figure out how large that is for the given camera resolution. To make a long story short, for a very large W and H there is too much data for the CPU and memory bus to keep up with reads and writes. Now iOS devices do have hardware to help with this task, for example you can encode movies using the built in hardware, but that is likely to be the only way you will be able to get it working when dealing with very large W x H values and fast frame rates. You also have to be careful with aspect ratios because you camera will likely capture pictures in aspect ratios that the h.264 encoding hardware will not support.





标签:use,buffer,iOS,but,video,TPCircularBuffer,com,circular
From: https://blog.51cto.com/u_16124099/6404611

相关文章

  • iOS应用上架详细图文教程
    ​ AppStore作为苹果官方的应用商店,审核严格周期长一直让用户头疼不已,很多app都“死”在了审核这一关,那我们就要放弃iOS用户了吗?当然不是!本期我们从iOSapp上架流程开始梳理,详细了解下iOSapp上架的那些事。 iOSapp上架总体流程: ​编辑1登录苹果开发者中心,注册开发......
  • iOS应用上架详细图文教程
    ​ AppStore作为苹果官方的应用商店,审核严格周期长一直让用户头疼不已,很多app都“死”在了审核这一关,那我们就要放弃iOS用户了吗?当然不是!本期我们从iOSapp上架流程开始梳理,详细了解下iOSapp上架的那些事。 iOSapp上架总体流程: ​编辑1登录苹果开发者中心,注册开发......
  • 黑屏real time clock error,bios设置系统时间
    打开笔记本,突然出现这样的黑屏信息 按一下F1,出现这样的界面,将选项栏转到第三项Date/Time  转到第三项之后,可以看到系统时间,将系统时间手动修改成现在的时间+ 修改完成后按F10,弹出一个对话框,选择yes,系统会自动关机......
  • iostat相关参数说明——await:平均每次设备I/O操作的等待时间 (毫秒),如果%util接近 100
    iostat是I/Ostatistics(输入/输出统计)的缩写,iostat工具将对系统的磁盘操作活动进行监视。它的特点是汇报磁盘活动统计情况,同时也会汇报出CPU使用情况。同vmstat一样,iostat也有一个弱点,就是它不能对某个进程进行深入分析,仅对系统的整体情况进行分析。iostat的语法如下:iostat[......
  • VMware ESXi 8.0U1a Unlocker & OEM BIOS 集成网卡驱动和 NVMe 驱动 (集成驱动版)
    VMwareESXi8.0Update1aUnlocker&OEMBIOS集成网卡驱动和NVMe驱动(集成驱动版)发布ESXi8.0U1集成驱动版,在个人电脑上运行企业级工作负载请访问原文链接:https://sysin.org/blog/vmware-esxi-8-u1-sysin/,查看最新版。原创作品,转载请保留出处。作者主页:sysin.orgES......
  • FLink写入Clickhouse优化
    一、背景ck因为有合并文件操作,适合批量写入。如单条插入则速度太慢二、Flink写入ck优化改为分批插入,代码如下DataStream<Row>stream=...stream.addSink(JdbcSink.sink("INSERTINTOmytable(col1,col2)VALUES(?,?)",(ps,row)->{ps.setString(1,row.ge......
  • VMware ESXi 8.0 Update 1a macOS Unlocker & OEM BIOS (标准版和厂商定制版)
    VMwareESXi8.0Update1amacOSUnlocker&OEMBIOS(标准版和厂商定制版)ESXi8.0U1标准版,DellHPE联想浪潮定制版请访问原文链接:https://sysin.org/blog/vmware-esxi-8-u1-oem/,查看最新版。原创作品,转载请保留出处。作者主页:sysin.orgESXi8.0U1a:此补丁修复了以下......
  • ​​拍照替换 IOS手机端安装使用教程​
    拍照替换IOS手机端安装使用教程拍照插件是一款自动替换拍照数据的插件,支持单张多张照片选择替换,作用于系统全局,所有调用拍照的APP均有效。功能使用简单,单张,多张图片选择,按音量键切换照片。一、适用机型及系统1、机型:除SE和XR之外单所有iphone机型,可越狱即可2、系统:支持12系统及以......
  • ios h5 input框自动填充会有黄色背景块
    iosh5input框自动填充会有黄色背景块(比如验证码发过来可以自动填充的时候)取消黄色块input:-webkit-autofill,  input:-webkit-autofill:hover,  input:-webkit-autofill:focus,  input:-webkit-autofill:active{    -webkit-transition-delay:99999......
  • iOS 瀑布流之栅格布局
    一、效果预览二、确定需求由下面的需求示意图可知模块的最小单位是正方形,边长是屏幕宽除去边距间隔后的四等份,而每个模块的样式有小正方形(1:1)、大正方形(2:2)、横长方形(2:1)、纵长方形(1:2),动态的根据服务器下发模块样式绘制布局,可以横向滑动,限定为两行的高度。注意:上面的示意......