Skip to content

Commit e02c03d

Browse files
committed
Added devcontainer
1 parent a7292ef commit e02c03d

File tree

16 files changed

+116
-131
lines changed

16 files changed

+116
-131
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/test.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
os: [ubuntu-latest, macos-latest, windows-latest]
15+
os: [windows-latest]
1616

1717
env:
1818
FFMPEG_VERSION: n7.0
@@ -53,23 +53,35 @@ jobs:
5353
name: Prepare linux ffmpeg install
5454
run: |
5555
sudo apt-get install yasm
56+
touch /tmp/linux.patch
57+
echo "FFMPEG_PATCH_PATH=/tmp/linux.patch" >> $GITHUB_ENV
5658
5759
- if: ${{ steps.load-ffmpeg-cache.outputs.cache-hit != 'true' && runner.os == 'macOS' }}
5860
name: Prepare macos ffmpeg install
5961
run: |
6062
brew install yasm
63+
touch /tmp/macos.patch
64+
echo "FFMPEG_PATCH_PATH=/tmp/macos.patch" >> $GITHUB_ENV
6165
6266
- if: ${{ steps.load-ffmpeg-cache.outputs.cache-hit != 'true' && runner.os == 'Windows' }}
6367
name: Prepare windows ffmpeg install
6468
run: |
6569
choco install make
6670
choco install yasm
67-
echo "FFMPEG_PATCH_PATH='$(cygpath -u ${{ github.WORKSPACE }})/.github/workflows/windows.patch'" >> $env:GITHUB_ENV
71+
echo "FFMPEG_PATCH_PATH='${{ github.WORKSPACE }}/.github/workflows/windows.patch'" >> $env:GITHUB_ENV
6872
6973
- if: ${{ steps.load-ffmpeg-cache.outputs.cache-hit != 'true' }}
7074
name: Install ffmpeg
7175
run: |
72-
make install-ffmpeg srcPath=${{ env.FFMPEG_PATH }}/src version=${{ env.FFMPEG_VERSION }} patchPath=${{ env.FFMPEG_PATCH_PATH }}
76+
mkdir -p ${{ env.FFMPEG_PATH }}/src
77+
cd ${{ env.FFMPEG_PATH }}/src
78+
git clone https://github.com/FFmpeg/FFmpeg .
79+
git checkout ${{ env.FFMPEG_VERSION }}
80+
echo "bite 1"
81+
./configure --prefix=..
82+
echo "bite 2"
83+
make
84+
make install
7385
7486
- if: ${{ steps.load-ffmpeg-cache.outputs.cache-hit != 'true' }}
7587
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)

format_context_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package astiav
22

33
import (
4+
"path/filepath"
45
"testing"
56

67
"github.com/stretchr/testify/require"
@@ -133,7 +134,7 @@ func TestFormatContext(t *testing.T) {
133134
require.NoError(t, fc6.ReadFrame(pkt1))
134135
require.Equal(t, int64(48), pkt1.Pos())
135136

136-
const outputPath = "tmp/test-format-context-output.mp4"
137+
var outputPath = filepath.Join(t.TempDir(), "test-format-context-output.mp4")
137138
fc7, err := AllocOutputFormatContext(nil, "", outputPath)
138139
require.NoError(t, err)
139140
defer fc7.Free()

0 commit comments

Comments
 (0)