Package for Extracting Header details of Video Streaming

Hi Team,
I need to get Header details of Video from sample video file.Is there any package available for this? I have found PESHeader method in the below URL.(That is for PES alone).Is there any way to get generic header details?

Thanks,
Rajapandian.B

Maybe this contains something useful: https://github.com/avelino/awesome-go/blob/master/README.md#video

Thanks Lutzhorn

I am able to get header sync byte(0X47) details only.But i need to get complete header details 0X471fff17.I didn’t find any method for reading header details.Is there any other methods available to achieve this?

Can you provide some minimal code and perhaps a short video which reproduces your problem or explains it better?

From your comment it just looks as if you were only considering a single byte where you need many…

package main

import (“fmt”
“os”
github.com/Comcast/gots/packet
)

func main() {
pidSet := make(map[uint16]bool, 5) //Create an empty map[KeyType]ValueType with a capacity of 5 pairs
filename := “C:/Users/PTS.ts”

file, err := os.Open(filename)
if err == nil {
pkt := make([]byte, packet.PacketSize)// Create empty dynamic array of packetsize
	for read, err := file.Read(pkt); read > 0 && err == nil; read, err = file.Read(pkt) {
                    if err != nil {
                            println(err)
                            return
                    }
		pid, err := packet.Pid(pkt)
		if err != nil {
			println(err)
			continue
		}
		pidSet[pid] = true
	}


for v := range pidSet {
fmt.Printf(“Found pid %d\n”, v)
}
} else {
fmt.Printf(“Unable to open file [%s] due to [%s]\n”, filename, err.Error())
}
}

I am able to get sync byte using pkt(0)

pkt[0] you mean? If so, the remaining bytes will probably in pkt[1], pkt[2], and pkt[3].

Also the first if err != nil {…} in the reading loop, will never fire, as you do only enter the body of the loop when err == nil.

And could you please do me a favor and use proper markdown to format your code? You have plenty of opportunities to do so:

  1. Write code, select it and click the </> button in the editors toolbar,
  2. Indent all code by additional 4 spaces,
  3. or Use fenced codeblocks by denoting the start of the code by a line containing at least three backticks (`) or tildes (~) followed by an optional language name and then a newline while ending the code block with a line containing only the same numbers of backticks/tildes and a newline.
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.