Giter Club home page Giter Club logo

x264-go's Introduction

x264-go

Build Status GoDoc Go Report Card

x264-go provides H.264/MPEG-4 AVC codec encoder based on x264 library.

C source code is included in package. If you want to use external shared/static library (i.e. built with asm and/or OpenCL) use -tags extlib

Installation

go get -u github.com/gen2brain/x264-go

Build tags

  • extlib - use external x264 library
  • pkgconfig - enable pkg-config (used with extlib)

Examples

See screengrab example.

Usage

package main

import (
	"bytes"
	"image"
	"image/color"
	"image/draw"

	"github.com/gen2brain/x264-go"
)

func main() {
	buf := bytes.NewBuffer(make([]byte, 0))

	opts := &x264.Options{
		Width:     640,
		Height:    480,
		FrameRate: 25,
		Tune:      "zerolatency",
		Preset:    "veryfast",
		Profile:   "baseline",
		LogLevel:  x264.LogDebug,
	}

	enc, err := x264.NewEncoder(buf, opts)
	if err != nil {
		panic(err)
	}

	img := x264.NewYCbCr(image.Rect(0, 0, opts.Width, opts.Height))
	draw.Draw(img, img.Bounds(), image.Black, image.ZP, draw.Src)

	for i := 0; i < opts.Width/2; i++ {
		img.Set(i, opts.Height/2, color.RGBA{255, 0, 0, 255})

		err = enc.Encode(img)
		if err != nil {
			panic(err)
		}
	}

	err = enc.Flush()
	if err != nil {
		panic(err)
	}

	err = enc.Close()
	if err != nil {
		panic(err)
	}
}

More

For AAC encoder see aac-go.

x264-go's People

Contributors

gen2brain avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

x264-go's Issues

Unable to get package

Hello developer,

I cannot get the package, it's my mistakes?

go mod report:

go: finding module for package github.com/gen2brain/x264-go
go: found github.com/gen2brain/x264-go in github.com/gen2brain/x264-go v0.2.2
go: downloading github.com/gen2brain/x264-go/yuv v0.0.0-00010101000000-000000000000
go: downloading github.com/gen2brain/x264-go/x264c v0.0.0-00010101000000-000000000000
github.com/EbitenPot/screenpot/app imports
	github.com/gen2brain/x264-go imports
	github.com/gen2brain/x264-go/x264c: github.com/gen2brain/x264-go/[email protected]: invalid version: unknown revision 000000000000
github.com/EbitenPot/screenpot/app imports
	github.com/gen2brain/x264-go imports
	github.com/gen2brain/x264-go/yuv: github.com/gen2brain/x264-go/[email protected]: invalid version: unknown revision 000000000000

Gen

What approach did you use to wrap the c code ?

C for go is one I know but really curious how you approached it

pointer being freed was not allocated

Anyone ever seen this error?

