Skip to content

Commit 45adeef

Browse files
committed
Added devcontainer
1 parent a7292ef commit 45adeef

File tree

17 files changed

+124
-130
lines changed

17 files changed

+124
-130
lines changed

.devcontainer/Dockerfile

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
FROM debian:latest
2+
3+
RUN apt-get update
4+
5+
##
6+
# git
7+
##
8+
9+
RUN apt-get install -y git nano
10+
11+
##
12+
# ffmpeg
13+
##
14+
15+
ARG FFMPEG_VERSION
16+
17+
RUN apt-get install -y \
18+
build-essential \
19+
nasm \
20+
pkg-config \
21+
libx264-dev \
22+
libpng-dev
23+
24+
RUN mkdir -p /opt/ffmpeg \
25+
&& git clone https://github.com/FFmpeg/FFmpeg /opt/ffmpeg/src \
26+
&& cd /opt/ffmpeg/src \
27+
&& git checkout ${FFMPEG_VERSION}
28+
29+
RUN cd /opt/ffmpeg/src \
30+
&& ./configure --prefix=.. --enable-libx264 --enable-gpl \
31+
&& make \
32+
&& make install
33+
34+
##
35+
# go
36+
##
37+
38+
ARG GO_VERSION
39+
40+
RUN apt-get install -y wget
41+
RUN <<_EOF_ sh
42+
arch=$(dpkg --print-architecture)
43+
goArch="amd64"
44+
case \${arch} in
45+
arm64) goArch="arm64" ;;
46+
esac
47+
wget -O /tmp/go.tar.gz https://dl.google.com/go/go${GO_VERSION}.linux-\${goArch}.tar.gz
48+
tar -C /opt -xzf /tmp/go.tar.gz
49+
_EOF_
50+
ENV PATH="$PATH:/opt/go/bin"

.devcontainer/devcontainer.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"build": {
3+
"args": {
4+
"FFMPEG_VERSION": "n7.0",
5+
"GO_VERSION": "1.25.3"
6+
},
7+
"dockerfile": "Dockerfile"
8+
},
9+
"containerEnv": {
10+
"CGO_LDFLAGS": "-L/opt/ffmpeg/lib/",
11+
"CGO_CFLAGS": "-I/opt/ffmpeg/include/",
12+
"PKG_CONFIG_PATH": "/opt/ffmpeg/lib/pkgconfig"
13+
},
14+
"customizations": {
15+
"vscode": {
16+
"extensions": [
17+
"ms-vscode.cpptools-extension-pack",
18+
"golang.go"
19+
],
20+
"settings": {
21+
"remote.autoForwardPorts": false
22+
}
23+
}
24+
},
25+
"mounts": [
26+
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/root/.ssh,readonly,type=bind"
27+
],
28+
"name": "asticode/go-astiav"
29+
}

.github/workflows/Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version=
2+
srcPath=
3+
patchPath=
4+
5+
i:
6+
rm -rf $(srcPath)
7+
mkdir -p $(srcPath)
8+
cd $(srcPath) && git clone https://github.com/FFmpeg/FFmpeg .
9+
cd $(srcPath) && git checkout $(version)
10+
ifneq "" "$(patchPath)"
11+
cd $(srcPath) && git apply $(patchPath)
12+
endif
13+
cd $(srcPath) && ./configure --prefix=.. $(configure)
14+
cd $(srcPath) && make
15+
cd $(srcPath) && make install

.github/workflows/test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ jobs:
6969
- if: ${{ steps.load-ffmpeg-cache.outputs.cache-hit != 'true' }}
7070
name: Install ffmpeg
7171
run: |
72-
make install-ffmpeg srcPath=${{ env.FFMPEG_PATH }}/src version=${{ env.FFMPEG_VERSION }} patchPath=${{ env.FFMPEG_PATCH_PATH }}
72+
cd .github/workflows
73+
make srcPath=${{ env.FFMPEG_PATH }}/src version=${{ env.FFMPEG_VERSION }} patchPath=${{ env.FFMPEG_PATCH_PATH }}
7374
7475
- if: ${{ steps.load-ffmpeg-cache.outputs.cache-hit != 'true' }}
7576
name: Save ffmpeg cache

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
.DS_STORE
1+
.DS_Store
22
coverage.out
33
.idea

.vscode/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
settings.json

.vscode/c_cpp_properties.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"configurations": [
3+
{
4+
"includePath": [
5+
"${workspaceFolder}/**",
6+
"/opt/ffmpeg/include"
7+
]
8+
}
9+
],
10+
"version": 4
11+
}

Makefile

Lines changed: 0 additions & 31 deletions
This file was deleted.

README.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,22 +77,16 @@ for {
7777

7878
# Install ffmpeg from source
7979

80-
If you don't know how to install `ffmpeg`, you can use the following to install it from source:
80+
Check out the `ffmpeg` section in the [Devcontainer Dockerfile](.devcontainer/Dockerfile) to see how to install ffmpeg from source.
8181

82-
```sh
83-
$ make install-ffmpeg
84-
```
85-
86-
`ffmpeg` will be built from source in a directory named `tmp` and located in you working directory
87-
88-
For your GO code to pick up `ffmpeg` dependency automatically, you'll need to add the following environment variables:
82+
For your GO code to pick up `ffmpeg` dependency automatically, you'll need to update the following environment variables :
8983

90-
(don't forget to replace `{{ path to your working directory }}` with the absolute path to your working directory)
84+
(don't forget to replace `{{ path to your ffmpeg directory }}` with the absolute path to your ffmpeg directory)
9185

9286
```sh
93-
export CGO_LDFLAGS="-L{{ path to your working directory }}/tmp/n7.0/lib/",
94-
export CGO_CFLAGS="-I{{ path to your working directory }}/tmp/n7.0/include/",
95-
export PKG_CONFIG_PATH="{{ path to your working directory }}/tmp/n7.0/lib/pkgconfig",
87+
export CGO_CFLAGS="-I{{ path to your ffmpeg directory }}/include/",
88+
export CGO_LDFLAGS="-L{{ path to your ffmpeg directory }}/lib/",
89+
export PKG_CONFIG_PATH="{{ path to your ffmpeg directory }}/lib/pkgconfig",
9690
```
9791

9892
## Building on Windows

astiav_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func (h *helper) inputLastFrame(name string, mediaType MediaType, ifmt *InputFor
153153

154154
c := FindDecoder(v.CodecParameters().CodecID())
155155
if c == nil {
156-
return nil, errors.New("astiav_test: no codec")
156+
return nil, fmt.Errorf("astiav_test: no decoder found for %s", v.CodecParameters().CodecID())
157157
}
158158

159159
s.cc = AllocCodecContext(c)

0 commit comments

Comments
 (0)