Extract NAL units from H.264 bitstreams
Author: Werner Robitza
Extracts NAL units from H.264 bitstreams and decodes their type and content, if supported.
Note: This is not a replacement for a proper tool like h264bitstream. h26x-extractor is not fast and not robust, but rather a playground for parsing bitstreams. Use with caution!
pip install h26x-extractor
pip3 install h26x-extractor
- Parsing of H.264 bitstreams
- Parsing of NALU
- Parsing of AUD
- Parsing of CodedSliceIDR
- Parsing of CodedSliceNonIDR
- Parsing of SPS
- Parsing of PPS
- Parsing of SEI
- Parsing of VUI
- Parsing of H.265 bitstreams
h26x-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 bye 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
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 | +--------------------------------------+---------+ ....
You can also use this library in your code, e.g.:
from h26x_extractor.h26x_parser import H26xParser H26xParser.set_callback("nalu", do_something) H26xParser.parse() def do_something(bytes): # do something with the NALU bytes
Valid callbacks are:
Raw data for all callbacks includes the RBSP.
You can also call the nalutypes classes to decode the individual fields, e.g. nalutypes.SPS.
The MIT License (MIT)
Copyright (c) 2017 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.
All notable changes to this project will be documented in this file. Dates are displayed in UTC.
Generated by `auto-changelog <https://github.com/CookPete/auto-changelog>`__.
- many updates `b839642 <https://github.com/slhck/h26x-extractor/commit/b8396422d559aa83b680bb159ca21d82f76a093d>`__
- initial commit `8e89e56 <https://github.com/slhck/h26x-extractor/commit/8e89e563a0ea5ec7059b6f64c13a8d2b5339e801>`__
- add release script `feddde6 <https://github.com/slhck/h26x-extractor/commit/feddde646ac5758a9708670671debd49a7658366>`__
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size h26x_extractor-0.3-py2.py3-none-any.whl (11.1 kB)||File type Wheel||Python version py2.py3||Upload date||Hashes View|
|Filename, size h26x-extractor-0.3.tar.gz (10.9 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for h26x_extractor-0.3-py2.py3-none-any.whl