`screengrab(85456,0x70000db22000) malloc: *** error for object 0x5955525554525150: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
SIGABRT: abort
PC=0x7fff5c9a6e3e m=4 sigcode=0

goroutine 0 [idle]:
runtime: unknown pc 0x7fff5c9a6e3e
stack: frame={sp:0x70000db21d78, fp:0x0} stack=[0x70000daa2290,0x70000db21e90)
000070000db21c78: 0000000000000000 00007fff5ca18a81
000070000db21c88: 000000000affa000 0000000000000000
000070000db21c98: 00007fff5ca18a70 000070000db21d00
000070000db21ca8: 00007fff5cad90d0 0000700000000001
000070000db21cb8: 0000000000000000 00007fff5ca18a81
000070000db21cc8: 000070000db21d10 000070000db22000
000070000db21cd8: 000000000affa000 000000000ac49000
000070000db21ce8: 0000000000000002 0000000000000000
000070000db21cf8: 5955525554525150 000070000db21de0
000070000db21d08: 00007fff5cad907d 0000003000000018
000070000db21d18: 000070000db21df0 000070000db21d30
000070000db21d28: 0000000000000032 9e3779b97f4a7c55
000070000db21d38: 000000000ac4b0e0 5955525554525150
000070000db21d48: 00007fff5cadae20 0000000000000000
000070000db21d58: 0000000000000000 0a99ac7c1b600036
000070000db21d68: 000070000db21dd8 000000000ac49000
000070000db21d78: <00007fff5cae5150 000070000db22000
000070000db21d88: 000070000db21dc8 000000000ac49000
000070000db21d98: 0000000000000002 0000000000000000
000070000db21da8: 5955525554525150 000070000db21de0
000070000db21db8: 00007fff5c903312 000070000db21de0
000070000db21dc8: 00007fffffffffdf ffffffff0db21d10
000070000db21dd8: 000000000affa000 000070000db21e20
000070000db21de8: 00007fff5ca00866 00007fff9588d0c0
000070000db21df8: 000000c4203262d0 0000000000000040
000070000db21e08: 0000000000000040 0000000000000011
000070000db21e18: 0000000000000100 000000c420053ce8
000070000db21e28: 00000000042399a6 000000c420053d28
000070000db21e38: 0000000004056bb0 <runtime.asmcgocall+112> 000000c420076180
000070000db21e48: 000070000db21e68 0000000004052702 <runtime.(*mcache).nextFree.func1+50>
000070000db21e58: 000000000ac5c6c8 000000000bf5415b
000070000db21e68: 0000000000000348 000000c420000180
runtime: unknown pc 0x7fff5c9a6e3e
stack: frame={sp:0x70000db21d78, fp:0x0} stack=[0x70000daa2290,0x70000db21e90)
000070000db21c78: 0000000000000000 00007fff5ca18a81
000070000db21c88: 000000000affa000 0000000000000000
000070000db21c98: 00007fff5ca18a70 000070000db21d00
000070000db21ca8: 00007fff5cad90d0 0000700000000001
000070000db21cb8: 0000000000000000 00007fff5ca18a81
000070000db21cc8: 000070000db21d10 000070000db22000
000070000db21cd8: 000000000affa000 000000000ac49000
000070000db21ce8: 0000000000000002 0000000000000000
000070000db21cf8: 5955525554525150 000070000db21de0
000070000db21d08: 00007fff5cad907d 0000003000000018
000070000db21d18: 000070000db21df0 000070000db21d30
000070000db21d28: 0000000000000032 9e3779b97f4a7c55
000070000db21d38: 000000000ac4b0e0 5955525554525150
000070000db21d48: 00007fff5cadae20 0000000000000000
000070000db21d58: 0000000000000000 0a99ac7c1b600036
000070000db21d68: 000070000db21dd8 000000000ac49000
000070000db21d78: <00007fff5cae5150 000070000db22000
000070000db21d88: 000070000db21dc8 000000000ac49000
000070000db21d98: 0000000000000002 0000000000000000
000070000db21da8: 5955525554525150 000070000db21de0
000070000db21db8: 00007fff5c903312 000070000db21de0
000070000db21dc8: 00007fffffffffdf ffffffff0db21d10
000070000db21dd8: 000000000affa000 000070000db21e20
000070000db21de8: 00007fff5ca00866 00007fff9588d0c0
000070000db21df8: 000000c4203262d0 0000000000000040
000070000db21e08: 0000000000000040 0000000000000011
000070000db21e18: 0000000000000100 000000c420053ce8
000070000db21e28: 00000000042399a6 000000c420053d28
000070000db21e38: 0000000004056bb0 <runtime.asmcgocall+112> 000000c420076180
000070000db21e48: 000070000db21e68 0000000004052702 <runtime.(*mcache).nextFree.func1+50>
000070000db21e58: 000000000ac5c6c8 000000000bf5415b
000070000db21e68: 0000000000000348 000000c420000180

goroutine 1 [syscall]:
runtime.cgocall(0x420a340, 0xc420053d28, 0x10cfb040)
/usr/local/go/src/runtime/cgocall.go:128 +0x64 fp=0xc420053cf8 sp=0xc420053cc0 pc=0x40055d4
github.com/gen2brain/x264-go/x264c._Cfunc_x264_picture_clean(0xc4203262d0)
_cgo_gotypes.go:589 +0x41 fp=0xc420053d28 sp=0xc420053cf8 pc=0x40bbfb1
github.com/gen2brain/x264-go/x264c.PictureClean.func1(0xc4203262d0)
/go/src/github.com/gen2brain/x264-go/x264c/x264c.go:853 +0x56 fp=0xc420053d60 sp=0xc420053d28 pc=0x40bc8a6
github.com/gen2brain/x264-go/x264c.PictureClean(0xc4203262d0)
/go/src/github.com/gen2brain/x264-go/x264c/x264c.go:853 +0x2b fp=0xc420053d78 sp=0xc420053d60 pc=0x40bc30b
github.com/gen2brain/x264-go.(*Encoder).Encode(0xc420080120, 0x437cee0, 0xc420020140, 0x0, 0x0)
/go/src/github.com/gen2brain/x264-go/encode.go:176 +0x343 fp=0xc420053e10 sp=0xc420053d78 pc=0x40bff93
main.main()
/go/src/github.com/gen2brain/x264-go/examples/screengrab/screengrab.go:93 +0x530 fp=0xc420053f88 sp=0xc420053e10 pc=0x41f7e10
runtime.main()
/usr/local/go/src/runtime/proc.go:198 +0x212 fp=0xc420053fe0 sp=0xc420053f88 pc=0x402e402
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc420053fe8 sp=0xc420053fe0 pc=0x4057ea1

goroutine 5 [syscall]:
os/signal.signal_recv(0x0)
/usr/local/go/src/runtime/sigqueue.go:139 +0xa7
os/signal.loop()
/usr/local/go/src/os/signal/signal_unix.go:22 +0x22
created by os/signal.init.0
/usr/local/go/src/os/signal/signal_unix.go:28 +0x41

goroutine 6 [select, locked to thread]:
runtime.gopark(0x435e0a8, 0x0, 0x434c1be, 0x6, 0x18, 0x1)
/usr/local/go/src/runtime/proc.go:291 +0x11a
runtime.selectgo(0xc420044750, 0xc42001e240)
/usr/local/go/src/runtime/select.go:392 +0xe50
runtime.ensureSigM.func1()
/usr/local/go/src/runtime/signal_unix.go:549 +0x1c6
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:2361 +0x1

rax 0x0
rbx 0x70000db22000
rcx 0x70000db21d78
rdx 0x0
rdi 0x1103
rsi 0x6
rbp 0x70000db21db0
rsp 0x70000db21d78
r8 0x0
r9 0x0
r10 0x0
r11 0x206
r12 0x1103
r13 0x2
r14 0x6
r15 0x2d
rip 0x7fff5c9a6e3e
rflags 0x206
cs 0x7
fs 0x0
gs 0x0
exit status 2`

