码迷,mamicode.com
首页 > 其他好文 > 详细

自己写的一个ffmpeg时间戳分析工具

时间:2015-12-20 01:50:03      阅读:832      评论:0      收藏:0      [点我收藏+]

标签:

代码托管

  https://github.com/gitgjogh/ffmpeg_debug_ts

使用环境

  1. FFMPEG 用于获取视频时间戳. 可以从 zeranoe 上下载事先编译的版本。(注意把ffempg所在路径加入系统或用户的环境变量$PATH)

  2. python + numpy + matplotlib 用于数据分析和画图显示. 懒得折腾numpy和matplotlib,可以安装 python-xy 或 winpython.

使用帮助

$ python ffmpe_debug_ts.py -h

Usage: ffmpeg\_debug\_ts.py [options]

Options:
  -h, --help            show this help message and exit
  -i INPUT, --input=INPUT
                        movie to be analyzed
  -l LOG, --log=LOG     log to be analyzed if you don‘t specify movie
  -o OUT, --out=OUT     Name for saved picture.
  -s START, --start=START
                        start time
  -e END, --end=END     end time
  -d DECODER, --decoder=DECODER
                        Decoder type: ffmpeg or ffprobe. [ffmpeg]
  -t THRESHOLD, --threshold=THRESHOLD
                        Time inc above the threshold will trigger error
                        report.
  -c, --compress        Whether use log scaling axises. [0]
  -k SELECT, --select=SELECT
                    select time-stamp type for showing. [pkt_pts,pkt_dts]

实例分析

$ python ffmpeg_debug_ts.py -i $MEDIA_PATH/movie1.flv

技术分享

  • 左列显示了码流中相邻两帧的时间戳变化。 正常情况下应该是一条直线。如果有数据丢失(时间跳变)则会显示为尖角脉冲。
  • 右列显示了到当前时间戳的累计帧数。 正常情况下应该是一条递增的直线。如果有数据丢失(时间增加但数据量没怎么增加)则会显示为水平阶梯。
  • 上面这个例子中视频流丢帧比较严重,音频流只有少量丢包。

当视频比较长时,数据都挤在一块,看起来不方便。可以使用 ‘-c‘ 和 ‘-e‘ 选项来放大数据丢失区域。在上面的例子中 ‘movie1.flv‘ 已解码过,二次分析时为了避免重复解码,可以使用 ‘-l‘ 选项指定已保存的时间戳数据文件。

$ python ffmpeg_debug_ts.py -l $MEDIA_PATH/movie1.flv.ffmpeg.log -s 7000 -e 8000

技术分享

有时候数据紊乱会导致时间戳跳变过大。下面这个例子中影片实际只有5秒,但是末尾有些错误数据导致时间戳从00:00:05一下跳到00:30:00。结果把0~5秒的数据都堆到坐标轴上一小段区间,什么也看不来。

$ python ffmpeg_debug_ts.py -i $MEDIA_PATH/movie2.flv

技术分享

为了防止时间跳变太大把正常的数据区间都挤压在一块什么也看不出来,可以使用 ‘-c‘ 选项对坐标轴进行对数(log)缩放。

& python ffmpeg_debug_ts.py -l $MEDIA_PATH/movie2.flv.ffmpeg.log -c

技术分享

 

自己写的一个ffmpeg时间戳分析工具

标签:

原文地址:http://www.cnblogs.com/jogh/p/5060125.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!