Extract NAL units from H.264 bitstreams
Project description
h26x-extractor
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!
Installation
Python 2.7:
pip install h26x-extractor
Python 3.x:
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
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
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.:
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:
sps
pps
slice
aud
nalu
Raw data for all callbacks includes the RBSP.
You can also call the nalutypes classes to decode the individual fields, e.g. nalutypes.SPS.
License
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.
Changelog
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>`__.
Unreleased
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>`__
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for h26x_extractor-0.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf72d62746a3f7504a45f3f46c0c872b7bedb8e95b6c94674991b17d99007142 |
|
MD5 | 7f76e3408c1e9cd1f9071a5e6c5322bf |
|
BLAKE2b-256 | fd5f082050ce66e409ff085bb065ec37962b5f224ad703ccf7a069a79235a20e |