x264c.Param outdated?

It seems the Param type is missing a number of fields that were added in the code update commits (i_bitdepth, i_avcintra_flavor, mastering_display, etc, etc), which makes the type incorrect and unable to apply most parameters correctly.

Do you perhaps have any tooling to update these types?

fail to build on arm64

/tmp/go-build637060393/b298/_x003.o:/home/ubuntu/go/pkg/mod/github.com/gen2brain/[email protected]/x264c/external/x264/encoder/cabac.c:89: more undefined references to x264_cabac_encode_decision_asm' follow /tmp/go-build637060393/b298/_x003.o: In function x264_cabac_mb_type_intra':
../../../../pkg/mod/github.com/gen2brain/[email protected]/x264c/external/x264/encoder/cabac.c:54: undefined reference to x264_cabac_encode_terminal_asm' ../../../../pkg/mod/github.com/gen2brain/[email protected]/x264c/external/x264/encoder/cabac.c:56: undefined reference to x264_cabac_encode_decision_asm'
../../../../pkg/mod/github.com/gen2brain/[email protected]/x264c/external/x264/encoder/cabac.c:58: undefined reference to x264_cabac_encode_decision_asm' ../../../../pkg/mod/github.com/gen2brain/[email protected]/x264c/external/x264/encoder/cabac.c:64: undefined reference to x264_cabac_encode_decision_asm'
../../../../pkg/mod/github.com/gen2brain/[email protected]/x264c/external/x264/encoder/cabac.c:65: undefined reference to x264_cabac_encode_decision_asm' /tmp/go-build637060393/b298/_x003.o: In function x264_cabac_transform_size':
../../../../pkg/mod/github.com/gen2brain/[email protected]/x264c/external/x264/encoder/cabac.c:238: undefined reference to x264_cabac_encode_decision_asm' /tmp/go-build637060393/b298/_x003.o:/home/ubuntu/go/pkg/mod/github.com/gen2brain/[email protected]/x264c/external/x264/encoder/cabac.c:89: more undefined references to x264_cabac_encode_decision_asm' follow
/tmp/go-build637060393/b298/_x003.o: In function x264_slice_write': ../../../../pkg/mod/github.com/gen2brain/[email protected]/x264c/external/x264/encoder/encoder.c:2748: undefined reference to x264_cabac_encode_terminal_asm'
collect2: error: ld returned 1 exit status

