19 def check_pts_dts(frame):
20 diff = frame['pkt_pts_time'] - frame['pkt_dts_time']
22 print("\tPTS != DTS: %f" % diff)
28 global video_frame_count
29 if frame['media_type'] == 'video' and 'video' in types:
30 if last_video_pts is not None and frame['pkt_pts_time'] <= last_video_pts:
31 print 'Out of order video frame %f (%d) is same as or behind %f (%d)' % (frame['pkt_pts_time'], frame['pkt_pts'], last_video_pts, last_video)
32 elif last_video_pts is not None:
33 print 'OK V frame %f %f %f %f %d indices %d/%d' % (frame['pkt_pts_time'], frame['pkt_dts_time'], frame['pkt_pts_time'] - last_video_pts, 1 / (frame['pkt_pts_time'] - last_video_pts), frame['pkt_size'], video_frame_count, frame['pkt_pts_time'] * VIDEO_RATE)
36 print 'OK V frame %f counted %d' % (frame['pkt_pts_time'], video_frame_count)
37 last_video = frame['pkt_pts']
38 last_video_pts = frame['pkt_pts_time']
39 video_frame_count += 1
40 elif frame['media_type'] == 'audio' and 'audio' in types:
41 stream_index = frame['stream_index']
42 if stream_index in last_audio_pts and (stream_index == AUDIO_STREAM or AUDIO_STREAM is None):
43 print 'OK A[%s] frame %4.8f %4.8f %4.8f %4.8f %d' % (stream_index, frame['pkt_pts_time'], frame['pkt_dts_time'], frame['pkt_pts_time'] - last_audio_pts[stream_index], 1 / (frame['pkt_pts_time'] - last_audio_pts[stream_index]), frame['pkt_size'])
45 if stream_index in last_channels and frame['channels'] != last_channels[stream_index]:
46 print "\t*** unusual channel count"
47 last_audio_pts[stream_index] = frame['pkt_pts_time']
48 last_channels[stream_index] = frame['channels']
51 p = subprocess.Popen(shlex.split('ffprobe -show_frames "%s"' % sys.argv[1]), stdin=None, stdout=subprocess.PIPE)
54 l = p.stdout.readline()
63 elif l != '[FRAME]' and l != '[SIDE_DATA]' and l != '[/SIDE_DATA]':
65 if s[0] in ['pkt_pts_time', 'pkt_dts_time', 'pkt_pts', 'pkt_dts']:
66 frame[s[0]] = float(s[1])
67 elif s[0] in ['channels', 'pkt_size', 'nb_samples']:
68 frame[s[0]] = int(s[1])