All Projects → DaWelter → h264decoder

DaWelter / h264decoder

Licence: other
h264 decoding module for python based on libav

Programming Languages

C++
36643 projects - #6 most used programming language
python
139335 projects - #7 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to h264decoder

Wxinlineplayer
🤟Super fast H.264/H.265 FLV player
Stars: ✭ 873 (+1048.68%)
Mutual labels:  h264, decoder
ffmpeg-h264-dec
H.264 decoder extracted from FFmpeg.
Stars: ✭ 81 (+6.58%)
Mutual labels:  h264, decoder
tinyh264
A tiny WASM h.264 decoder, for node and browser
Stars: ✭ 139 (+82.89%)
Mutual labels:  h264, decoder
Ffmediatoolkit
FFMediaToolkit is a cross-platform video decoder/encoder library for .NET that uses FFmpeg native libraries. It supports video frames extraction, reading stream metadata and creating videos from bitmaps in any format supported by FFmpeg.
Stars: ✭ 156 (+105.26%)
Mutual labels:  h264, decoder
demuxer
A tool for demux ts/mp4/flv by typescript. Support HEVC/AVC/AAC codec
Stars: ✭ 108 (+42.11%)
Mutual labels:  h264
screp
StarCraft - Brood War replay parser
Stars: ✭ 71 (-6.58%)
Mutual labels:  decoder
VideoCodecKit
iOS macOS 编解码库 脱离ffmpeg等外部依赖 支持H.264 H.265裸流播放 硬件编解码 rtmp推流等
Stars: ✭ 78 (+2.63%)
Mutual labels:  h264
mini
OpenSource Mini IP camera streamer
Stars: ✭ 64 (-15.79%)
Mutual labels:  h264
greenpass-covid19-qrcode-decoder
An easy tool for decoding Green Pass Covid-19 QrCode
Stars: ✭ 64 (-15.79%)
Mutual labels:  decoder
python-embedded-example-project
This is an example project using mebedded python in C++ console application using CMake
Stars: ✭ 32 (-57.89%)
Mutual labels:  pybind11
logfmt
Package logfmt marshals and unmarshals logfmt messages.
Stars: ✭ 156 (+105.26%)
Mutual labels:  decoder
netease-music-cache-decoder
The decoder for netease music to convert cache file to origin mp3.
Stars: ✭ 41 (-46.05%)
Mutual labels:  decoder
CTF-CryptoTool
CTF-CryptoTool is a tool written in python, for breaking crypto text of CTF challenges. It tries to decode the cipher by bruteforcing it with all known cipher decoding methods easily. Also works for the cipher which does not have a key.
Stars: ✭ 38 (-50%)
Mutual labels:  decoder
sms
A Go library for encoding and decoding SMSs
Stars: ✭ 37 (-51.32%)
Mutual labels:  decoder
QRCode-Decoder
An iOS QRCode Scanner and Decoder
Stars: ✭ 17 (-77.63%)
Mutual labels:  decoder
fevh264
baseline h.264 encoder
Stars: ✭ 18 (-76.32%)
Mutual labels:  h264
pybind11-stubgen
Generates stubs for python modules (targeted to C++ extensions compiled with pybind11)
Stars: ✭ 103 (+35.53%)
Mutual labels:  pybind11
mpq
Decoder/parser of Blizzard's MPQ archive file format
Stars: ✭ 28 (-63.16%)
Mutual labels:  decoder
urlpack
Pure JavaScript toolkit for data URLs (MessagePack, Base58 and Base62)
Stars: ✭ 51 (-32.89%)
Mutual labels:  decoder
binstruct
Golang binary decoder for mapping data into the structure
Stars: ✭ 67 (-11.84%)
Mutual labels:  decoder

H264 Decoder Python Module

The aim of this project is to provide a simple decoder for video captured by a Raspberry Pi camera. At the time of this writing I only need H264 decoding, since a H264 stream is what the RPi software delivers. Furthermore flexibility to incorporate the decoder in larger python programs in various ways is desirable.

The code might also serve as example for libav and pybind11 usage.

Examples

You can do something like this

import h264decoder
import numpy as np

f = open(thefile, 'rb')
decoder = h264decoder.H264Decoder()
while 1:
  data_in = f.read(1024)
  if not data_in:
    break
  framedatas = decoder.decode(data_in)
  for framedata in framedatas:
    (frame, w, h, ls) = framedata
    if frame is not None:
        #print('frame size %i bytes, w %i, h %i, linesize %i' % (len(frame), w, h, ls))
        frame = np.frombuffer(frame, dtype=np.ubyte, count=len(frame))
        frame = frame.reshape((h, ls//3, 3))
        frame = frame[:,:w,:]
        # At this point `frame` references your usual height x width x rgb channels numpy array of unsigned bytes.

There are simple demo programs in the examples folder. display_frames.py is probably the one you want to take a look at.

Requirements

  • Python 3
  • cmake for building
  • libav / ffmpeg (swscale, avutil and avcodec)
  • pybind11 (will be automatically downloaded from github if not found)

For the example scripts

  • matplotlib
  • numpy

I tested it on

  • Ubuntu 18, gcc 9, Anaconda environment with Python 3.7, Libav from Ubuntu repo.
  • Windows 10, Visual Studio Community 2017, Anaconda environment with Python 3.7, FFMPEG from vcpkg.

Building and Installing

Windows

The suggested way to obtain ffmpeg is through vcpkg. Assuming all the setup including VC integration has been done, we can install the x64 libraries with

vcpkg.exe install ffmpeg:x64-windows

We can build the extension module with setuptools almost normally. However cmake is used internally and we have to let it know the search paths to our libs. Hence the additional --cmake-args argument with the toolchain file as per vcpkg instructions.

python setup.py build_ext --cmake-args="-DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake"
pip install -e .

The -e option installs symlinks to the build directory. Useful for development. Leave it out otherwise.


Alternatively one can build the extension module manually with cmake. From the project directory:

mkdir [build dir name]
cd [build dir name]
cmake -DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake -A x64 ..
cmake --build .

Linux

Should be a matter of installing the libav or ffmpeg libraries. On Debian or Ubuntu:

sudo apt install libswscale-dev libavcodec-dev libavutil-dev

And then running

pip install .

in the project directory.

History

v2

For Python 3. Switch to PyBind11. Module renamed from libh264decoder to h264decoder! Support installation via setuptools.

v1

For Python 2.7. Depends on Boost Python. Project/Build file generation with CMake.

Credits

License

The code is published under the Mozilla Public License v. 2.0.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].