Giter VIP home page Giter VIP logo

pgsplusplus's Introduction

iAmSomeone2

Pgs++

A C++ library for reading Presentation Graphics Stream (PGS) subtitles.

Check out the documentation here.

Table of Contents

How to Build

Dependencies

Library

Library tests

Build

  • Navigate to project directory.
  • Make a build directory and change directory into it.
    • mkdir build
    • cd build

Library only

cmake -DCMAKE_BUILD_TYPE=Release ..
make

Library with tests

cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=on ..
make

A note about the tests

The library tests rely on having 2 valid, binary PGS files in the ./test/res directory. One should be named subs.sup, and the other should be named subs_short.sup. As the names imply, subs_short.sup is an abbreviated version of subs.sup.

Acquiring test data

Getting valid PGS data requires having a legally-obtained copy of a Blu-ray disc ripped to your computer storage. You can use MakeMKV to create an MKV file containing any part of the Blu-ray data you want including the subtitles (as PGS data streams). To make the rest of the process easier, it's best to select only one subtitle stream.

After MakeMKV has finished processing the file, you can use FFmpeg to exract the subtitle stream into its own file.

For example:

ffmpeg -i '<extracted_file>.mkv' -vn -an -c:s copy '<subtitle_file>.sup'

Copy or move the extracted file to the project's ./test/res/ directory and rename it to subs.sup.

From here, you may either make a copy of subs.sup and name it subs_short.sup or use a hex editor to create a shorter version of the file that is properly formatted. The main consideration to keep in mind is that the library currently expects proper formatting for the end of the file.

The end of any PGS stream or section will be denoted as such:

Magic Number (2 bytes) Decode timestamp (4 bytes) Presentation timestamp (4 bytes) Segment type flag (1 byte) Segment Size (2 bytes)
"PG" 32-bit value 32-bit value 0x80 (END flag) 0x00 0x00

It is best to seek to between 2-3 megabytes into the file, find the closest END section as described above, and remove all data after the END section.

Save this new file as <project_dir>/test/res/subs_short.sup.

Generate Packages

Pgs++ can be packed for various OSes to make system and project integration easier.

RPM

Currently, Pgs++ has support for building native RPM packages on any architecture provided it has the following packages along with the minimum requirements listed here:

  • rpm-build
  • rpmlint
  • python
  • coreutils
  • diffutils
  • patch
  • rpmdevtools

To install all base requirements on Fedora, CentOS 8, and RedHat Enterprise Linux 8, use the following command:

dnf install gcc cmake rpm-build rpm-devel rpmlint python bash coreutils diffutils patch rpmdevtools

Configuration

Pgs++ uses CMake to generate an RPM SPEC file based on the template located in <project_dir>/dist/redhat. To have CMake generate the file, simply create a fresh build directory or use one configured for a release build, enter it, and run CMake from there.

Example:

mkdir build-rpm && cd build-rpm
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=off -DEXPORT_HEADERS=on ..

or

cd build-release
cmake ..

At this point a new SPEC file will have been created at <project_dir>/dist/redhat/pgs++.spec. Take note of this location for the next step.

Packaging

If you have not created RPM packages before, use the following command to generate the required directories in your HOME directory:

rpmdev-setuptree

From here, either copy the generated SPEC file from the previous step to $HOME/rpmbuild/SPECS/ or create a symlink in the same directory.

Open a terminal in $HOME/rpmbuild/SPECS/ and enter the following command to download the required sources to $HOME/rpmbuild/SOURCES/:

spectool -g -R pgs++.spec

Next, run the following command to build the code and generate the RPM packages:

rpmbuild -bb pgs++.spec

If the command is successful, a freshly-generated set of Pgs++ packages will be waiting at $HOME/rpmbuild/RPMS/

pgsplusplus's People

Contributors

iamsomeone2 avatar

Watchers

 avatar  avatar

pgsplusplus's Issues

Create Debian packaging scripts for DEB packaging

Handmade Debian packaging files will make using the library on DEB-based systems significantly easier for the end-user.

The 'base' package file will contain the binary shared lib, the AUTHORS file and the LICENSE file.

The 'dev' package file will list 'base' as a dependency and contain the C++ headers.

Create RPM SPEC files for 'base' and 'devel' packages.

Handmade SPEC files will make using the library on RPM-based systems significantly easier for the end-user.

The 'base' spec file will contain the binary shared lib, the AUTHORS file and the LICENSE file.

The 'devel' spec file will list 'base' as a dependency and contain the C++ headers.

Fix CMake module configuration

While the CMake module does install as part of the development package, it does not export the include directory or library install path.

Add MKV support

Most PGS data will be embedded as streams in MKV files. Adding the ability to open MKV files and extract PGS streams would enhance usability by removing the need for the end-user to extract the data themselves.

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.