Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
17.3.0
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM ubuntu:18.04

RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
RUN apt-get install build-essential wget pkg-config xvfb libxi-dev libglu1-mesa-dev libglew-dev libvips-dev -y --no-install-recommends

# install ffmpeg
RUN wget --no-check-certificate -O /tmp/ffmpeg.tar.xz \
"https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-$(dpkg --print-architecture)-static.tar.xz" \
&& mkdir /usr/local/ffmpeg && cd /usr/local/ffmpeg && tar xvf /tmp/ffmpeg.tar.xz --strip-components=1
ENV PATH=/usr/local/ffmpeg:$PATH

# upgrade vips
ARG VIPS_VERSION="8.12.1"
RUN cd /tmp && wget --no-check-certificate \
"https://github.com/libvips/libvips/releases/download/v$VIPS_VERSION/vips-$VIPS_VERSION.tar.gz" && \
tar zxvf vips* && cd vips-$VIPS_VERSION && ./configure && make && make install && ldconfig
ENV LD_LIBRARY_PATH=/usr/local/lib
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
ENV GI_TYPELIB_PATH=/usr/lib/$(arch)-linux-gnu/girepository-1.0:/usr/lib/girepository-1.0

# install nodejs
WORKDIR /app
ADD .nvmrc /app/.nvmrc
RUN wget --no-check-certificate \
"https://nodejs.org/dist/v$(cat .nvmrc)/node-v$(cat .nvmrc)-linux-$( \
[ $(dpkg --print-architecture) = amd64 ] && echo x64 || dpkg --print-architecture).tar.gz" \
-O /tmp/node.tar.gz \
&& tar -xf /tmp/node.tar.gz -C /usr/local --strip-components=1 \
&& rm /tmp/node.tar.gz

ADD package*.json /app
RUN npm install

ADD *.js *.sh /app/
ADD lib /app/lib
ADD media /app/media

RUN ln -s /app/lib/cli.js /usr/local/bin/ffmpeg-concat

ENTRYPOINT ["/app/docker-entrypoint.sh"]
14 changes: 14 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

CMD_PREPEND="ffmpeg-concat"
PATTERN="^\s*(npm|npx|node|ffmpeg|sh|bash).*$"
if [[ $# == 0 ]]; then
CMD_PREPEND="ffmpeg-concat --help"
elif [[ "$1" =~ $PATTERN ]]; then
CMD_PREPEND=""
fi

echo Running: exec xvfb-run -s "-ac -screen 0 1280x1024x24" \
$CMD_PREPEND "$@"
exec xvfb-run -s "-ac -screen 0 1280x1024x24" \
$CMD_PREPEND "$@"
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
"node": ">=10.13.0"
},
"scripts": {
"test": "ava -v && standard"
"test": "ava -v && standard",
"docker-build": "docker build . -t ffmpeg-concat",
"docker-test": "docker build . -t ffmpeg-concat && docker run --init ffmpeg-concat npm run test",
"docker": "docker run --init -v \"${DIR:-$(pwd)}:/vids\" -w /vids ffmpeg-concat"
},
"keywords": [
"ffmpeg",
Expand Down Expand Up @@ -47,7 +50,7 @@
"p-map": "^2.0.0",
"p-race": "^2.0.0",
"rmfr": "^2.0.0",
"sharp": "^0.24.0",
"sharp": "^0.29.3",
"tempy": "^0.2.1",
"url-parse": "^1.4.4"
},
Expand Down
24 changes: 24 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,30 @@ This package runs on Linux, macOS, and Windows.

Node.js versions 10.13.0 and up are supported. Note (**macOS only**): due to an inadvertant low-level breaking change in libuv's process handling code, OpenGL [is not supported](https://github.com/stackgl/headless-gl#supported-platforms-and-nodejs-versions) when running Node.js version 12.13.1 through to 13.6.0 on macOS. A fix has been released in Node.js version 13.7.0. A fix for 12.x is pending. Other platforms are unaffected.

### Docker

A multi-platform and multi-arch Docker image can be used for debugging and cross platform needs (requires [Docker](https://www.docker.com/) installed), as well as avoiding requiring `ffmpeg` and node dependencies installed locally.

Docker image build:
```bash
npm run docker-build
```

After image is built, some `docker run` examples:
```bash
# run tests in docker container
npm run docker-test
# print CLI options
npm run docker
npm run docker -- --help
# run on this repo's sample files in container
npm run docker -- media/0.mp4 media/1.mp4
# run with host machine files (make sure Docker has access / permissions)
DIR=/path/to/vids/dir npm run docker -- file1.mov file2.avi
```

See [package.json](./package.json), and [Dockerfile](./Dockerfile) for more details.

## CLI

```sh
Expand Down