github.com/gen2brain/x264-go/x264c

the efficiency of YCbCr converter in x264-go

hello

I found that the efficiency of YCbCr converter in x264-go is quite low,

image

I0204 23:05:53.512131 31980 encoder.go:79] H264: start encode one image
before convert to YCbCr. the time is %v 2021-02-04 23:05:53.512142829 +0800 CST m=+17.347932716
after convert to YCbCr. the time is %v 2021-02-04 23:05:53.663298327 +0800 CST m=+17.499088233

I0204 23:05:53.669515 31980 encoder.go:79] H264: start encode one image
before convert to YCbCr. the time is %v 2021-02-04 23:05:53.66953006 +0800 CST m=+17.505319930
after convert to YCbCr. the time is %v 2021-02-04 23:05:53.826771366 +0800 CST m=+17.662561280

1080p
convert time:almost 151ms
convert + encode time : 157ms

Is there any methods to optimize?

How can i extract seprate SPS and PPS bytes array ?

I am looking to integrate the X264 with the simple-rtsp-server (mediamtx ) now to publish the x264 stream .

RTSP Streaming somewhere expect a separate byte array for SPS and PPS. i can see the initial header we are writing the data but its looks like its a combined data is there anyway i can seprate them up in the two parts.

Is there a way to support hardware acceleration

In my case, the speed of encoding become the bottle of the whole process, it takes about 50ms to encode a single image in ultrafast preset. Is there a way to use hardware acceleration? Or any other way to speed up encoding?

problem with win10 x64

x264 [info]: using cpu capabilities: none!
x264 [info]: profile Constrained Baseline, level 3.1
x264 [debug]: frame= 0 QP=11.43 NAL=3 Slice:I Poc:0 I:3600 P:0 SKIP:0 size=65211 bytes
exit status 3221226356

Can you add crf to Option struct?

package main

import (
	"fmt"
	"log"
	"os"
	"time"

	x264 "github.com/gen2brain/x264-go"
	"github.com/kbinani/screenshot"
)

func main() {
	n := screenshot.NumActiveDisplays()
	for i := 0; i < n; i++ {
		save(i)
	}

}

func save(i int) {
	file, err := os.Create(fmt.Sprintf("%v_screen.264", i))
	if err != nil {
		log.Println("Create err:", err)
		os.Exit(1)
	}

	bounds := screenshot.GetDisplayBounds(i)

	opts := &x264.Options{
		Width:     bounds.Dx(),
		Height:    bounds.Dy(),
		FrameRate: 3,
		Tune:      "film",
		Preset:    "faster",
		Profile:   "baseline",
		LogLevel:  x264.LogError,
	}

	enc, err := x264.NewEncoder(file, opts)
	if err != nil {
		fmt.Fprintf(os.Stderr, "%s\n", err.Error())
		os.Exit(1)
	}

	defer enc.Close()

	timer := time.NewTimer(5 * time.Second)
	defer timer.Stop()

	for {
		select {
		case <-timer.C:
			enc.Flush()

			err = file.Close()
			if err != nil {
				log.Println("Close err:", err)
				os.Exit(1)
			}

			return
		default:
			img, err := screenshot.CaptureRect(bounds)
			if err != nil {
				log.Println("CaptureRect err:", err)

				continue
			}

			err = enc.Encode(img)
			if err != nil {
				log.Println("Encode err:", err)
			}
			// When sleep() is removed, the file size multiplies
			time.Sleep(300 * time.Millisecond)
		}
	}
}

The current file size is around 1500kb. I don't care about the video quality. I hope I can further compress the size without affecting performance too much

Decode h264

Looking forward to decode h264 stream function !

Tag with the current commit

