asticode / go-astits

Demux and mux MPEG Transport Streams (.ts) natively in GO

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add a muxer

sjpotter opened this issue · comments

i.e. I might want to read in a stream, modify it and output the stream.

In fact, I did just that in a project I'm working on where I take the m2ts stream from libbluray, and add in language descriptors (from the buray clipinfo) and then serialize it out.

you're definitely right, it would mean adding a muxer.

if you feel like contributing, I'm welcoming PRs

you could use https://github.com/nareix/joy4/tree/master/format/ts, since it is not maintained, it would be nice to have some up-to-date library..even if it is only for ts.

I'm currently doing some preliminary research to make a TS muxer to mux small TS files into 1 big TS file. Anyone else working on this or might I be the one to issue a PR?

I don't think anybody is working on this, go for it! ❤️

Try to reuse as much code as possible in this lib, create the least amount of new .go files and export the simplest and smallest API would be my points of emphasis.

I'm playing with sample-aes encrypted hls streams that I'd like to demux, decode and remux. If this package were to offer a muxer, it would really make it close to complete. I understand nobody's really working on it at this moment and I'm afraid my TS knowledge is too limited but contribute but if maybe if a few of us work together we can get something working decently rapidely.

Sorry I completely forgot about this. I'm probably not going to be working this until I get settled into my new job.

I'm playing with sample-aes encrypted hls streams that I'd like to demux, decode and remux. If this package were to offer a muxer, it would really make it close to complete.

Well you can do this now. You got to handle decoding yourself though. But it's not hard since go std lib offers good crypto API. Just be aware of PKCS7 padding, that one costed me a bunch of grey hairs :)

@barbashov care to share more? I'm not too worried about the crypto (if I understand what data needs to be decoded) but I'm not sure how to rebuild the stream without a muxer.

@barbashov care to share more? I'm not too worried about the crypto (if I understand what data needs to be decoded) but I'm not sure how to rebuild the stream without a muxer.

I've written a muxer :) It's under review currently, but already useful #16

@asticode you may want to close that one as well

Thanks to @barbashov 's great work, this lib now has a muxer ❤️

Closing this issue

I'm playing with sample-aes encrypted hls streams that I'd like to demux, decode and remux. If this package were to offer a muxer, it would really make it close to complete.

Well you can do this now. You got to handle decoding yourself though. But it's not hard since go std lib offers good crypto API. Just be aware of PKCS7 padding, that one costed me a bunch of grey hairs :)

Thanks @barbashov , I wrote the aes-128 crypto (CBC/PKCS7) code needed to decode the entire files but sample-aes is a bit more tricky since it requires also understanding the transport protocol (only only part of the data is encrypted).

My understanding is that I need to do something similar to your what you have here:
https://github.com/asticode/go-astits/blob/master/cmd/astits-es-split/main.go#L107

That would give me access to the partially encrypted data, then decrypt the data and remux the file by adding the decrypted PES to the new stream. Does that seem right or do I need to copy/add more data to my decrypted stream?

I'm playing with sample-aes encrypted hls streams that I'd like to demux, decode and remux. If this package were to offer a muxer, it would really make it close to complete.

Well you can do this now. You got to handle decoding yourself though. But it's not hard since go std lib offers good crypto API. Just be aware of PKCS7 padding, that one costed me a bunch of grey hairs :)

Thanks @barbashov , I wrote the aes-128 crypto (CBC/PKCS7) code needed to decode the entire files but sample-aes is a bit more tricky since it requires also understanding the transport protocol (only only part of the data is encrypted).

My understanding is that I need to do something similar to your what you have here:
https://github.com/asticode/go-astits/blob/master/cmd/astits-es-split/main.go#L107

That would give me access to the partially encrypted data, then decrypt the data and remux the file by adding the decrypted PES to the new stream. Does that seem right or do I need to copy/add more data to my decrypted stream?

I don't really know how to help you since I haven't implemented SAMPLE-AES at this point in my software.
Though as far as i know, SAMPLE-AES doesn't encrypt the whole packet, it encrypts just the payload. If that's right, what you need to do is to decrypt only the payload. Anyway, I would follow HLS RFC here.