怎么给MP4c4d怎么添加关键帧帧

问题对人有帮助,内容完整,我也想知道答案
问题没有实际价值,缺少关键内容,没有改进余地
flv格式是视频可以包含关键帧信息,可以支持从任意时间点开始播放,请问针对mp4能做吗?七牛云的云端视频转化是怎么处理的。
来源: 七牛云存储问答
答案对人有帮助,有参考价值
答案没帮助,是错误的答案,答非所问
当然有关键帧,所有的视频编码都有关键帧。mp4从任意时间点播放,需要用我们的流媒体加速。视频转化如何处理 请参考文档
同步到新浪微博
分享到微博?
Hi,欢迎来到 SegmentFault 技术社区!⊙▽⊙ 在这里,你可以提出编程相关的疑惑,关注感兴趣的问题,对认可的回答投赞同票;大家会帮你解决编程的问题,和你探讨技术更新,为你的回答投上赞同票。
明天提醒我
关闭理由:
删除理由:
忽略理由:
推广(招聘、广告、SEO 等)方面的内容
与已有问题重复(请编辑该提问指向已有相同问题)
答非所问,不符合答题要求
宜作评论而非答案
带有人身攻击、辱骂、仇恨等违反条款的内容
无法获得确切结果的问题
非开发直接相关的问题
非技术提问的讨论型问题
其他原因(请补充说明)
我要该,理由是:
扫扫下载 AppAVAsset读MP4中H.264与判断CMSampleBuffer是否为关键帧问题 - 简书
AVAsset读MP4中H.264与判断CMSampleBuffer是否为关键帧问题
通过AVAssetReader配合AVAssetReaderTrackOutput,只需简单的几行语句可读取MP4文件中的H.264数据(假设视频为H.264编码)。读取过程中有几份CMSampleBuffer是相对有趣的,示例代码如下。
AVAssetReaderTrackOutput.copyNextSampleBuffer
经测试,整个MP4文件的视频包(SampleBuffer)一共出现5次buffer-level attachments信息,列举如下。
1、第一个:EditBoundary(P) = true
CMSampleBuffer 0x134d85df0 retainCount: 1 allocator: 0x1a1a20150
invalid = NO
dataReady = YES
makeDataReadyCallback = 0x0
makeDataReadyRefcon = 0x0
buffer-level attachments:
EditBoundary(P) = true
formatDescription = (null)
sbufToTrackReadiness = 0x0
numSamples = 0
sampleTimingArray[1] = {
PTS = {0/1 = 0.000},
DTS = {INVALID},
duration = {0/1 = 0.000}
dataBuffer = 0x0
苹果文档里并无EditBoundary相关说明。
2、第二个:ResetDecoderBeforeDecoding(P) = true
CMSampleBuffer 0x134e57320 retainCount: 1 allocator: 0x1a1a20150
invalid = NO
dataReady = YES
makeDataReadyCallback = 0x0
makeDataReadyRefcon = 0x0
buffer-level attachments:
ResetDecoderBeforeDecoding(P) = true
formatDescription = //...
sbufToTrackReadiness = 0x0
numSamples = 1
sampleTimingArray[1] = {
PTS = {0/60000 = 0.000},
DTS = {0/60000 = 0.000},
duration = { = 0.033}
sampleSizeArray[1] = {
sampleSize = 176328,
dataBuffer = 0x134e57550
苹果文档关于ResetDecoderBeforeDecoding的说明如下:
kCMSampleBufferAttachmentKey_ResetDecoderBeforeDecodingIndicates whether the sample buffer should be reset before decoding (type CFBoolean, default false).
This attachment is used at run time to indicate that a sample follows a break in decode sequence and that it is appropriate to reset the decoder before decoding this sample.
This attachment is not written to media files.
因此,ResetDecoderBeforeDecoding只是AVFoundation自行添加的信息。
3、从第三个视频包开始,不再包含buffer-level attachments数据,直到视频流结束前三个视频包时才有新的buffer-level attachments信息。不过,它们有sampleAttachmentsArray信息,这是前两个视频包所没有的,示例类似如下:
CMSampleBuffer 0x134d86260 retainCount: 1 allocator: 0x1a1a20150
invalid = NO
dataReady = YES
makeDataReadyCallback = 0x0
makeDataReadyRefcon = 0x0
formatDescription = //...
sbufToTrackReadiness = 0x0
numSamples = 1
sampleTimingArray[1] = {
PTS = { = 0.033},
DTS = { = 0.033},
duration = { = 0.033}},
sampleSizeArray[1] = {
sampleSize = 28652,
sampleAttachmentsArray[1] = {
dataBuffer = 0x134d806f0
苹果文档对sampleAttachmentsArray中NotSync的说明如下:
kCMSampleAttachmentKey_NotSyncIndicates whether the sample is a sync sample (type CFBoolean, default false).
A sync sample, also known as a key frame or IDR (Instantaneous Decoding Refresh), can be decoded without requiring any previous samples to have been decoded. Samples following a sync sample also do not require samples prior to the sync sample to have been decoded. Samples are assumed to be sync samples by default — set the value for this key to kCFBooleanTrue for samples which should not be treated as sync samples.
This attachment is read from and written to media files.
上述资料表明,NotSync为true时表示非IDR帧。这令人感到疑惑,整个视频流都没看到NotSync = false的帧。
4、倒数第三个:DrainAfterDecoding(P) = true
CMSampleBuffer 0x134e8c740 retainCount: 1 allocator: 0x1a1a20150
invalid = NO
dataReady = YES
makeDataReadyCallback = 0x0
makeDataReadyRefcon = 0x0
buffer-level attachments:
DrainAfterDecoding(P) = true
formatDescription = //...
sbufToTrackReadiness = 0x0
numSamples = 0
dataBuffer = 0x0
苹果文档对kCMSampleBufferAttachmentKey_DrainAfterDecoding的说明如下:
kCMSampleBufferAttachmentKey_DrainAfterDecodingIndicates whether the sample buffer should be drained after decoding type CFBoolean, default false).
This attachment is used at run time to indicate that a sample precedes a break in decode sequence and that it is appropriate to drain the decoder after decoding this sample.
This attachment is not written to media files.
5、倒数第二个:PostNotificationWhenConsumed(P)
CMSampleBuffer 0x134e8c940 retainCount: 1 allocator: 0x1a1a20150
invalid = NO
dataReady = YES
makeDataReadyCallback = 0x0
makeDataReadyRefcon = 0x0
buffer-level attachments:
PostNotificationWhenConsumed(P) = &CFBasicHash 0x134e8c100 [0x1a1a20150]&{type = mutable dict, count = 2,
entries =&
0 : &CFString 0x19dx1a1a20150]&{contents = "StartPresentationTimesStamp"} = &CFBasicHash 0x134e8c610 [0x1a1a20150]&{type = mutable dict, count = 4,
entries =&
0 : &CFString 0x19dx1a1a20150]&{contents = "flags"} = &CFNumber 0xb012 [0x1a1a20150]&{value = +1, type = kCFNumberSInt32Type}
1 : &CFString 0x19d478ad0 [0x1a1a20150]&{contents = "value"} = &CFNumber 0xbaf03 [0x1a1a20150]&{value = +1334000, type = kCFNumberSInt64Type}
4 : &CFString 0x19dx1a1a20150]&{contents = "timescale"} = &CFNumber 0xbea602 [0x1a1a20150]&{value = +60000, type = kCFNumberSInt32Type}
5 : &CFString 0x19dx1a1a20150]&{contents = "epoch"} = &CFNumber 0xb003 [0x1a1a20150]&{value = +0, type = kCFNumberSInt64Type}
1 : &CFString 0x19dx1a1a20150]&{contents = "EndPresentationTimesStamp"} = &CFBasicHash 0x134e8c6d0 [0x1a1a20150]&{type = mutable dict, count = 4,
entries =&
0 : &CFString 0x19dx1a1a20150]&{contents = "flags"} = &CFNumber 0xb052 [0x1a1a20150]&{value = +5, type = kCFNumberSInt32Type}
1 : &CFString 0x19d478ad0 [0x1a1a20150]&{contents = "value"} = &CFNumber 0xb003 [0x1a1a20150]&{value = +0, type = kCFNumberSInt64Type}
4 : &CFString 0x19dx1a1a20150]&{contents = "timescale"} = &CFNumber 0xb002 [0x1a1a20150]&{value = +0, type = kCFNumberSInt32Type}
5 : &CFString 0x19dx1a1a20150]&{contents = "epoch"} = &CFNumber 0xb003 [0x1a1a20150]&{value = +0, type = kCFNumberSInt64Type}
formatDescription = //...
sbufToTrackReadiness = 0x0
numSamples = 0
dataBuffer = 0x0
整理PostNotificationWhenConsumed(P)得
@"StartPresentationTimesStamp": @{
@(1334000),
@"timescale":
@"EndPresentationTimesStamp": @{
@"timescale":
苹果文档对kCMSampleBufferAttachmentKey_PostNotificationWhenConsumed的说明如下:
kCMSampleBufferAttachmentKey_PostNotificationWhenConsumedIf present, indicates that decode pipelines should post a notification when consuming the sample buffer(type CFDictionary).
This attachment is used at run time to request that a decode pipeline post a kCMSampleBufferConsumerNotification_BufferConsumed notification when this sample buffer is consumed. The value for this key is used as the userInfo dictionary in the notification.
This attachment is not written to media files.
6、最后一个:EmptyMedia(P) = true、PermanentEmptyMedia(P) = true
CMSampleBuffer 0x134e8cb60 retainCount: 1 allocator: 0x1a1a20150
invalid = NO
dataReady = YES
makeDataReadyCallback = 0x0
makeDataReadyRefcon = 0x0
buffer-level attachments:
EmptyMedia(P) = true
PermanentEmptyMedia(P) = true
formatDescription = //...
sbufToTrackReadiness = 0x0
numSamples = 0
sampleTimingArray[1] = {
PTS = {00 = 22.233},
DTS = {INVALID},
duration = {0/1 = 0.000}},
dataBuffer = 0x0
苹果文档对kCMSampleBufferAttachmentKey_EmptyMedia的说明如下:
Marks an intentionally empty interval in the sequence of samples (type CFBoolean, default false).
The sample buffer's output presentation timestamp indicates when the empty interval begins. Marker sample buffers with this attachment are used to announce the arrival of empty edits.
苹果文档对kCMSampleBufferAttachmentKey_PermanentEmptyMedia的说明如下:
Marks the end of the sequence of samples (type CFBoolean, default false).
Marker sample buffers with this attachment in addition to kCMSampleBufferAttachmentKey_EmptyMedia are used to indicate that no further samples are expected.
总结1、在读取过程中,CMSampleBuffer无直接信息表示自身是否为关键帧,使用sampleSizeArray判断也不方便,虽然IDR帧显然比P、B帧数量会大,但是不同IDR之间的大小并不相同。2、经多份数据样本测试,DTS = {INVALID}时,dataBuffer = 0x0。3、由于AVAssetReader自行添加了三个额外的kCMSampleBufferAttachmentKey:
ResetDecoderBeforeDecoding
DrainAfterDecoding
PostNotificationWhenConsumed
故使用媒体文件(如MP4)的持续时间(AVURLAsset.duration)与平均帧率(AVAssetTrack.nominalFrameRate)的乘积并不能完善地保证视频的总帧数,表示读取进度时需考虑这几个因素,才不会让读取进度超过100%。
laijinfeng - Bytedance
True nobility is being s...[转载]HTTP方式播放FLV/mp4&:nginx+Yamdi/MP4BOX
【导语】chrome浏览器确实很强,直接支持MP4拖动播放,对于其他播放器,可以使用以下方法来支持拖动播放。拖动的关键在于生成关键帧等元数据信息,便于服务器和播放器支持拖动。
另外,nginx web服务器体验起来,也是很有前途的一个web服务器,值得研究。
flv 视频可以采用两种方式发布:
一、普通的 HTTP 下载方式
二、基于 Flash Media Server 或 Red5 服务器的 rtmp/rtmpt 流媒体方式。
多数知名视频网站都采用的是前一种方式。
两种方式对比如下:
Rtmp/rtmpt
生成关键帧后可拖动播放
任意拖动播放
下载完成后不再消耗服务器资源
无缓存,每次播放都会消耗服务器资源
这里说一下怎么用nginx 搭建http 方式的视频点播服务器,主要分为三步:
一、 nginx 安装及配置
1. 下载nginx 最新win32 版本解压到任意目录
2. 打开cmd 进入nginx 目录,使用命令start nginx 启动nginx
(默认使用confnginx.conf 配置,可用-c 选项指定要使用的配置文件,更多参数可使用nginx &h 查看)
二、 nginx 对flv 的支持
1. 编辑配置文件confnginx.conf ,加入如下配置:
在http 块加入启动gzip 的配置
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types text/
在server 块中加入启用flv 的配置:
limit_rate_after 1m; # 下载1M 后开始限速
limit_rate 100k; # 将速度限制为100k/s
location ~ .flv {
2. 使用命令nginx &s reload 重新加载配置文件
三、 客户端播放器
1. 下载开源的flash 播放器jwplayer
2. 将文件解压到nginx 下的html 目录
访问http://localhost:8080/player.swf?type=http&file=1.flv即可播放视频
注意:现在视频能播放了,但并不支持拖动功能,因为没有给flv 文件添加“关键帧”,可以的工具有“yamdi”
和“flvtool”,以yamdi win32 版为例,下载解压后进入cmd 执行:
yamdi &i src.flv &o dst.flv
意思是将src.flv 添加关键帧,并输出为dst.flv 。
,这时我们再访问http://localhost:8080/player.swf?type=http&file=dst.flv即可自由拖动播放了。
=========================================================================================
This post is a comparison of the performance of different tools
available to tag FLV and MP4 containers with specific metadata
(e.g. title, keyframes, generator or other custom fields…). For FLV
containers flvtool2, flvtool++ and yamdi are compared. For the MP4
container MP4box, AtomicParsley and ffmpeg are compared.
Here are the IMO three most important FLV taggers tested on a
125MB FLV:
Large Files
Custom Tags
flvtool2 -UP -band:Test -user:Test -date:1995 -genres:pop
flvtool++ test.flv -tag band “Test” -tag user “Test” -tag date
“1995&P -tag genres “pop” test2.flv
yamdi -i test.flv -o test2.flv -c “Test”
The performance of flvtool2 is horrendous. For films of 120min
it will take hours to process.
Therefore:&Do not use it! Use
Facebooks flvtool++ instead. I guess the bad performance results
from it being built in Ruby. Also notice the “Large File” column
indicating large file support which officially only yamdi support
(by adding compile flag -D_FILE_OFFSET_BITS=64). Another important
point is the “In Memory” column indicating that flvtool++ loads the
entire file into memory when tagging, which is problematic when
tagging large files. Given this results
only&yamdi should be used for FLV
Now for the MP4 tagging. Here you can select between a lot of
tools from the net, but only a few of them are command line based
and available for Unix. The MP4 test file used is 100MB large.
AtomicParsley test.mp4 &artist “Test” &genre “Test” &year
MP4Box -itags Name=Test:Artist=Me:disk=95/100 test.mp4
ffmpeg -i test.mp4 -metadata title=”Test” -metadata
artist=”Test” -metadata date=”1995&P -acodec copy -vcodec copy
Given that recent ffmpeg brings the tagging for MP4 out of the box
(it doesn’t for FLV though) you do not even need an external tool
to add the metadata
自:http://www.aojie.biz/1030
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。添加一个或多个关键帧_翼狐网
当前位置:
购买整套教程¥0元
VIP价格¥0元
该课时视频点播价为0
您是普通会员,需支付:0(开通VIP会员即享点播8折)
您的余额:
余额不足?或免费领果仁
帐号密码:
使用微信付款
其他方式支付:
请先通过邮箱验证激活您的账号,然后购买教程。
免费领取VIP限时体验资格,超强超清教程免费看
您需要开通或才能观看超清画质
VIP包月服务05月优惠:399 /月(39.9
新会员开通一年送3个月,开通半年送1个月
超清包月服务 包月价格:49 /月(4.9
您需要先翼狐网,才能观看该教程。
声音有问题
看不了-无法播放
英文无中文字幕
下载教程和工程文件
下载当前教程的MP4格式
下载当前教程的YH格式
该教程共123个视频可下载
下载当前的工程文件
该教程共1个文件可下载
暂无介绍。
相关专辑推荐
软件:Premiere
学习人数: 66948
软件:Premiere
学习人数: 44357
软件:Premiere
学习人数: 11720
软件:Premiere
学习人数: 12369
软件:Premiere
学习人数: 41046
软件:Premiere
学习人数: 3540
软件:Premiere
学习人数: 14470
软件:After Effects
学习人数: 1345
暂无评论,一起来抢沙发~

我要回帖

更多关于 pr怎么添加关键帧 的文章

 

随机推荐