h26x-extractor


Nameh26x-extractor JSON
Version 0.8.1 PyPI version JSON
download
home_pagehttps://github.com/slhck/h26x-extractor
SummaryExtract NAL units from H.264 bitstreams
upload_time2023-01-08 15:59:36
maintainer
docs_urlNone
authorWerner Robitza
requires_python>=3.8
licenseMIT
keywords video h264
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # h26x-extractor

[![PyPI version](https://img.shields.io/pypi/v/h26x-extractor.svg)](https://pypi.org/project/h26x-extractor)

Author: Werner Robitza, with contributions from @chemag, Paulo Sherring.

Extracts NAL units from H.264 bitstreams and decodes their type and content, if supported.

⚠️ `h26x-extractor` is neither fast nor robust to bitstream errors. It's rather a playground for parsing bitstreams. Use with caution! This program is no longer maintained, PRs are welcome.

Contents:

- [Installation](#installation)
- [Status](#status)
- [Usage](#usage)
- [Programmatic usage](#programmatic-usage)
- [Alternatives](#alternatives)

## Installation

Requirements: Python 3.8 or higher

Via pip:

    pip3 install h26x-extractor

## Status

Currently supported:

- Parsing of H.264 bitstreams
- Parsing of NALU
- Parsing of AUD
- Parsing of CodedSliceIDR
- Parsing of CodedSliceNonIDR
- Parsing of SPS
- Parsing of PPS

Currently planned:

- Parsing of SEI
- Parsing of VUI
- Parsing of H.265 bitstreams

## Usage

If you installed the program via pip, you can run it directly:

    h26x-extractor [options] <input-file>...

Otherwise you can clone this repo and run it via:

    python3 -m h264_extractor [options] <input-file>...

You can pass the `-v` flag to enable verbose output, e.g. the following. You will get, for each NAL unit:

- The byte position range
- The offset from the start of the stream
- The overall length including start code
- The type (also translated in plaintext)
- Its content in raw bytes, encoded as hex
- Its RBSP content
- A table with its content decoded, if supported

Example:

    NALU bytepos:   [0, 28]
    NALU offset:    0 Bytes
    NALU length:    29 Bytes (including start code)
    NALU type:      7 (Sequence parameter set)
    NALU bytes:     0x0000000167f4000d919b28283f6022000003000200000300641e28532c
    NALU RBSP:      0xf4000d919b28283f602200000002000000641e28532c

    SPS (payload size: 22.0 Bytes)
    +--------------------------------------+---------+
    | field                                | value   |
    +======================================+=========+
    | constraint_set0_flag                 | 0       |
    +--------------------------------------+---------+
    | constraint_set1_flag                 | 0       |
    +--------------------------------------+---------+
    ....

## Programmatic usage

You can also use this library in your code, e.g.:

```python
from h26x_extractor.h26x_parser import H26xParser

def do_something(bytes):
    pass
    # do something with the NALU bytes

H26xParser.set_callback("nalu", do_something)
H26xParser.parse()
```

The callback is called for each type of info found. Valid callbacks are:

- `sps`
- `pps`
- `slice`
- `aud`
- `nalu`

The raw data for all callbacks includes the RBSP.

You can also call the `nalutypes` classes to decode the individual fields, e.g. `nalutypes.SPS`:

```python
from h26x_extractor.h26x_parser import H26xParser
from h26x_extractor.nalutypes import SPS

def parse_sps(bytes):
    sps = SPS(bytes)
    sps.print_verbose()

H26xParser.set_callback("sps", parse_sps)
H26xParser.parse()
```

## Alternatives

[h264bitstream](https://github.com/aizvorski/h264bitstream) is a proper H.264 parser.

FFmpeg can also parse bitstream data:

```
ffmpeg -i video.h264 -c copy -bsf:v trace_headers -f null - 2> output.txt
```

# License

The MIT License (MIT)

Copyright (c) 2017-2023 Werner Robitza

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


# Changelog


## v0.8.1 (2023-01-08)

* Bump version to 0.8.1.

* Organize imports.

* Update module structure, readme.


## v0.8.0 (2021-11-12)

* Bump version to 0.8.0.

* Remove unneeded imports.

* Rename test dir.

* Apply formatting with black.

* Parse as bytearray instead of BitStream.

* Update copyright year.

* Add requirements.txt.

* Update badge link.

* Update README.


## v0.7.0 (2021-03-10)

* Bump version to 0.7.0.

* Add python_requires to setup.py.

* Remove release script.


## v0.6 (2021-03-06)

* Bump version to 0.6.

* Switch version to string.

* Format setup.py and switch to markdown.

* Update badge URL.


## v0.5 (2020-12-30)

* Bump version to 0.5.

* Apply formatting.

* Rm python 2.x support, README fixes.

* Fix frame_crop_left_offset typo (#5)

* Formatting.

* Import local package for tests.

* Add pypi badge.

* Add missing gitchangelog template.


## v0.4 (2020-04-12)

* Bump version to 0.4.

* Update release script.

* Update readme.

* H26x_extractor: add deeper slice_header parsing (#4)

  Includes:
  * passing the SPS and PPS NALUs to CodedSliceIDR and CodedSliceNonIDR
    (which need them to go further)
  * adding an optional concept of order in the verbose printing, so that
    NALU parameters are printed in the order they are parsed
  * implementing ordering in SPS, PPS, and CodedSliceIDR NALUs
  * fix on the SPS parser based on profile_idc values, per 2016-02
    standard (Section 7.3.2.1.1, page 44). Note in particular that the if
    loop does not include value 144
  * fix minor type (s/slice_gropu_change_rate_minus1/slice_group_change_rate_minus1/)

  Tested:
  ```
  $ h26x-extractor -v file.264
  ...
  SPS (payload size: 21.0 Bytes)
  +--------------------------------------+---------+
  | field                                | value   |
  +======================================+=========+
  | profile_idc                          | 66      |
  +--------------------------------------+---------+
  | constraint_set0_flag                 | 1       |
  +--------------------------------------+---------+
  | constraint_set1_flag                 | 1       |
  +--------------------------------------+---------+
  | constraint_set2_flag                 | 0       |
  +--------------------------------------+---------+
  | constraint_set3_flag                 | 0       |
  +--------------------------------------+---------+
  ...
  NALU type:  5 (Coded slice of an IDR picture)
  NALU bytes: 0x000000016588841afffffc2f14000416fd78e06380de6a1306bb224a722233e54ffa7cb9526c188ed1189699e7c6fd1a2307f757de5c3fca2f3d22b7fc667ccb6ff6b6a8dabb515b59fe53f8a7d83a8beb6ff17988adbfde818bdf2dafc5e7a2b5fde4a0bca4156137f8ceadff19bd5bfe233e152fbefbefbe2fab6dfe...
  NALU RBSP:  0x88841afffffc2f14000416fd78e06380de6a1306bb224a722233e54ffa7cb9526c188ed1189699e7c6fd1a2307f757de5c3fca2f3d22b7fc667ccb6ff6b6a8dabb515b59fe53f8a7d83a8beb6ff17988adbfde818bdf2dafc5e7a2b5fde4a0bca4156137f8ceadff19bd5bfe233e152fbefbefbe2fab6dfed6d62d6ad7...

  CodedSliceIDR (payload size: 4538.0 Bytes)
  +----------------------+---------+
  | field                | value   |
  +======================+=========+
  | first_mb_in_slice    | 0       |
  +----------------------+---------+
  | slice_type           | 7       |
  +----------------------+---------+
  | slice_type_clear     | I       |
  +----------------------+---------+
  | pic_parameter_set_id | 0       |
  +----------------------+---------+
  | frame_num            | 0       |
  +----------------------+---------+
  | idr_pic_id           | 0       |
  ...
  ```

* Fix offset-by-one (#3)

  * h26x-extractor: add a simple parsing test

  Needed to refactor the parser constructor in order to allow testing
  binary blobs.

  Tested:

  Before the AUD fix patch:

  ```
  $ ./tests/simple_parsing.py

  ========================================================================================================

  NALU bytepos: [0, 5]
  NALU offset:  0 Bytes
  NALU length:  6 Bytes (including start code)
  NALU type:  9 (Access unit delimiter)
  NALU bytes: 0x000000010910
  NALU RBSP:

  E
  ======================================================================
  ERROR: testAUDParser (__main__.ParsingTest)
  Simple AUD parsing.
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "./tests/simple_parsing.py", line 17, in testAUDParser
      ex.parse()
    File "/usr/local/lib/python3.7/site-packages/h26x_extractor-0.3-py3.7.egg/h26x_extractor/h26x_parser.py", line 209, in parse
      aud = nalutypes.AUD(rbsp_payload, self.verbose)
    File "/usr/local/lib/python3.7/site-packages/h26x_extractor-0.3-py3.7.egg/h26x_extractor/nalutypes.py", line 120, in __init__
      self.primary_pic_type = self.s.read('uint:3')
    File "/usr/lib/python3.7/site-packages/bitstring.py", line 3902, in read
      value, self._pos = self._readtoken(name, self._pos, length)
    File "/usr/lib/python3.7/site-packages/bitstring.py", line 2016, in _readtoken
      "Tried to read {0} bits when only {1} available.".format(int(length), self.length - pos))
  bitstring.ReadError: Reading off the end of the data. Tried to read 3 bits when only 0 available.

  ----------------------------------------------------------------------
  Ran 1 test in 0.003s

  FAILED (errors=1)
  ```

  After the AUD fix patch:

  ```
  $ ./tests/simple_parsing.py

  ========================================================================================================

  NALU bytepos: [0, 5]
  NALU offset:  0 Bytes
  NALU length:  6 Bytes (including start code)
  NALU type:  9 (Access unit delimiter)
  NALU bytes: 0x000000010910
  NALU RBSP:  0x10

  AUD (payload size: 1.0 Bytes)
  +------------------+---------+
  | field            |   value |
  +==================+=========+
  | primary_pic_type |       0 |
  +------------------+---------+
  .
  ----------------------------------------------------------------------
  Ran 1 test in 0.001s

  OK
  ```

  * h26x_extractor: fix offset-by-1 in NALU parser

  Tested:

  Before the AUD fix patch:

  ```
  $ ./tests/simple_parsing.py

  ========================================================================================================

  NALU bytepos: [0, 5]
  NALU offset:  0 Bytes
  NALU length:  6 Bytes (including start code)
  NALU type:  9 (Access unit delimiter)
  NALU bytes: 0x000000010910
  NALU RBSP:

  E
  ======================================================================
  ERROR: testAUDParser (__main__.ParsingTest)
  Simple AUD parsing.
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "./tests/simple_parsing.py", line 17, in testAUDParser
      ex.parse()
    File "/usr/local/lib/python3.7/site-packages/h26x_extractor-0.3-py3.7.egg/h26x_extractor/h26x_parser.py", line 209, in parse
      aud = nalutypes.AUD(rbsp_payload, self.verbose)
    File "/usr/local/lib/python3.7/site-packages/h26x_extractor-0.3-py3.7.egg/h26x_extractor/nalutypes.py", line 120, in __init__
      self.primary_pic_type = self.s.read('uint:3')
    File "/usr/lib/python3.7/site-packages/bitstring.py", line 3902, in read
      value, self._pos = self._readtoken(name, self._pos, length)
    File "/usr/lib/python3.7/site-packages/bitstring.py", line 2016, in _readtoken
      "Tried to read {0} bits when only {1} available.".format(int(length), self.length - pos))
  bitstring.ReadError: Reading off the end of the data. Tried to read 3 bits when only 0 available.

  ----------------------------------------------------------------------
  Ran 1 test in 0.003s

  FAILED (errors=1)
  ```

  After the AUD fix patch:

  ```
  $ ./tests/simple_parsing.py

  ========================================================================================================

  NALU bytepos: [0, 5]
  NALU offset:  0 Bytes
  NALU length:  6 Bytes (including start code)
  NALU type:  9 (Access unit delimiter)
  NALU bytes: 0x000000010910
  NALU RBSP:  0x10

  AUD (payload size: 1.0 Bytes)
  +------------------+---------+
  | field            |   value |
  +==================+=========+
  | primary_pic_type |       0 |
  +------------------+---------+
  .
  ----------------------------------------------------------------------
  Ran 1 test in 0.001s

  OK
  ```


## v0.3 (2020-03-15)

* Bump version to 0.3.

* Add release script.

* Python 3.7 and 3.8.

* Rename changelog.


## v0.2 (2017-08-02)

* Many updates.


## v0.1 (2017-07-17)

* Initial commit.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/slhck/h26x-extractor",
    "name": "h26x-extractor",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "video,h264",
    "author": "Werner Robitza",
    "author_email": "werner.robitza@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/89/01/e140621eb06f3b9e11c953625bc18e69b59e5d3659cdb6a9c7e2aeb0fdeb/h26x-extractor-0.8.1.tar.gz",
    "platform": null,
    "description": "# h26x-extractor\n\n[![PyPI version](https://img.shields.io/pypi/v/h26x-extractor.svg)](https://pypi.org/project/h26x-extractor)\n\nAuthor: Werner Robitza, with contributions from @chemag, Paulo Sherring.\n\nExtracts NAL units from H.264 bitstreams and decodes their type and content, if supported.\n\n\u26a0\ufe0f `h26x-extractor` is neither fast nor robust to bitstream errors. It's rather a playground for parsing bitstreams. Use with caution! This program is no longer maintained, PRs are welcome.\n\nContents:\n\n- [Installation](#installation)\n- [Status](#status)\n- [Usage](#usage)\n- [Programmatic usage](#programmatic-usage)\n- [Alternatives](#alternatives)\n\n## Installation\n\nRequirements: Python 3.8 or higher\n\nVia pip:\n\n    pip3 install h26x-extractor\n\n## Status\n\nCurrently supported:\n\n- Parsing of H.264 bitstreams\n- Parsing of NALU\n- Parsing of AUD\n- Parsing of CodedSliceIDR\n- Parsing of CodedSliceNonIDR\n- Parsing of SPS\n- Parsing of PPS\n\nCurrently planned:\n\n- Parsing of SEI\n- Parsing of VUI\n- Parsing of H.265 bitstreams\n\n## Usage\n\nIf you installed the program via pip, you can run it directly:\n\n    h26x-extractor [options] <input-file>...\n\nOtherwise you can clone this repo and run it via:\n\n    python3 -m h264_extractor [options] <input-file>...\n\nYou can pass the `-v` flag to enable verbose output, e.g. the following. You will get, for each NAL unit:\n\n- The byte position range\n- The offset from the start of the stream\n- The overall length including start code\n- The type (also translated in plaintext)\n- Its content in raw bytes, encoded as hex\n- Its RBSP content\n- A table with its content decoded, if supported\n\nExample:\n\n    NALU bytepos:   [0, 28]\n    NALU offset:    0 Bytes\n    NALU length:    29 Bytes (including start code)\n    NALU type:      7 (Sequence parameter set)\n    NALU bytes:     0x0000000167f4000d919b28283f6022000003000200000300641e28532c\n    NALU RBSP:      0xf4000d919b28283f602200000002000000641e28532c\n\n    SPS (payload size: 22.0 Bytes)\n    +--------------------------------------+---------+\n    | field                                | value   |\n    +======================================+=========+\n    | constraint_set0_flag                 | 0       |\n    +--------------------------------------+---------+\n    | constraint_set1_flag                 | 0       |\n    +--------------------------------------+---------+\n    ....\n\n## Programmatic usage\n\nYou can also use this library in your code, e.g.:\n\n```python\nfrom h26x_extractor.h26x_parser import H26xParser\n\ndef do_something(bytes):\n    pass\n    # do something with the NALU bytes\n\nH26xParser.set_callback(\"nalu\", do_something)\nH26xParser.parse()\n```\n\nThe callback is called for each type of info found. Valid callbacks are:\n\n- `sps`\n- `pps`\n- `slice`\n- `aud`\n- `nalu`\n\nThe raw data for all callbacks includes the RBSP.\n\nYou can also call the `nalutypes` classes to decode the individual fields, e.g. `nalutypes.SPS`:\n\n```python\nfrom h26x_extractor.h26x_parser import H26xParser\nfrom h26x_extractor.nalutypes import SPS\n\ndef parse_sps(bytes):\n    sps = SPS(bytes)\n    sps.print_verbose()\n\nH26xParser.set_callback(\"sps\", parse_sps)\nH26xParser.parse()\n```\n\n## Alternatives\n\n[h264bitstream](https://github.com/aizvorski/h264bitstream) is a proper H.264 parser.\n\nFFmpeg can also parse bitstream data:\n\n```\nffmpeg -i video.h264 -c copy -bsf:v trace_headers -f null - 2> output.txt\n```\n\n# License\n\nThe MIT License (MIT)\n\nCopyright (c) 2017-2023 Werner Robitza\n\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\n# Changelog\n\n\n## v0.8.1 (2023-01-08)\n\n* Bump version to 0.8.1.\n\n* Organize imports.\n\n* Update module structure, readme.\n\n\n## v0.8.0 (2021-11-12)\n\n* Bump version to 0.8.0.\n\n* Remove unneeded imports.\n\n* Rename test dir.\n\n* Apply formatting with black.\n\n* Parse as bytearray instead of BitStream.\n\n* Update copyright year.\n\n* Add requirements.txt.\n\n* Update badge link.\n\n* Update README.\n\n\n## v0.7.0 (2021-03-10)\n\n* Bump version to 0.7.0.\n\n* Add python_requires to setup.py.\n\n* Remove release script.\n\n\n## v0.6 (2021-03-06)\n\n* Bump version to 0.6.\n\n* Switch version to string.\n\n* Format setup.py and switch to markdown.\n\n* Update badge URL.\n\n\n## v0.5 (2020-12-30)\n\n* Bump version to 0.5.\n\n* Apply formatting.\n\n* Rm python 2.x support, README fixes.\n\n* Fix frame_crop_left_offset typo (#5)\n\n* Formatting.\n\n* Import local package for tests.\n\n* Add pypi badge.\n\n* Add missing gitchangelog template.\n\n\n## v0.4 (2020-04-12)\n\n* Bump version to 0.4.\n\n* Update release script.\n\n* Update readme.\n\n* H26x_extractor: add deeper slice_header parsing (#4)\n\n  Includes:\n  * passing the SPS and PPS NALUs to CodedSliceIDR and CodedSliceNonIDR\n    (which need them to go further)\n  * adding an optional concept of order in the verbose printing, so that\n    NALU parameters are printed in the order they are parsed\n  * implementing ordering in SPS, PPS, and CodedSliceIDR NALUs\n  * fix on the SPS parser based on profile_idc values, per 2016-02\n    standard (Section 7.3.2.1.1, page 44). Note in particular that the if\n    loop does not include value 144\n  * fix minor type (s/slice_gropu_change_rate_minus1/slice_group_change_rate_minus1/)\n\n  Tested:\n  ```\n  $ h26x-extractor -v file.264\n  ...\n  SPS (payload size: 21.0 Bytes)\n  +--------------------------------------+---------+\n  | field                                | value   |\n  +======================================+=========+\n  | profile_idc                          | 66      |\n  +--------------------------------------+---------+\n  | constraint_set0_flag                 | 1       |\n  +--------------------------------------+---------+\n  | constraint_set1_flag                 | 1       |\n  +--------------------------------------+---------+\n  | constraint_set2_flag                 | 0       |\n  +--------------------------------------+---------+\n  | constraint_set3_flag                 | 0       |\n  +--------------------------------------+---------+\n  ...\n  NALU type:  5 (Coded slice of an IDR picture)\n  NALU bytes: 0x000000016588841afffffc2f14000416fd78e06380de6a1306bb224a722233e54ffa7cb9526c188ed1189699e7c6fd1a2307f757de5c3fca2f3d22b7fc667ccb6ff6b6a8dabb515b59fe53f8a7d83a8beb6ff17988adbfde818bdf2dafc5e7a2b5fde4a0bca4156137f8ceadff19bd5bfe233e152fbefbefbe2fab6dfe...\n  NALU RBSP:  0x88841afffffc2f14000416fd78e06380de6a1306bb224a722233e54ffa7cb9526c188ed1189699e7c6fd1a2307f757de5c3fca2f3d22b7fc667ccb6ff6b6a8dabb515b59fe53f8a7d83a8beb6ff17988adbfde818bdf2dafc5e7a2b5fde4a0bca4156137f8ceadff19bd5bfe233e152fbefbefbe2fab6dfed6d62d6ad7...\n\n  CodedSliceIDR (payload size: 4538.0 Bytes)\n  +----------------------+---------+\n  | field                | value   |\n  +======================+=========+\n  | first_mb_in_slice    | 0       |\n  +----------------------+---------+\n  | slice_type           | 7       |\n  +----------------------+---------+\n  | slice_type_clear     | I       |\n  +----------------------+---------+\n  | pic_parameter_set_id | 0       |\n  +----------------------+---------+\n  | frame_num            | 0       |\n  +----------------------+---------+\n  | idr_pic_id           | 0       |\n  ...\n  ```\n\n* Fix offset-by-one (#3)\n\n  * h26x-extractor: add a simple parsing test\n\n  Needed to refactor the parser constructor in order to allow testing\n  binary blobs.\n\n  Tested:\n\n  Before the AUD fix patch:\n\n  ```\n  $ ./tests/simple_parsing.py\n\n  ========================================================================================================\n\n  NALU bytepos: [0, 5]\n  NALU offset:  0 Bytes\n  NALU length:  6 Bytes (including start code)\n  NALU type:  9 (Access unit delimiter)\n  NALU bytes: 0x000000010910\n  NALU RBSP:\n\n  E\n  ======================================================================\n  ERROR: testAUDParser (__main__.ParsingTest)\n  Simple AUD parsing.\n  ----------------------------------------------------------------------\n  Traceback (most recent call last):\n    File \"./tests/simple_parsing.py\", line 17, in testAUDParser\n      ex.parse()\n    File \"/usr/local/lib/python3.7/site-packages/h26x_extractor-0.3-py3.7.egg/h26x_extractor/h26x_parser.py\", line 209, in parse\n      aud = nalutypes.AUD(rbsp_payload, self.verbose)\n    File \"/usr/local/lib/python3.7/site-packages/h26x_extractor-0.3-py3.7.egg/h26x_extractor/nalutypes.py\", line 120, in __init__\n      self.primary_pic_type = self.s.read('uint:3')\n    File \"/usr/lib/python3.7/site-packages/bitstring.py\", line 3902, in read\n      value, self._pos = self._readtoken(name, self._pos, length)\n    File \"/usr/lib/python3.7/site-packages/bitstring.py\", line 2016, in _readtoken\n      \"Tried to read {0} bits when only {1} available.\".format(int(length), self.length - pos))\n  bitstring.ReadError: Reading off the end of the data. Tried to read 3 bits when only 0 available.\n\n  ----------------------------------------------------------------------\n  Ran 1 test in 0.003s\n\n  FAILED (errors=1)\n  ```\n\n  After the AUD fix patch:\n\n  ```\n  $ ./tests/simple_parsing.py\n\n  ========================================================================================================\n\n  NALU bytepos: [0, 5]\n  NALU offset:  0 Bytes\n  NALU length:  6 Bytes (including start code)\n  NALU type:  9 (Access unit delimiter)\n  NALU bytes: 0x000000010910\n  NALU RBSP:  0x10\n\n  AUD (payload size: 1.0 Bytes)\n  +------------------+---------+\n  | field            |   value |\n  +==================+=========+\n  | primary_pic_type |       0 |\n  +------------------+---------+\n  .\n  ----------------------------------------------------------------------\n  Ran 1 test in 0.001s\n\n  OK\n  ```\n\n  * h26x_extractor: fix offset-by-1 in NALU parser\n\n  Tested:\n\n  Before the AUD fix patch:\n\n  ```\n  $ ./tests/simple_parsing.py\n\n  ========================================================================================================\n\n  NALU bytepos: [0, 5]\n  NALU offset:  0 Bytes\n  NALU length:  6 Bytes (including start code)\n  NALU type:  9 (Access unit delimiter)\n  NALU bytes: 0x000000010910\n  NALU RBSP:\n\n  E\n  ======================================================================\n  ERROR: testAUDParser (__main__.ParsingTest)\n  Simple AUD parsing.\n  ----------------------------------------------------------------------\n  Traceback (most recent call last):\n    File \"./tests/simple_parsing.py\", line 17, in testAUDParser\n      ex.parse()\n    File \"/usr/local/lib/python3.7/site-packages/h26x_extractor-0.3-py3.7.egg/h26x_extractor/h26x_parser.py\", line 209, in parse\n      aud = nalutypes.AUD(rbsp_payload, self.verbose)\n    File \"/usr/local/lib/python3.7/site-packages/h26x_extractor-0.3-py3.7.egg/h26x_extractor/nalutypes.py\", line 120, in __init__\n      self.primary_pic_type = self.s.read('uint:3')\n    File \"/usr/lib/python3.7/site-packages/bitstring.py\", line 3902, in read\n      value, self._pos = self._readtoken(name, self._pos, length)\n    File \"/usr/lib/python3.7/site-packages/bitstring.py\", line 2016, in _readtoken\n      \"Tried to read {0} bits when only {1} available.\".format(int(length), self.length - pos))\n  bitstring.ReadError: Reading off the end of the data. Tried to read 3 bits when only 0 available.\n\n  ----------------------------------------------------------------------\n  Ran 1 test in 0.003s\n\n  FAILED (errors=1)\n  ```\n\n  After the AUD fix patch:\n\n  ```\n  $ ./tests/simple_parsing.py\n\n  ========================================================================================================\n\n  NALU bytepos: [0, 5]\n  NALU offset:  0 Bytes\n  NALU length:  6 Bytes (including start code)\n  NALU type:  9 (Access unit delimiter)\n  NALU bytes: 0x000000010910\n  NALU RBSP:  0x10\n\n  AUD (payload size: 1.0 Bytes)\n  +------------------+---------+\n  | field            |   value |\n  +==================+=========+\n  | primary_pic_type |       0 |\n  +------------------+---------+\n  .\n  ----------------------------------------------------------------------\n  Ran 1 test in 0.001s\n\n  OK\n  ```\n\n\n## v0.3 (2020-03-15)\n\n* Bump version to 0.3.\n\n* Add release script.\n\n* Python 3.7 and 3.8.\n\n* Rename changelog.\n\n\n## v0.2 (2017-08-02)\n\n* Many updates.\n\n\n## v0.1 (2017-07-17)\n\n* Initial commit.\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Extract NAL units from H.264 bitstreams",
    "version": "0.8.1",
    "split_keywords": [
        "video",
        "h264"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4e187bd4baf084dba661963422be4ad41922e573a74e4338d315fc53bbd8f96e",
                "md5": "379e12dba6fd291e8518acb4d0b53620",
                "sha256": "cd3f95f3fa12cf71335fb4e7ffd5ede31be46264b3571174581e5834d22b9bb1"
            },
            "downloads": -1,
            "filename": "h26x_extractor-0.8.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "379e12dba6fd291e8518acb4d0b53620",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.8",
            "size": 13813,
            "upload_time": "2023-01-08T15:59:34",
            "upload_time_iso_8601": "2023-01-08T15:59:34.552823Z",
            "url": "https://files.pythonhosted.org/packages/4e/18/7bd4baf084dba661963422be4ad41922e573a74e4338d315fc53bbd8f96e/h26x_extractor-0.8.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8901e140621eb06f3b9e11c953625bc18e69b59e5d3659cdb6a9c7e2aeb0fdeb",
                "md5": "b5640af0cfc38a81d10de8a87893f5fe",
                "sha256": "a4115437494af1c07511d78fa988333069cc12b77c0768397328a101b0044ca0"
            },
            "downloads": -1,
            "filename": "h26x-extractor-0.8.1.tar.gz",
            "has_sig": false,
            "md5_digest": "b5640af0cfc38a81d10de8a87893f5fe",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 15037,
            "upload_time": "2023-01-08T15:59:36",
            "upload_time_iso_8601": "2023-01-08T15:59:36.670848Z",
            "url": "https://files.pythonhosted.org/packages/89/01/e140621eb06f3b9e11c953625bc18e69b59e5d3659cdb6a9c7e2aeb0fdeb/h26x-extractor-0.8.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-08 15:59:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "slhck",
    "github_project": "h26x-extractor",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "h26x-extractor"
}
        
Elapsed time: 0.02660s