Beispiel #1
0
 def test_bitrate(self):
     try:
         media = FFProbe(test_videos[0],
                         show_streams=True,
                         show_packets=True)
         packets_by_stream = media.get_packets_by_stream()
         for stream_index, packets in packets_by_stream.items():
             bytes = sum([packet.size() for packet in packets], 0)
             print(
                 'Stream bitrate:', bytes * 8 /
                 (media.streams()[stream_index].duration_seconds() * 1000))
     except Exception as e:
         raise e
Beispiel #2
0
def print_ffprobe(media: FFProbe):
    print('\tFormat:',
          media.format().format_name(), "(",
          media.format().format_long_name(), ")")
    print('\tStreams:', len(media.streams()))
    for index, stream in enumerate(media.streams(), 1):
        print('\tStream: ', index)
        print('\t\tCodec:', stream.codec_description())
        if isinstance(stream, FFVideoStream):
            print('\t\tFrame Rate:', stream.frame_rate())
            print('\t\tFrame Size:', stream.frame_size())
        print('\t\tDuration:', stream.duration_seconds())
        print('\t\tFrames:', stream.frames())
        print('\t\tIs video:', isinstance(stream, FFVideoStream))
    print('\tPackets:', len(media.packets()))
    print('\tFrames:', len(media.frames()))
    frames_by_stream = media.get_frames_by_stream()
    for item in frames_by_stream.items():
        print('\tFrames: (%d,%d)' % (item[0], len(item[1])))
    packets_by_stream = media.get_packets_by_stream()
    for item in packets_by_stream.items():
        print('\tPackets: (%d,%d)' % (item[0], len(item[1])))