Coder Social home page Coder Social logo

Comments (8)

asticode avatar asticode commented on September 28, 2024

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.

AhmedX6 avatar AhmedX6 commented on September 28, 2024

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.

asticode avatar asticode commented on September 28, 2024

Could you share your video.ts file so that I reproduce the problem locally ?

from go-astits.

AhmedX6 avatar AhmedX6 commented on September 28, 2024

You have a sample
data.zip

from go-astits.

AhmedX6 avatar AhmedX6 commented on September 28, 2024

Hello,

any news ?

from go-astits.

asticode avatar asticode commented on September 28, 2024

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.

AhmedX6 avatar AhmedX6 commented on September 28, 2024

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.

asticode avatar asticode commented on September 28, 2024

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)

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.