本帖最后由 TangMonk 于 2016-7-27 10:26 编辑
1 av_seek_frame
对视频进行跳转规律
1.1 flags
参数
#define AVSEEK_FLAG_BACKWARD 1 ///< seek backward,若你设置seek时间为1秒,可是只有0秒和2秒上才有I帧,则时间从0秒开始。 #define AVSEEK_FLAG_BYTE 2 ///<seeking based on position in bytes #define AVSEEK_FLAG_ANY 4 ///< seek toany frame, even non-keyframes,若你设置seek时间为1秒,可是只有0秒和2秒上才有I帧,则时间从2秒开始。 #defineAVSEEK_FLAG_FRAME 8 ///< seeking based on frame number,若你设置seek时间为1秒,可是只有0秒和2秒上才有I帧,则时间从2秒开始。
1.2 seek
不成功的缘由
1.2.1
格式问题 [td]
1.2.2 ffmpeg
版本问题
有的版本能够知足上面的格式关系
1.3 flv
对于flv格式,pkt->pos指向该packet的h264数据位置
1.4 MP4
有些mp4的片断的最后一个packet的pos为packet.pos,那么该mp4在seek的时候须要用到文件pos-50000位置的数据,不一样的视频该偏移不一样
1.5 av_seek_frame
到40.0秒处,av_read_frame读到的第一个packet可能不是40秒处的视频packet,多是以前的音频packet
2
遇到的问题及解决
2.1 probe size[flv @ 0x608380] Packet mismatch 0 7474
[flv @ 0x608380] Could not find codec parameters for stream 0 (Video:h264, none, 502 kb/s): unspecified size Consider increasing the value for the'analyzeduration' and 'probesize' options [flv @ 0x608380] Could not find codecparameters for stream 1 (Audio: aac, 44100 Hz, stereo, 32 kb/s): unspecifiedsample format Consider increasing the value for the 'analyzeduration' and'probesize' options
2.1.1
缘由是自定义IO的probe size参数设置的太小
2.2 mp4
文件执行时打印错误: [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fff340008c0] error reading header
缘由: 头的大小太小,分配大一点的头解决
2.3 mp4
文件执行到avformat_open_input,报[mov,mp4,m4a,3gp,3g2,mj2@ 0x7fff340008c0] moov atom not found
别人那里没问题 缘由:头过小,10M才能够,5M都不行
|