remuxer example
Opened this issue · 7 comments
Is it possible to have an example that takes every element of the ts muxer and then writes it down to a file element by element?
I'm trying to figure out how to get the data alongside with its parsing and I fail to figure out how to do it by reading the examples.
Yes, the examples are bit lacking.
What level of detail would you like to see specifically?
Since you mention remux, there am old example of remuxing mpegts to mp4 over at dholroyd/lowly/src/mpegts/h264.rs. The code is not very good - only supports a fixed audio/video setup, but does this demonstrate some of the library functionality that you would like to see added to an example?
Maybe a great example would be taking in a ts and convert it to a cbr one or the leanest vbr one by adding/removing the stuffing?
I see - you should know that this codebase doesn't currently have any support for multipliexing / writing mpegts - there's more than just examples missing there! I've been tempted to add multiplexing in the past, but it's both harder than demux and something I've not needed as often as demux.
It would be easy enough to write an example that drops packets with pid=0x1fff, but it sounds like you are looking for more than this?
As example that's exactly what you want :)
In a case you read everything, if you find stuffing do not write the packet, otherwise write down what you just read, in the other you read everything and write it down and every time you see a PCR you check if you wrote enough data, otherwise you add more stuffing.
A muxer that pairs well with this crate would be great in general, but not required for the examples I had in mind.
There's a first pass example of stripping stuffing packets in #30.
Because this uses the existing demuxer infra rather than simply iterating packets, in addition to dropping stuffing it also has the effect of,
- dropping packets with
transport_error_indicator
set - the demultiplexer simply discards these - dropping packets with
transport_scrambling_control
- there's no descrambling support in the code (I've not looked into how scrambling works), so it conservatively drops these packets rater than passing the application bad data. This doesn't really make sense for a tool that's just stripping stuffing, so at some point it would be good to fix this.
Thank you, I was away and I just read the code :)