dholroyd / h264-reader

Rust reader for H264 bitsream syntax
Apache License 2.0
73 stars 25 forks source link

[Q] Install for those not familiar with Rust #37

Closed bbgdzxng1 closed 1 year ago

bbgdzxng1 commented 2 years ago

Firstly, thanks for putting together a tool that can dig-deep into H.264 SEI data. I'm excited to have a potential tool that can view at least the headers in the SEI ITU-T-T35 data, since tools such as fq, as great as they are, doesn't navigate the ITU-T-T35 headers, whereas h264-reader looks like it can dig in a little deeper. h264bitstream does not seem to dig down to the SEI.

However, do you have a quick couple-of-liner quickstart for h264-reader for those less familiar with rust packages vs binaries?

$ brew install rust                           # Using macOS brew to install rust/cargo
$ cargo list                                  # Test cargo
$ cargo version                               # Test cargo
$ cargo install h264-reader                   # This seems to download the crate

error: there is nothing to install in `h264-reader v0.6.0`, because it has no binaries
`cargo install` is only for installing programs, and can't be used with libraries.
To use a library crate, add it as a dependency in a Cargo project instead.

I'm guessing that in order to use h264-reader, I need to start a rust project and use the library etc. This is all fine for developers, but rust is a little out of my skillset.

My goal is to pass infile.264 to h264-reader by issuing commands at a terminal

$ h264-reader-app infile.264 -stdout 

Or ideally pipe the raw stream out of FFmpeg to h264-reader.

$ ffmpeg -i infile.ts -map 0:v:0 -codec:v copy -f h264 pipe:1 | h264-reader-app - -stdout 

How would a user (not developer) go about using the tool in a terminal? Is it necessary to start a project and wrap that up into an app, or is there a simple way for a user to expose the h264-reader library as a command-line tool or library?

Once again, thanks for putting together the SEI-parser side of things. fq is pretty good, but it doesn't get down into the ITU-T-35. h264-reader looks promising.

I appreciate that this is more of a rust question rather than a h264-reader question, but a quickstart in the README.md would be super helpful for non-rust-types.

dholroyd commented 2 years ago

Hi! What would you like to be able to achieve - what would the tool output?

For example, I know that 608/708 caption data is stored in these headers, but we don't have a parser (and I recall the format is fairly complex).

bbgdzxng1 commented 2 years ago

I would like to be able to dig down into the SEI data and, in a perfect world, be able to see the caption payload for a video frame (not necessarily a decode, just headers to see what is in there).

By my interpretation of the DTVCC spec, the first stage would be to decode the T.35 header, which is really a standard for country codes, but is used by ATSC A/53 to declare that the payload is ATSC A/53 DTVCC caption data. The A/53 data is a more complex format, and the digital captions are usually EIA-708 with CEA-608 compatibility bits, or just CEA-608 compatibility mode. As you say, the 608/708 is a bit of a complex format - and there are other tools such as ccextractor (partly already ported to rust) that can decode 608/708.

Where ccextractor is a fine caption decoder, it is not a header parser and tends to abstract the headers from the user.

So my assumption was that in the same way that h264-parser is not H.264 decoder, neither should it be a 608/708 caption decoder, but there is a middle ground where decoding the headers would be useful for a parser/analyser tool. Decoding of the T.35 header would be the next level down from the current functionality.

The tools that are out there for parsing or decoding SEI or 608/708 captions are:

It feels like header parsing falls into the domain of h264-parser, but that is a hypothetical statement because I'm a little bit too stupid to be able to work out how to use h264-parser without learning rust.

My questions are really one of: a) how could I install/use the library without first learning how to program in rust. As you can see from the above, I have tried the obvious. b) would you consider adding T.35 header decode, so users could dig one level deeper than current?

The tool looks really cool, BTW - Thanks! If only I was not so stupid that I have not understood how to get going with it.