Git Product home page Git Product logo

bitrate-plotter's Introduction

Bitrate Plotter

A command line program that plots one of the following graphs:

[1] A graph showing the bitrate every second. The graph can be "filled" or "unfilled".

[2] A graph showing bitrate of every closed GOP (you must specify the -gop argument). Applicable to video files only.

You can find an example of each graph type below:

Graph type [1] (unfilled):

Graph type [1] (unfilled)

Image 1: a graph showing the bitrate every second. To see an example of a filled graph, check out the "Example Graphs" folder.

Graph type [2]:

Graph type [2]

Image 2: a graph showing the bitrate of every closed GOP. The distances between the lines show the length (in seconds) of each closed GOP.

When opting for graph type [1], the data used to plot the graph is saved in a file named BitrateEverySecond.txt. The data is in the format timestamp --> bitrate. Here's an example:

Timestamp: 1.001 --> 9.201 Mbps
Timestamp: 2.002 --> 9.256 Mbps
Timestamp: 3.003 --> 8.46 Mbps
Timestamp: 4.004 --> 8.898 Mbps
Timestamp: 5.005 --> 9.429 Mbps
Timestamp: 6.006 --> 8.784 Mbps
Timestamp: 7.007 --> 8.522 Mbps
Timestamp: 8.008 --> 8.276 Mbps
Timestamp: 9.009 --> 10.259 Mbps
Timestamp: 10.01 --> 9.958 Mbps

Requirements

  • Python 3.6+
  • FFprobe executable in your PATH.
  • pip install -r requirements.txt

Usage

You can find the output of python main.py -h below:

usage: main.py [-h] -f FILE_PATH [-g {filled,unfilled}] [-gop] [-se SHOW_ENTRIES] [-ngm] [-s STREAM_SPECIFIER]

optional arguments:
  -h, --help            show this help message and exit
  -f FILE_PATH, --file-path FILE_PATH
                        Enter the path of the file that you want to analyse. If the path contains a space, it must be
                        surrounded in double quotes. Example: -f "C:/Users/H/Desktop/my file.mp4"
  -g {filled,unfilled}, --graph-type {filled,unfilled}
                        Specify the type of graph that should be created. The default graph type is "unfilled". To see
                        the difference between a filled and unfilled graph, check out the example graph files.
  -gop                  Instead of plotting the bitrate every second, plot the bitrate of each GOP. This plots GOP end
                        time (x-axis, in seconds) against GOP bitrate (y-axis, kbps).
  -se SHOW_ENTRIES, --show-entries SHOW_ENTRIES
                        Only applicable if --no-graph-mode is specified. Use FFprobe's -show_entries option to specify
                        what to output. Example: -se frame=key_frame,pkt_pts_time
  -ngm, --no-graph-mode
                        Enable "no graph mode" which simply writes the output of ffprobe to a .txt file. You should
                        also use the --show-entries argument to specify what information you want ffprobe to output.
  -s STREAM_SPECIFIER, --stream-specifier STREAM_SPECIFIER
                        Use FFmpeg stream specifier syntax to specify the audio/video stream that you want to analyse.
                        The defaults for audio and video files are a:0 and V:0, respectively. Note that stream index
                        starts at 0. As an example, to target the 2nd audio stream, enter: --stream-specifier a:1

bitrate-plotter's People

Contributors

crypticsignal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

bitrate-plotter's Issues

Can't view Graph type 2 with GOP

Hi, with parameter -g works well but -gop i received next issue:

Traceback (most recent call last):
  File "C:\Soft\bitrate-plotter-main\main.py", line 138, in <module>
    gop_end_times, gop_bitrates = get_gop_bitrates(process, number_of_frames, data_output_path)
  File "C:\Soft\bitrate-plotter-main\ffprobe_output_parser.py", line 72, in get_gop_bitrates
    key_frame, pkt_dts_time, pkt_size = line.strip().split(",")
ValueError: not enough values to unpack (expected 3, got 1)

Minor fix for current ffprobe

in ffprobe_out_parser.py i had to change the parser for ffprobe output.

    for line in io.TextIOWrapper(process.stdout, encoding="utf-8"):
        ## ffprobe will return the time in ms and the size in bytes.
        if line.strip():  # Check if the line is not empty                                                                                                                       
            dts_time, packet_size = line.strip().split(",", 2)[:2]   # grab only 2 fields
             # original bad code dts_time, packet_size = line.strip().split(",")

It was choking on empty lines and for some reason ffprobe was returning lines with a trailing comma. This gets past that problem.

Thanks for the real hepful tool!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.