Comments (8)
This library will go as far as retrieving H.264 and AAC packets from your stream but it won't decode packets. Decoding packets is a whole other world and it's not the purpose of this transport stream oriented library.
In order to retrieve packets, you would have to do something along the lines of :
// TODO Connect to your TCP socket
var conn *net.TCPConn
// Create the demuxer
dmx := astits.New(context.Background(), conn)
for {
// Get the next data
d, _ := dmx.NextData()
// TODO You can determine the streams in your TS container using PMT data
if d.PMT != nil {
// Loop through elementary streams
for _, es := range d.PMT.ElementaryStreams {
fmt.Printf("Stream detected: %d\n", es.ElementaryPID)
}
} else if d.PES != nil {
// TOD Your H.264 or AAC packets are in the d.PES.Data attributes
}
}
Regarding decoding packets, I would urge you to use ffmpeg even though it requires to install ffmpeg
C bindings and use CGO.
from go-astits.
Hello,
Thank you for your answer, ok so atleast if I can have the H264 & the AAC easily from sockets that seems good. I will see to decode H264 myself then.
I tried your code but I get a panic: runtime error: invalid memory address or nil pointer dereference
in that line if d.PMT != nil
Here is the idea, I'm streaming the screen of my Android phone and encoding it in MPEG2TS as I said then I send packets in real time to a golang server socket.
I did a test just to be sure that data received are corrected by recording appending every packets in a file eg: video.ts. When I play the file using VLC it's correct, I have a good stream.
Now I want to retrieve H264 & AAC with your library but I get this error.
Could you tell me if there is something I can do for debugging that ?
EDIT:
I just printed the err
of NextData()
method and I have : astits: fetching next packet failed: astits: creating packet buffer failed: astits: auto detecting packet size failed: astits: packet must start with a sync byte
Thank you very much
from go-astits.
Could you share your video.ts
file so that I reproduce the problem locally ?
from go-astits.
You have a sample
data.zip
from go-astits.
Hello,
any news ?
from go-astits.
It seems your file is corrupted, as if bytes were missing. Right now this library can't recover if the file is not a valid transport stream.
FYI when running ffprobe
I get lots of PES packet size mismatch
which is not good news.
Therefore, my guess is that the connection is having problems retrieving all data.
from go-astits.
Through socket, maybe I have some loss data but the file that I sent to you have been created on the socket reception in Golang. I just append the data when I get it. What is the solution ? This case could happen I think if it's from socket connection
from go-astits.
There are 2 solutions :
- make sure not to get any loss data (practicly impossible)
- implement a recover logic in this library
Unfortunately I won't have time to work on the recover logic anytime soon, but I'm welcoming PRs.
from go-astits.
Related Issues (20)
- Add a muxer HOT 13
- Question about astikit HOT 1
- Incorrect PTS calculation on 32 bit platforms HOT 2
- Q: aac and h264 codecs HOT 5
- Logging HOT 4
- update the README to indicate the new exciting muxer feature HOT 1
- demuxer.NextData not returning PAT/PMT when seen HOT 9
- demuxer fails to parse complex PMT with multiple tables
- demuxer.NextData returns (nil, nil) on unknown data types HOT 1
- demuxer fails when corrupted PES packet advertises incorrect length HOT 2
- how to use the demuxer to extract audio/aac stream into a aac file ? HOT 1
- Implement ATSC standard as well HOT 8
- split into files
- muxer fail then panic "writePacket: can't write 185 bytes of payload: only 184 is available... " on muxer.WriteData(&astits.MuxerData{ ... HOT 1
- Latest version (v1.11.0) is vulnerable to multiple DoS attacks HOT 1
- [Question] Realtime muxer HOT 4
- How to get started with go-astits...
- Getting started with go-astits
- Mux 7-packets alignment HOT 2
- [Question]: no PMT in DemuxerData of mpetgs over udp HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-astits.