asticode / go-astiav

Golang ffmpeg and libav C bindings
MIT License
393 stars 45 forks source link

Could not compile without editing frame_side_data_type.go #15

Closed kfatehi closed 1 year ago

kfatehi commented 1 year ago

Hi. On current master branch (as well as on tag v0.7.3) I was getting the following errors:

body@body-OptiPlex-7050:~/webrtc-body$ cat run.sh
export CGO_LDFLAGS="-L/home/body/webrtc-body/go-astiav/tmp/n4.4.1/lib/"
export CGO_CXXFLAGS="-I/home/body/webrtc-body/go-astiav/tmp/n4.4.1/include/"
export PKG_CONFIG_PATH="/home/body/webrtc-body/go-astiav/tmp/n4.4.1/lib/pkgconfig"
go run .
body@body-OptiPlex-7050:~/webrtc-body$ ./run.sh
# github.com/asticode/go-astiav
go-astiav/frame_side_data_type.go:32:64: could not determine kind of name for C.AV_FRAME_DATA_FILM_GRAIN_PARAMS
go-astiav/frame_side_data_type.go:31:64: could not determine kind of name for C.AV_FRAME_DATA_SEI_UNREGISTERED
go-astiav/frame_side_data_type.go:30:64: could not determine kind of name for C.AV_FRAME_DATA_VIDEO_ENC_PARAMS

I was able to workaround it by commenting those out

image

I thought it might be related to my exports but I double-checked them just now. It is possible it is loading my system ffmpeg still, I am not really sure how to know if it's using the n4.4.1 which perhaps has those 3 defined whilst my system ffmpeg does not. Just a guess.

asticode commented 1 year ago

This usually indicates an ffmpeg version problem indeed.

You could try uninstalling your system ffmpeg to see whether that fixes the issue 👍

gedw99 commented 1 year ago

I wrote a small bit of golang that downloads the ffmpeg binaries on demand . Don’t know if this is useful ?

I got sick of the cross platform setup issues for developers on their laptops and this fixed it

bbetter173 commented 1 year ago

I wrote a small bit of golang that downloads the ffmpeg binaries on demand . Don’t know if this is useful ?

I got sick of the cross platform setup issues for developers on their laptops and this fixed it

@gedw99 - Do you mind sharing this? I've been struggling with the same thing across a variety of platforms and cpu architectures and I'd rather use/improve an existing solution rather than rolling our own. Cheers!

gedw99 commented 1 year ago

@bbetter173

Its wrapped up in some code but this makefile shows it working.

Try it out. If you dont know makefiles then contact me and i can give you a easier solution to get it working.


# https://github.com/peolic/videohashes

REPO_NAME=videohashes

REPO_URL=git@github.com:peolic/$(REPO_NAME).git
REPO_VER=main

# Allow downloading of ffmpeg/ffprobe if no acceptable executables on path
# https://github.com/peolic/videohashes/pull/6
# https://github.com/4c0d3r/videohashes
# git@github.com:4c0d3r/videohashes.git
REPO_URL=git@github.com:4c0d3r/$(REPO_NAME).git
REPO_VER=main

BIN_FSPATH_NAME=.bin
BIN_FSPATH=$(PWD)/$(BIN_FSPATH_NAME)

BIN_NAME=videohashes
BIN=$(BIN_FSPATH)/$(BIN_NAME)

print:
    @echo ""
    @echo "REPO_NAME:     $(REPO_NAME)"
    @echo "REPO_URL:      $(REPO_URL)"
    @echo "REPO_VER:      $(REPO_VER)"
    @echo "REPO_PR_ID:    $(REPO_PR_ID)"
    @echo "BIN:           $(BIN)"

dep-git:
    git clone $(REPO_URL) -b $(REPO_VER)
    @echo $(REPO_NAME) >> .gitignore

dep-git-del:
    rm -rf $(REPO_NAME)

dep-tools:
    go install github.com/oligot/go-mod-upgrade@latest

CMD=cd $(REPO_NAME) &&

mod-upgrade: dep-tools mod-tidy
    $(CMD) go-mod-upgrade
    $(MAKE) mod-tidy
mod-tidy:
    $(CMD) go mod tidy

gen:
    $(CMD) go generate ./... -v

build:
    $(CMD) EXTRA_LDFLAGS='-extldflags=-static -s -w' go build -o $(BIN) ./cmd/videohashes
build-del:
    rm -rf $(BIN_FSPATH)

### TEST

# https://samplelib.com/
# https://github.com/ffeast/samplelib
TEST_REPO_NAME=samplelib
TEST_REPO_URL=git@github.com:ffeast/samplelib.git
TEST_REPO_VER=main

TEST_FSPATH=$(PWD)/samplelib/mp4
TEST_NAME=sample-5s.mp4
TEST=$(TEST_FSPATH)/$(TEST_NAME)

test-print:
    @echo ""
    @echo "TEST_NAME:     $(TEST_NAME)"
    @echo "TEST:          $(TEST)"

test-dep-git:
    # this is a repo with test samples
    git clone $(TEST_REPO_URL)
    @echo $(TEST_REPO_NAME) >> .gitignore
test-dep-git-del:
    rm -rf $(TEST_REPO_NAME)
test-run:
    $(BIN) -json -md5 -video $(TEST)

I am integrating this concept at the moment into a plugin for a ML platform, and so hopefully will open source it one day. takes for freaking ever mate !!