The command go get -u "github.com/gen2brain/x264-go" is currently broken. I believe this was fixed in the latest commit, but the changes have not been pushed to pkg.go.dev because the current tagged version is from before the commit was made.

This is the full error:

go: downloading github.com/gen2brain/x264-go v0.2.2
go: github.com/gen2brain/[email protected] requires
	github.com/gen2brain/x264-go/[email protected]: invalid version: unknown revision 000000000000

error running example on windows

I copied the example from folder and just an go mod tidy and run it using go run main.go it gives this error.
i am not able to identify issue with package

image

Out of memory error agent: malloc.c:2379: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.

I am creating a new encoder inside a function. I am not even calling the function just declaring the function. I am getting this error and program crashes and also all the go routines.

My current Implementation. I am just declaring I haven't even called the function anywhere.
`
func (h *Handler) Encoder(ros_cameras []model.RosStreams, pc *webrtc.PeerConnection, disconnected chan bool) {
for _, cam := range ros_cameras {
videoTrack, err := webrtc.NewTrackLocalStaticSample(
webrtc.RTPCodecCapability{
MimeType: webrtc.MimeTypeH264,
},
fmt.Sprintf("video-%d", randutil.NewMathRandomGenerator().Uint32()),
fmt.Sprintf("video-%d", randutil.NewMathRandomGenerator().Uint32()),
)
if err != nil {
panic(err)
}
_, err = pc.AddTrack(videoTrack)
if err != nil {
panic(err)
}

	opts := &gen264.Options{
		Width:     640,
		Height:    480,
		FrameRate: 0,
		// Presets: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo
		Preset: "zerolatency",
		// Tunings: film, animation, grain, stillimage, psnr, ssim, fastdecode, zerolatency.
		Tune: "veryfast",
		// Profiles: baseline, main, high, high10, high422, high444.
		Profile:  "baseline",
		LogLevel: gen264.LogError,
	}

	buffer := bytes.NewBuffer(make([]byte, 0))
	

	enc, err := gen264.NewEncoder(buffer, opts)
	if err != nil {
		fmt.Println("Error initializing codec", err)
		os.Exit(1)
	}
	fmt.Println(enc)

	// throttler := throttle.New(time.Millisecond * 50)
	sub, err := h.Subscribe(cam.TopicName, func(msg *sensor_msgs.Image) {
		

		defer func() {
			if r := recover(); r != nil {
				fmt.Println("Recovered in f", r)
			}
		}()

	})
	if err != nil {
		fmt.Println("Error in ros subscribe", err, sub)
	}

	go func() {
		<-disconnected
		fmt.Println("Stopping subscription")
		sub.Close()
	}()
}

}

`

This is the error. It goes on for more than 300 lines. I Also tweeked options and it doesn't fix it.

