Open zzcl1990 opened 8 years ago
这是so上的一个解释: It is just the nature of the formats. The moov atom contains all the metadata for every frame of audio or video in the file. So, the more frames, the larger the moov. By putting all this metatadata in one place, it makes seeking within a file much easier. Once you have downloaded the moov, the player knows exactly what byte in the file to request to seek to a specific frame or time. An FLV file is sent one frame at a time, there is no index of frame locations, this makes seeking extremely difficult for the player.
You can try making the moov smaller by ensuring your video is not in variable frame rate, and that you do not have unnecessary data (such as movie posters) embedded in the metadata. Having the server send gzip streams may help as well as the moov should compress well.
播放时长超过一个小时,首帧出现时间将明显增加。主要耗时集中在解析视频的头部
1492223125.139-->avformat_open_input start 1492223125.140-->Setting default whitelist 'http,https,tls,rtp,tcp,udp,crypto,httpproxy' 1492223125.232-->Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100 1492223125.232-->ISO: File Type Major Brand: isom 1492223125.232-->Unknown dref type 0x08206c7275 size 12 1492223127.038-->Offset DTS by ctts[0].duration: 2000 1492223127.038-->Processing st: 0, edit list 0 - media time: -1, duration: 1648 1492223127.038-->Processing st: 0, edit list 1 - media time: 2000, duration: 133206656 1492223127.055-->drop a frame at curr_cts: 133212656 @ 199809 1492223127.058-->Unknown dref type 0x08206c7275 size 12 1492223129.914-->Processing st: 1, edit list 0 - media time: 0, duration: 367150008 1492223129.951-->rfps: 23.916667 0.009681 1492223129.951-->rfps: 23.916667 0.009681 1492223129.951-->rfps: 24.000000 0.000042 1492223129.951-->rfps: 24.083333 0.009700 1492223129.951-->rfps: 48.000000 0.000170 1492223129.951-->rfps: 48.000000 0.000170 1492223129.951-->rfps: 120.000000 0.001061 1492223129.951-->rfps: 240.000000 0.004244 1492223129.951-->rfps: 240.000000 0.004244 1492223129.951-->rfps: 23.976024 0.000838 1492223129.951-->rfps: 23.976024 0.000838 1492223129.951-->rfps: 47.952048 0.003353 1492223129.951-->rfps: 47.952048 0.003353 1492223130.022-->avformat_open_input end 1492223130.024-->Option safe not found. 1492223130.024-->avformat_find_stream_info start 1492223130.024-->Before avformat_find_stream_info() pos: 9874330 bytes read:9875384 seeks:0 nb_streams:2 1492223130.043-->Reinit context to 1920x1088, pix_fmt: yuv420p 1492223130.068-->no picture 1492223130.098-->All info found 1492223130.099-->After avformat_find_stream_info() pos: 9900005 bytes read:9900584 seeks:0 frames:2 1492223130.100-->avformat_find_stream_info end 1492223130.100-->max_frame_duration: 10.000
@bbcallen 这应该是FFmpeg的一个issue,对了,Web播放mp4格式时,首帧加载速度明显快很多
我用ijkplayer播放mp4流媒体,首播时间太长,文件越大时间越长,跟了一下发现主要是libavformat中的mov_read_default解析mp4头部花了大量时间,针对这个问题大家有没有好的解决方案呢