flv 元信息(metadata)

flv文件中的元信息,是一些描述flv文件各类属性的信息。这些信息以AMF格式保存在文件的起始部分。adobe官方的标准flv元信息项目如下(来源:http://help.adobe.com/en_US/FlashMediaLiveEncoder/3.0/Using/WS5b3ccc516d4fbf351e63e3d11c104ba878-7ff5.html):

  • audiochannels

  • audiocodecid

  • audiodatarate

  • audiodevice

  • audioinputvolume

  • audiosamplerate

  • creationdate

  • duration (media files only)

  • fmleversion (Flash Media Live Encoder version) (media files only)

  • framerate

  • height

  • lastkeyframetimestamp (media files only)

  • lasttimestamp (media files only)

  • presetname

  • videocodecid

  • videodatarate

  • videodevice

  • videokeyframe_frequency

  • width

每个元信息项目所表达的意思还是不难猜测。虽然现在网络流媒体中,flv格式占据主导地位,但是标准的元信息项目中,经常被用到的只有不到一半。我们拿youku的flv文件中所包含的元信息项目做个比较。
liruqi@Apollo:~/Videos$ flvtool2 -P youku.flv
---
/home/liruqi/Videos/youku.flv:
duration: 300.867
hasMetadata: true
hasKeyframes: true
audiodatarate: 43.4919904392971
audiosamplerate: 22050
framerate: 15.0033071091213
datasize: 9661244
audiosamplesize: 16
hasVideo: true
lasttimestamp: 300.867
stereo: true
videocodecid: 2
canSeekToEnd: false
lastkeyframetimestamp: 298.933
audiosize: 1801606
videosize: 7795514
hasAudio: true
keyframes:
filepositions:
- 1571
- 255073
- 432405
- 623314
- 809714
- 983310
- 1182506
- 1353766
- 1524852
- 1707253
- 1898530
- 2116411
- 2306012
- 2476133
- 2671519
- 2841358
- 3009769
- 3163044
- 3340645
- 3502065
- 3663881
- 3867247
- 4050995
- 4251763
- 4411694
- 4587080
- 4766001
- 4967281
- 5162796
- 5345682
- 5523669
- 5672578
- 5867093
- 6086781
- 6257768
- 6453268
- 6656733
- 6854996
- 7023930
- 7188798
- 7362948
- 7560148
- 7778350
- 8007845
- 8265492
- 8453671
- 8678896
- 8892715
- 9084570
- 9281456
- 9584974
times:
- 0
- 4.933
- 10.933
- 16.933
- 22.933
- 28.933
- 34.933
- 40.933
- 46.933
- 52.933
- 58.933
- 64.933
- 70.933
- 76.933
- 82.933
- 88.933
- 94.933
- 100.933
- 106.933
- 112.933
- 118.933
- 124.933
- 130.933
- 136.933
- 142.933
- 148.933
- 154.933
- 160.933
- 166.933
- 172.933
- 178.933
- 184.933
- 190.933
- 196.933
- 202.933
- 208.933
- 214.933
- 220.933
- 226.933
- 232.933
- 238.933
- 244.933
- 250.933
- 256.933
- 262.933
- 268.933
- 274.933
- 280.933
- 286.933
- 292.933
- 298.933
lastkeyframelocation: 9584974
filesize: 9662773
height: 256
audiocodecid: 2
videodatarate: 201.133827405465
metadatacreator: modify by youku.com in 20090909
width: 320
...

下面重点讲述一下keyframes。keyframes几乎是一个非官方的标准。在网上已经很难看到flv文件格式,但是metadata里面不包含keyframes项目的视频。两个常用的操作metadata的工具是flvtool2和FLVMDI,都是把keyframes作为一个默认的元信息项目。关于keyframes,在FLVMDI的主页(http://www.buraks.com/flvmdi/)上有描述:
keyframes: (Object) This object is added only if youspecify the /k switch. 'keyframes' is known to FLVMDI and if /k switchis not specified, 'keyframes' object will be deleted.
'keyframes' object has 2 arrays: 'filepositions' and 'times'. Botharrays have the same number of elements, which is equal to the numberof key frames in the FLV. Values in times array are in 'seconds'. Eachcorrespond to the timestamp of the n'th key frame. Values infilepositions array are in 'bytes'. Each correspond to the filepositionof the nth key frame video tag (which starts with byte tag type 9).

简单来说,keyframes保存着关键帧的时间和文件偏移量的映射。在网络流媒体环境下,服务器能够以很小的代价保证发送给客户端的第一帧是可以显示出来的关键帧,从而提高用户体验。FLVMDI我没用过。用flvtool2来更新源信息的命令是:
flvtool2 -U youku.flv youku.flv.out
上面的那个youku的视频,我用flvtool2更新了元信息之后,元信息如下:
liruqi@Apollo:~/Videos$ flvtool2 -P youku.flv.out
---
/home/liruqi/Videos/youku.flv.out:
duration: 300.934
hasMetadata: true
hasKeyframes: true
framerate: 14
datasize: 9598746
audiodatarate: 44.5357982098402
audiosamplerate: 22000
cuePoints:
audiosamplesize: 16
hasVideo: true
lasttimestamp: 300.867
videocodecid: 2
canSeekToEnd: false
stereo: true
audiosize: 1801606
lastkeyframetimestamp: 298.933
videosize: 7795514
audiodelay: 0
hasAudio: true
filesize: 9662891
height: 256
keyframes:
filepositions:
- 1651
- 255153
- 432485
- 623394
- 809794
- 983390
- 1182586
- 1353846
- 1524932
- 1707333
- 1898610
- 2116491
- 2306092
- 2476213
- 2671599
- 2841438
- 3009849
- 3163124
- 3340725
- 3502145
- 3663961
- 3867327
- 4051075
- 4251843
- 4411774
- 4587160
- 4766081
- 4967361
- 5162876
- 5345762
- 5523749
- 5672658
- 5867173
- 6086861
- 6257848
- 6453348
- 6656813
- 6855076
- 7024010
- 7188878
- 7363028
- 7560228
- 7778430
- 8007925
- 8265572
- 8453751
- 8678976
- 8892795
- 9084650
- 9281536
- 9585054
times:
- 0
- 4.933
- 10.933
- 16.933
- 22.933
- 28.933
- 34.933
- 40.933
- 46.933
- 52.933
- 58.933
- 64.933
- 70.933
- 76.933
- 82.933
- 88.933
- 94.933
- 100.933
- 106.933
- 112.933
- 118.933
- 124.933
- 130.933
- 136.933
- 142.933
- 148.933
- 154.933
- 160.933
- 166.933
- 172.933
- 178.933
- 184.933
- 190.933
- 196.933
- 202.933
- 208.933
- 214.933
- 220.933
- 226.933
- 232.933
- 238.933
- 244.933
- 250.933
- 256.933
- 262.933
- 268.933
- 274.933
- 280.933
- 286.933
- 292.933
- 298.933
videodatarate: 205.961039263196
audiocodecid: 2
metadatacreator: inlet media FLVTool2 v1.0.6 - http://www.inlet-media.de/flvtool2
metadatadate: Mon Oct 26 00:32:57 GMT+0800 2009
width: 320
hasCuePoints: false
...

所谓的更新,就是flvtool2把元信息全部改写了。实际上跟youku原来的没差多少,只是把文件属性重新计算了一遍。
再看看FLVMDI所定义的metadata的标准,跟flvtool2的比较类似:

  • duration: (Number) Length of the FLV in seconds. FLVMDI computes this value.
  • lasttimestamp: (Number) TimeStamp of the last tag in the FLV file.
  • lastkeyframetimestamp: (Number) TimeStamp of the last video tag which is a key frame. This info might be needed because seeking a frame after this time usually does not work.
  • width: (Number) Width of the video in pixels. (Flash exporter 1.1 sets this to 0).
  • height: (Number) Height of the video in pixels. (Flash exporter 1.1 sets this to 0).
  • videodatarate: (Number) FLVMDI does not compute this value and imports it if present. (Defaults to 0).
  • audiodatarate: (Number) FLVMDI does not compute this value and imports it if present. (Defaults to 0).
  • framerate: (Number) FLVMDI computes this value, but uses imported value if not 0.
  • creationdate: (String) FLVMDI cannot compute this value and imports it if present. (Defaults to 'unknown').
  • filesize: (Number) Filesize in bytes (including the injected data).
  • videosize: (Number) Total size of video tags in the file in bytes.
  • audiosize: (Number) Total size of audio tags in the file in bytes.
  • datasize: (Number) Total size of data tags in the file in bytes.
  • metadatacreator: (String) Will be set to 'Manitu Group FLV MetaData Injector 2'.
  • metadatadate: (Date) Date and time metadata added. (Note that this is not of type string like 'creationdate').
  • xtradata: (string) Additional string data if specified.
  • videocodecid: (Number) Video codec ID number used in the FLV. (Sorenson H.263 =2, Screen Video =3, On2 VP6 = 4 and 5, Screen Video V2 = 6).
  • audiocodecid: (Number) Audio codec ID number used in the FLV. (Uncompressed = 0, ADPCM = 1, MP3 = 2, NellyMoser = 5 and 6).
  • audiodelay:(Number) Audio delay in seconds. Flash 8 encoder delays the video forbetter synch with audio (Audio and video does not start both at time 0,Video starts a bit later). This value is also important for Flash 8Video Encoder injected Cue Points, because logical time of the cuepoints does not correspond to physical time they are inserted in theFLV. (Cue points are injected before encoding, when the video isshifted by 'audio delay' seconds, cue points are also shifted and theirphysical time in the FLV changes).
  • canSeekToEnd: (Boolean) True if the last video tag is a key frame and hence can be 'seek'ed.
  • keyframes: (Object)

很显然,优酷就是改了flvtool2的一些代码然后拿来用了,还谦卑地说"modify by youku.com"。这句话都有语法问题,真是够山寨的。

原文地址:http://hi.baidu.com/barnabas/blog/item/854b3523f28c234493580766.html

flv文件元信息(metadata)相关推荐

  1. 分析flv文件的信息

    上一篇博文"FLV文件格式解析"提到的小工具FLVParse,是由于工作需要,我自己写的一个小程序. 这个工具的主要功能是查看FLV的文件结构,帮助我们理解FLV格式.另外,如果涉 ...

  2. linux修改文件元信息,Linux 文件元数据详细讲解

    已知linux上文件有两种数据: 1.元数据(metadata):用来描述一个文件的特征的系统数据 2.数据:泛指普通文件中的实际数据: 硬盘格式化的时候,操作系统自动将硬盘分成两个区域.一个是数据区 ...

  3. R语言使用fs包的file_info函数查看文件元信息(属性信息)、使用file_chmod函数修改文件的权限、使用file_chown函数修改文件的所有者

    R语言使用fs包的file_info函数查看文件元信息(属性信息).使用file_chmod函数修改文件的权限.使用file_chown函数修改文件的所有者 目录

  4. java获取hadoop目录结构_2、查看 hadoop HDFS 的文件元信息

    [zwh@hadoop current]$ hdfs oiv -p XML -i fsimage_0000000000000000025  -o fsimage.xml [zwh@hadoop cur ...

  5. 从flv文件中提取音频并存储为mp3格式

    在优酷上下载了一些教学视频,为了把它们放到mp3里面,需要从这些flv文件中提取出音频数据并存储为mp3格式. 操作系统是centos 5.3. 在网上搜索了一下,找到以下方法: 方法一:使用menc ...

  6. 动态播放外部FLV 文件和预加载 FLV 文件

    /***************** wgscd (c)2005 ' qq:153964481 e-mail:wgscd@126.com  blog:http://blog.csdn.net/wgsn ...

  7. php获取视频文件属性,使用php获取flv视频文件的信息

    最近要做一个判断flv文件信息的程序,使用php对flv文件进行解析判断,百度了半天也没有对应的信息,后来又去csdn发帖子,得到的答复是目前还没有直接可以对flv文件进行处理的方法,于是决定放弃这个 ...

  8. GDCM:显示有关输入DICOM文件的meta元信息的测试程序

    GDCM:显示有关输入DICOM文件的meta元信息 GDCM:显示有关输入DICOM文件的meta元信息 GDCM:显示有关输入DICOM文件的meta元信息 #include "gdcm ...

  9. FLV文件(H264 + AAC)格式超详细分析

    最近自己动手将H264视频流和AAC音频流合成flv文件,但是没有采用开源的ffmpeg的api来处理音视频流.方法就是模仿ffmpeg中libavformat/flvenc.c 文件写代码来完成音视 ...

最新文章

  1. 可能是 nginx 限速最容易理解的说明
  2. 再见,数据库!MySQL千亿数据分库分表架构,堪称惊艳!
  3. redchat怎么编写shell脚本_shell脚本编写思路
  4. linux下文件的压缩和解压缩
  5. 渴望订阅– RxJava常见问题解答
  6. Substitute Algorithm(替换算法)
  7. pwm波如何控制电机代码_PWM波控制720电机
  8. 点到直线的距离c语言程序,点到线段的距离 题解(C++)
  9. 将视图转为image_OpenShift 4.3 之 直接将Web应用当成Serverless运行
  10. 无人驾驶出租车已经在北京全面开放,未来普通人还需要学驾照吗?
  11. 内卷时代,普通测试员的铁饭碗究竟是什么?
  12. python真的是吹过了-被吹的神乎其神的Python到底都能干什么
  13. C++静态成员总结(转)
  14. SDR WiFi平台 gr-ieee802-11 软件无线电实现802.11协议
  15. 【最新】电脑常用装机软件组合 装机必备
  16. SQL——查询和1002号的同学学习的课程完全相同的其他同学的学号和姓名
  17. Math.abs()方法
  18. button layui-btn 色调
  19. 斯皮尔曼相关系数范围_Spearman Rank(斯皮尔曼等级)相关系数及MATLAB实现
  20. 百度AICA迎来毕业季,55位新晋“首席AI架构师”推进产业智能化

热门文章

  1. openstack create flavor.sh
  2. 使用Typora画 流程图、时序图、顺序图、甘特图、等图详解
  3. msk调制 vhdl_MSK调制解调技术的原理及应用分析
  4. smart计算机英语作文,介绍smart cars英语作文【精选】
  5. C编译器01-扫描器
  6. what is BI and OLAP?
  7. 花落人独立,微雨燕双飞
  8. centos8安装dm8,动态库加载成功后导致undefined symbol: EVP_KDF_ctrl, version OPENSSL_1_1_1b fatal: Could not read
  9. 输入一个整数,判断它是奇数还是偶数。 若n是奇数,则输出“This is an odd number.” 若n是偶数,则输出“This is a even number.”
  10. 计算机cpu风扇不转怎么办,CPU风扇不转但是能开机,电脑风扇不转了怎么修理