diff --git a/revid/revid.go b/revid/revid.go index dea2183b..168b6808 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -178,7 +178,7 @@ func readWriteVideo(input string, output string) error { } } - if *flags&(filterDropAudio) == 0 { + if *flags&filterDropAudio == 0 { audioArg[0] = "-acodec" audioArg[1] = "copy" } else { @@ -306,9 +306,8 @@ func sendClipToHTTP(clip []byte, output string, _ net.Conn) error { func sendClipToUDP(clip []byte, _ string, conn net.Conn) error { size := UDPPackets * mp2tPacketSize fmt.Printf("Sending %d UDP packets of size %d (%d bytes)\n", len(clip)/size, size, len(clip)) - pkt := make([]byte, size) for offset := 0; offset < len(clip); offset += size { - copy(pkt, clip[offset:offset+size]) + pkt := clip[offset : offset+size] _, err := conn.Write(pkt) if err != nil { fmt.Printf("UDP write error %s. Is your player listening?\n", err) @@ -346,12 +345,11 @@ func sendClipToStdout(clip []byte, _ string, _ net.Conn) error { packetCount := 0 discontinuities := 0 - pkt := make([]byte, mp2tPacketSize) var cc int for offset := 0; offset < len(clip); offset += mp2tPacketSize { packetCount++ - copy(pkt, clip[offset:offset+mp2tPacketSize]) + pkt := clip[offset : offset+mp2tPacketSize] pktPid, err := packet.Pid(pkt) if err != nil { @@ -364,7 +362,7 @@ func sendClipToStdout(clip []byte, _ string, _ net.Conn) error { if *flags&(dumpPacketHeader|dumpPacketPayload) != 0 { fmt.Printf("Packet #%d.%d\n", clipCount, packetCount) } - + hasPayload := pkt[3]&0x10 != 0 if !hasPayload { continue // nothing to do @@ -419,6 +417,7 @@ func sendClipToStdout(clip []byte, _ string, _ net.Conn) error { // mp2tDumpProgram dumps MPEG-TS Program Association Table (PAT) and Program Map Tables (PMT). func mp2tDumpProgram(clip []byte) error { + // NB: Comcast API requires a buffered reader reader := bufio.NewReader(bytes.NewReader(clip)) _, err := packet.Sync(reader) @@ -505,7 +504,7 @@ func mp2tGetPcr(pkt []byte) (uint64, uint32, bool) { } // RTPEncapsulate encapsulates MPEG-TS packets within an RTP header, -// setting the payload type accordingly and incrementing the RTP sequence number. +// setting the payload type accordingly (to 33) and incrementing the RTP sequence number. func RTPEncapsulate(mp2tPacket []byte, pkt []byte) { // RTP packet encapsulates the MP2T // first 12 bytes is the header