Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
joelrbrandt committed Jun 20, 2023
1 parent cffe07e commit 823d964
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 569 deletions.
86 changes: 86 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# ffmpeg - http://ffmpeg.org/download.html
#
# From https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
#
# https://hub.docker.com/r/jrottenberg/ffmpeg/
#
#
FROM ubuntu:22.04

ARG FFMPEG_VERSION="6.0"
ARG X264_SHA="a8b68ebfaa68621b5ac8907610d3335971839d52"
ARG LD_LIBRARY_PATH="/opt/ffmpeg/lib"
ARG MAKEFLAGS="-j6"
ARG PKG_CONFIG_PATH="/opt/ffmpeg/share/pkgconfig:/opt/ffmpeg/lib/pkgconfig:/opt/ffmpeg/lib64/pkgconfig"
ARG PREFIX="/opt/ffmpeg"
ARG LD_LIBRARY_PATH="/opt/ffmpeg/lib:/opt/ffmpeg/lib64"

RUN apt update -y && \
apt install -y \
less \
curl \
bzip2 \
build-essential \
pkg-config

WORKDIR /build/x264

RUN curl -o x264.tar.bz2 "https://code.videolan.org/videolan/x264/-/archive/${X264_SHA}/x264-${X264_SHA}.tar.bz2"

RUN tar -jx --strip-components=1 -f x264.tar.bz2

WORKDIR /build/ffmpeg

RUN curl -L -o ffmpeg.tar.bz2 "https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2"

RUN tar -jx --strip-components=1 -f ffmpeg.tar.bz2

WORKDIR /build/x264

RUN ./configure \
--prefix="${PREFIX}" --enable-shared --enable-pic --disable-cli && \
make && \
make install

WORKDIR /build/ffmpeg

RUN ./configure \
--enable-gpl \
--enable-shared \
--disable-programs \
--enable-ffmpeg \
--disable-doc \
--disable-avdevice \
--disable-network \
--enable-pthreads \
--enable-ffmpeg \
--disable-avdevice \
--enable-avcodec \
--enable-avformat \
--enable-swresample \
--enable-swscale \
--enable-postproc \
--enable-avfilter \
--disable-encoders \
--enable-encoder=libx264 \
--enable-encoder=mjpeg \
--enable-encoder=pcm_s16le \
--disable-decoders \
--enable-decoder=aac \
--enable-decoder=h264 \
--disable-protocols \
--enable-protocol=file \
--disable-devices \
--enable-libx264 \
--disable-debug \
--extra-libs=-ldl \
--prefix="${PREFIX}" \
--extra-libs=-lpthread \
--extra-cflags="-I${PREFIX}/include" \
--extra-ldflags="-L${PREFIX}/lib" && \
make && \
make install

ENV LD_LIBRARY_PATH /opt/ffmpeg/lib:/usr/local/lib

RUN apt update -y && apt install -y cmake gdb
35 changes: 35 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp
{
"name": "ffmpeg",
"build": {
"dockerfile": "Dockerfile"
},

"containerEnv": {
"ARTIFACTORY_API_KEY": "${localEnv:ARTIFACTORY_API_KEY}"
},
"capAdd": ["SYS_PTRACE"],
"securityOpt": ["seccomp=unconfined"],

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
"settings": {},
"extensions": ["ms-vscode.cpptools", "ms-vscode.cmake-tools"]
}
}

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "gcc -v",

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ bunny_1s_gop.mp4.ts
bunny_1s_gop.mp4.webm
.vscode
.clangd
compile_commands.json
compile_commands.json

*.mp4
!small_bunny_1080p_60fps.mp4
13 changes: 7 additions & 6 deletions 0_hello_world.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ static void save_gray_frame(unsigned char *buf, int wrap, int xsize, int ysize,

int main(int argc, const char *argv[])
{
if (argc < 2) {
printf("You need to specify a media file.\n");
return -1;
char* filename = "/workspaces/ffmpeg-libav-tutorial/single-gop60.mp4";

if (argc >= 2) {
filename = argv[1];
}

logging("initializing all the containers, codecs and protocols.");
Expand All @@ -44,15 +45,15 @@ int main(int argc, const char *argv[])
return -1;
}

logging("opening the input file (%s) and loading format (container) header", argv[1]);
logging("opening the input file (%s) and loading format (container) header", filename);
// Open the file and read its header. The codecs are not opened.
// The function arguments are:
// AVFormatContext (the component we allocated memory for),
// url (filename),
// AVInputFormat (if you pass NULL it'll do the auto detect)
// and AVDictionary (which are options to the demuxer)
// http://ffmpeg.org/doxygen/trunk/group__lavf__decoding.html#ga31d601155e9035d5b0e7efedc894ee49
if (avformat_open_input(&pFormatContext, argv[1], NULL, NULL) != 0) {
if (avformat_open_input(&pFormatContext, filename, NULL, NULL) != 0) {
logging("ERROR could not open the file");
return -1;
}
Expand Down Expand Up @@ -127,7 +128,7 @@ int main(int argc, const char *argv[])
}

if (video_stream_index == -1) {
logging("File %s does not contain a video stream!", argv[1]);
logging("File %s does not contain a video stream!", filename);
return -1;
}

Expand Down
140 changes: 0 additions & 140 deletions 2_remuxing.c

This file was deleted.

Loading

0 comments on commit 823d964

Please sign in to comment.