agent: malloc.c:2379: sysmalloc: Assertion (old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.
SIGABRT: abort
PC=0x7fd41cde303b m=13 sigcode=18446744073709551610
signal arrived during cgo execution

goroutine 40 [syscall]:
runtime.cgocall(0xb82780, 0xc0004dfd40)
/usr/local/go/src/runtime/cgocall.go:158 +0x5c fp=0xc0004df970 sp=0xc0004df938 pc=0x41175c
github.com/pion/mediadevices/pkg/codec/x264._Cfunc_enc_new({0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x280, 0x1e0, 0x1, ...}, ...)
_cgo_gotypes.go:420 +0x65 fp=0xc0004dfd40 sp=0xc0004df970 pc=0xb6c485
github.com/pion/mediadevices/pkg/codec/x264.newEncoder.func1(0x152a500?, 0x1?, 0x1?)
/home/anand/Go/pkg/mod/github.com/pion/[email protected]/pkg/codec/x264/x264.go:85 +0x138 fp=0xc0004e0870 sp=0xc0004dfd40 pc=0xb6caf8
github.com/pion/mediadevices/pkg/codec/x264.newEncoder({0xfcac40, 0xc000414078}, {{0x0, 0x0}, {0x280, 0x1e0, 0x0, {0x0, 0x0}}, {0x0, ...}}, ...)
/home/anand/Go/pkg/mod/github.com/pion/[email protected]/pkg/codec/x264/x264.go:85 +0x125 fp=0xc0004e0c80 sp=0xc0004e0870 pc=0xb6c845
github.com/pion/mediadevices/pkg/codec/x264.(*Params).BuildVideoEncoder(0x1e0?, {0xfcac40?, 0xc000414078?}, {{0x0, 0x0}, {0x280, 0x1e0, 0x0, {0x0, 0x0}}, ...})
/home/anand/Go/pkg/mod/github.com/pion/[email protected]/pkg/codec/x264/params.go:49 +0x6f fp=0xc0004e0d18 sp=0xc0004e0c80 pc=0xb6c0ef
github.com/pion/mediadevices.(*CodecSelector).selectVideoCodecByNames(0xc000364d20, {0xfcac40, 0xc000414078}, {{0x0, 0x0}, {0x280, 0x1e0, 0x0, {0x0, 0x0}}, ...}, ...)
/home/anand/Go/pkg/mod/github.com/pion/[email protected]/codec.go:74 +0x439 fp=0xc0004e0e60 sp=0xc0004e0d18 pc=0xb61dd9
github.com/pion/mediadevices.(*VideoTrack).newEncodedReader(0xc000012240, {0xc0004e1068, 0x1, 0x1})
/home/anand/Go/pkg/mod/github.com/pion/[email protected]/track.go:384 +0x165 fp=0xc0004e0ff0 sp=0xc0004e0e60 pc=0xb678e5
github.com/pion/mediadevices.(*VideoTrack).NewRTPReader(0xc000012240, {0xc0001c6bf6?, 0xc0000418c0?}, 0x8438ce24, 0x4b0)
/home/anand/Go/pkg/mod/github.com/pion/[email protected]/track.go:419 +0x6a fp=0xc0004e1088 sp=0xc0004e0ff0 pc=0xb67d6a
github.com/pion/mediadevices.(*baseTrack).bind(0xc000122840, {{0xc0000418c0, 0x20}, {{0x1602ac0, 0x0, 0x0}, {0xc00009a240, 0x1, 0x1}}, 0x8438ce24, ...}, ...)
/home/anand/Go/pkg/mod/github.com/pion/[email protected]/track.go:173 +0x6f4 fp=0xc0004e1298 sp=0xc0004e1088 pc=0xb661f4
github.com/pion/mediadevices.(*VideoTrack).Bind(0x7fd3f5a91700?, {{0xc0000418c0, 0x20}, {{0x1602ac0, 0x0, 0x0}, {0xc00009a240, 0x1, 0x1}}, 0x8438ce24, ...})
/home/anand/Go/pkg/mod/github.com/pion/[email protected]/track.go:370 +0xc5 fp=0xc0004e1430 sp=0xc0004e1298 pc=0xb67625
github.com/pion/webrtc/v3.(*RTPSender).Send(0xc0000c1800, {{{0x1602ac0, 0x0, 0x0}, {0xc00009a240, 0x1, 0x1}}, {0xc00054e0c0, 0x1, 0x1}})
/home/anand/Go/pkg/mod/github.com/pion/webrtc/[email protected]/rtpsender.go:305 +0x515 fp=0xc0004e18b0 sp=0xc0004e1430 pc=0xb43bb5
github.com/pion/webrtc/v3.(*PeerConnection).startRTPSenders(0xe56200?, {0xc000196a20, 0xb, 0xc00052e280?})
/home/anand/Go/pkg/mod/github.com/pion/webrtc/[email protected]/peerconnection.go:1386 +0x1bd fp=0xc0004e1978 sp=0xc0004e18b0 pc=0xb3389d
github.com/pion/webrtc/v3.(*PeerConnection).SetLocalDescription(0xc0003ba000, {0x3, {0xc000331800, 0x1764}, 0xc00040c240})
/home/anand/Go/pkg/mod/github.com/pion/webrtc/[email protected]/peerconnection.go:987 +0x38a fp=0xc0004e1a30 sp=0xc0004e1978 pc=0xb2f74a
robotix-agent/handler.(*Handler).StartWebRtc(0xfca460?, {0xc0003dc000, 0xdbc4})
/home/anand/go/src/github.com/anand-dotworld/robotix-agent/handler/webrtc.go:262 +0x8cb fp=0xc0004e1ce0 sp=0xc0004e1a30 pc=0xb7e60b
robotix-agent/handler.(*Handler).InitializeWebrtcSignalStream(0xc000132240, {0xfcfa20, 0xc000188000})
/home/anand/go/src/github.com/anand-dotworld/robotix-agent/handler/webrtc.go:77 +0x44b fp=0xc0004e1fb8 sp=0xc0004e1ce0 pc=0xb7dacb
main.main.func4()
/home/anand/go/src/github.com/anand-dotworld/robotix-agent/agent.go:54 +0x2e fp=0xc0004e1fe0 sp=0xc0004e1fb8 pc=0xb8164e
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0004e1fe8 sp=0xc0004e1fe0 pc=0x4742a1
created by main.main
/home/anand/go/src/github.com/anand-dotworld/robotix-agent/agent.go:54 +0x377

goroutine 1 [chan receive]:
runtime.gopark(0x0?, 0xc000235e50?, 0x3f?, 0xb0?, 0x0?)
/usr/local/go/src/runtime/proc.go:363 +0xd6 fp=0xc000086dd0 sp=0xc000086db0 pc=0x4461b6
runtime.chanrecv(0xc000196cc0, 0x0, 0x1)
/usr/local/go/src/runtime/chan.go:583 +0x49b fp=0xc000086e60 sp=0xc000086dd0 pc=0x41475b
runtime.chanrecv1(0xc000132240?, 0xfcfa20?)
/usr/local/go/src/runtime/chan.go:442 +0x18 fp=0xc000086e88 sp=0xc000086e60 pc=0x414258
main.main()
/home/anand/go/src/github.com/anand-dotworld/robotix-agent/agent.go:73 +0x43e fp=0xc000086f80 sp=0xc000086e88 pc=0xb813be
runtime.main()
/usr/local/go/src/runtime/proc.go:250 +0x212 fp=0xc000086fe0 sp=0xc000086f80 pc=0x445df2
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000086fe8 sp=0xc000086fe0 pc=0x4742a1

goroutine 2 [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:363 +0xd6 fp=0xc000072fb0 sp=0xc000072f90 pc=0x4461b6
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:369
runtime.forcegchelper()
/usr/local/go/src/runtime/proc.go:302 +0xad fp=0xc000072fe0 sp=0xc000072fb0 pc=0x44604d
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000072fe8 sp=0xc000072fe0 pc=0x4742a1
created by runtime.init.6
/usr/local/go/src/runtime/proc.go:290 +0x25

goroutine 3 [GC sweep wait]:
runtime.gopark(0x1?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:363 +0xd6 fp=0xc000073790 sp=0xc000073770 pc=0x4461b6
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:369
runtime.bgsweep(0x0?)
/usr/local/go/src/runtime/mgcsweep.go:297 +0xd7 fp=0xc0000737c8 sp=0xc000073790 pc=0x432897
runtime.gcenable.func1()
/usr/local/go/src/runtime/mgc.go:178 +0x26 fp=0xc0000737e0 sp=0xc0000737c8 pc=0x427506
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0000737e8 sp=0xc0000737e0 pc=0x4742a1
created by runtime.gcenable
/usr/local/go/src/runtime/mgc.go:178 +0x6b

goroutine 4 [GC scavenge wait]:
runtime.gopark(0xc00003c150?, 0xfc3b30?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:363 +0xd6 fp=0xc000073f70 sp=0xc000073f50 pc=0x4461b6
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:369
runtime.(*scavengerState).park(0x155bb00)
/usr/local/go/src/runtime/mgcscavenge.go:389 +0x53 fp=0xc000073fa0 sp=0xc000073f70 pc=0x4308f3
runtime.bgscavenge(0x0?)
/usr/local/go/src/runtime/mgcscavenge.go:622 +0x65 fp=0xc000073fc8 sp=0xc000073fa0 pc=0x430ee5
runtime.gcenable.func2()
/usr/local/go/src/runtime/mgc.go:179 +0x26 fp=0xc000073fe0 sp=0xc000073fc8 pc=0x4274a6
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000073fe8 sp=0xc000073fe0 pc=0x4742a1
created by runtime.gcenable
/usr/local/go/src/runtime/mgc.go:179 +0xaa

goroutine 18 [finalizer wait]:
runtime.gopark(0x155c440?, 0xc000007860?, 0x0?, 0x0?, 0xc000072770?)
/usr/local/go/src/runtime/proc.go:363 +0xd6 fp=0xc000072628 sp=0xc000072608 pc=0x4461b6
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:369
runtime.runfinq()
/usr/local/go/src/runtime/mfinal.go:180 +0x10f fp=0xc0000727e0 sp=0xc000072628 pc=0x42660f
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0000727e8 sp=0xc0000727e0 pc=0x4742a1
created by runtime.createfing
/usr/local/go/src/runtime/mfinal.go:157 +0x45

`

Memory leaking

Running the screengrab.go, anyone observed the memory usage is always ramping up?

x264_config.h not found

Go version: 1.19.3
x264-go version: v0.2.0
OS version: Windows 10 version 22H2
Hi, When I try to build my project which uses x264-go with above configuration on windows it fails with this error

# [github.com/gen2brain/x264-go/x264c](http://github.com/gen2brain/x264-go/x264c)
In file included from ./external/x264/common/osdep.h:52,
                 from ./external/x264/common/base.h:43,
                 from ./external/x264/common/base.c:27,
                 from ..\..\..\..\go\pkg\mod\[github.com](http://github.com/)\gen2brain\x264-go\[email protected]\common_base.go:7:
..\..\..\..\go\pkg\mod\[github.com](http://github.com/)\gen2brain\x264-go\[email protected]\external\x264/x264.h:46:10: fatal error: x264_config.h: No such file or directory
   46 | #include "x264_config.h"

I notice this in the [email protected] version of the library but in x264-go/x264c v0.0.0-20210523185153-54bdbefd1212 this version, the same file which has //#include "x264_config.h" line commented so this version works fine while building with go 1.16 version.

But now I can't force go to download the older version as its a indirect dependency and it always pulls the latest version of x264c.
Thanks

using the data

this is cool.
Worked first time and i got a stream.264.
I assume that this needs to be fed into VLC or something to make a video file ?

Build issue - 'external/x264/common/base.c' file not found

Hello,

I'm using m1 mac.
export GOOS=darwin
export GOARCH=arm64

When I try to build I'm getting the error

vendor/github.com/gen2brain/x264-go/x264c/common_base.go:6:10: fatal error: 'external/x264/common/base.c' file not found
#include "external/x264/common/base.c"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

How can I solve this error?

Frame Rate

In the encoding options, FrameRate fields type is integer. Should It be float32 rather than int? I think, FPS value has not be integer. When I use openCV with this API, my camera's fps is 29.00009. It is ok to round the fps value for this case. But every camera devices have different fps value.

Thanks,

Doesn't produce a valid video file

The video produced doesn't work with Quicktime or VLC. However, when I ran it through ffmpeg, ffmpeg produced a valid video. But I can't have it re-encoded through ffmpeg all the time, what is wrong?

When I tried to run it through ffmpeg without re-encoding, ffmpeg gave the error

Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly

Is there an issue with the timestamps that is causing this? I noticed that param.ITimebaseNum isn't set.

extlib on Ubuntu 20.04

I'm trying to use extlib on ubuntu 20.04, which uses x264 v155.

For this, I've updated the x264.h, encoder and common from the exact same version, v155 commit 0a84d98

I'm able to compile and link fine, but at runtime, when I initialize the encoder, I'm getting these two errors:

x264 [error]:  8-bit AVC-Intra is not widely compatible
x264 [error]: 10-bit x264 is required to encode AVC-Intra

So I took a look at the source, and tried adding this in x264c_cgo_extlib.go:

#cgo linux CFLAGS: -DX264_REV=2917 -DX264_REV_DIFF=0 -DX264_VERSION=" r2917 0a84d98" -DX264_POINTVER="0.155.2917 0a84d98" -DHAVE_BITDEPTH10=1 -DHIGH_BIT_DEPTH=1 -DBIT_DEPTH=10

But it doesn't seem to be enough. Any idea of what I could try next?

undefined reference to `__log2f_finite'

when i run:
go get -u github.com/gen2brain/x264-go
then get the follow errors:

# github.com/gen2brain/x264-go/x264c
x264c_analyse_linux_amd64.syso: In function `x264_analyse_init_costs':
analyse.c:(.text+0x27115): undefined reference to `__log2f_finite'
collect2: ld 返回 1

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.