master
wanggang 4 years ago
commit ad4fef766f

1
.gitignore vendored

@ -0,0 +1 @@
tmp

@ -0,0 +1,59 @@
#https://github.com/ksvc/FFmpeg/wiki/hevcpush
#https://github.com/runner365/ffmpeg_rtmp_h265
#https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
ARG BUILD_IMAGE=ubuntu:18.04
ARG IMAGE=ubuntu:18.04
FROM $BUILD_IMAGE as build
ARG BRANCH=release/4.1
ARG COMPILE_PACKAGES="autoconf automake build-essential cmake git-core libass-dev libfreetype6-dev libgnutls28-dev libtool libvorbis-dev meson ninja-build pkg-config texinfo wget yasm zlib1g-dev nasm checkinstall"
COPY ffmpeg/libavformat /ffmpeg/libavformat
RUN sed -i s/archive.ubuntu.com/mirrors.ustc.edu.cn/g /etc/apt/sources.list && \
sed -i s/security.ubuntu.com/mirrors.ustc.edu.cn/g /etc/apt/sources.list && \
apt update -y && \
apt install -y $COMPILE_PACKAGES && \
apt install -y \
libx264-dev \
libx265-dev libnuma-dev \
libfdk-aac-dev && \
rm -rf /var/lib/apt/lists/* && \
mkdir -p ~/ffmpeg_sources ~/bin && \
cd ~/ffmpeg_sources && \
git clone --depth=1 -b $BRANCH https://github.com/FFmpeg/FFmpeg.git ffmpeg && \
/bin/cp -rf /ffmpeg/libavformat/* /root/ffmpeg_sources/ffmpeg/libavformat && \
rm -rf /ffmpeg/libavformat &&\
cd ~/ffmpeg_sources && \
cd ffmpeg && \
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
--prefix="$HOME/ffmpeg_build" \
--pkg-config-flags="--static" \
--extra-cflags="-I$HOME/ffmpeg_build/include" \
--extra-ldflags="-L$HOME/ffmpeg_build/lib" \
--extra-libs="-lpthread -lm" \
--ld="g++" \
--bindir="$HOME/bin" \
--enable-static --enable-pic \
--disable-encoders --enable-encoder=aac --enable-encoder=libx264 --enable-gpl --enable-libx264 --enable-encoder=libx265 --enable-libx265 \
--disable-decoders --enable-decoder=aac --enable-decoder=h264 --enable-decoder=hevc \
--disable-demuxers --enable-demuxer=aac --enable-demuxer=mov --enable-demuxer=mpegts --enable-demuxer=flv --enable-demuxer=h264 --enable-demuxer=hevc --enable-demuxer=hls \
--disable-muxers --enable-muxer=h264 --enable-muxer=flv --enable-muxer=f4v --enable-muxer=mp4 \
--disable-doc && \
PATH="$HOME/bin:$PATH" make && checkinstall && hash -r && \
mv ~/bin/ffmpeg /usr/local/bin && \
rm -rf ~/ffmpeg_build ~/ffmpeg_sources ~/bin/{ffmpeg,ffprobe,ffplay,x264,x265,nasm} && \
apt purge -y $COMPILE_PACKAGES nasm checkinstall && apt clean && apt autoclean
FROM $IMAGE
LABEL org.opencontainers.image.authors="76527413@qq.com"
COPY --from=build /usr/local/bin/ffmpeg /usr/local/bin
RUN sed -i s/archive.ubuntu.com/mirrors.ustc.edu.cn/g /etc/apt/sources.list && \
sed -i s/security.ubuntu.com/mirrors.ustc.edu.cn/g /etc/apt/sources.list && \
apt update -y && \
apt install -y \
libx264-dev \
libx265-dev libnuma-dev \
libfdk-aac-dev && \
rm -rf /var/lib/apt/lists/* && \
echo "/usr/local/lib" > /etc/ld.so.conf.d/libc.conf

@ -0,0 +1,64 @@
ARG BUILD_IMAGE=arm64v8/ubuntu:18.04
ARG IMAGE=arm64v8/ubuntu:18.04
FROM multiarch/qemu-user-static:x86_64-aarch64 as qemu
FROM $BUILD_IMAGE as build
ARG BRANCH=release/4.1
ARG COMPILE_PACKAGES="autoconf automake build-essential cmake git-core libass-dev libfreetype6-dev libgnutls28-dev libtool libvorbis-dev meson ninja-build pkg-config texinfo wget yasm zlib1g-dev nasm checkinstall"
COPY ffmpeg/libavformat /ffmpeg/libavformat
COPY --from=qemu /usr/bin/qemu-aarch64-static /usr/bin
RUN sed -i s/ports.ubuntu.com/mirrors.ustc.edu.cn/g /etc/apt/sources.list && \
apt update -y && \
apt install -y $COMPILE_PACKAGES && \
apt install -y \
libx264-dev \
libx265-dev libnuma-dev \
libfdk-aac-dev && \
rm -rf /var/lib/apt/lists/* && \
mkdir -p ~/ffmpeg_sources ~/bin && \
cd ~/ffmpeg_sources && \
git clone --depth=1 -b $BRANCH https://github.com/FFmpeg/FFmpeg.git ffmpeg && \
/bin/cp -rf /ffmpeg/libavformat/* /root/ffmpeg_sources/ffmpeg/libavformat && \
rm -rf /ffmpeg/libavformat &&\
cd ~/ffmpeg_sources && \
cd ffmpeg && \
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
--prefix="$HOME/ffmpeg_build" \
--pkg-config-flags="--static" \
--extra-cflags="-I$HOME/ffmpeg_build/include" \
--extra-ldflags="-L$HOME/ffmpeg_build/lib" \
--extra-libs="-lpthread -lm" \
--ld="g++" \
--bindir="$HOME/bin" \
--enable-static --enable-pic \
--disable-encoders --enable-encoder=aac --enable-encoder=libx264 --enable-gpl --enable-libx264 --enable-encoder=libx265 --enable-libx265 \
--disable-decoders --enable-decoder=aac --enable-decoder=h264 --enable-decoder=hevc \
--disable-demuxers --enable-demuxer=aac --enable-demuxer=mov --enable-demuxer=mpegts --enable-demuxer=flv --enable-demuxer=h264 --enable-demuxer=hevc --enable-demuxer=hls \
--disable-muxers --enable-muxer=h264 --enable-muxer=flv --enable-muxer=f4v --enable-muxer=mp4 \
--disable-doc && \
PATH="$HOME/bin:$PATH" make && checkinstall && hash -r && \
mv ~/bin/ffmpeg /usr/local/bin && \
rm -rf ~/ffmpeg_build ~/ffmpeg_sources ~/bin/{ffmpeg,ffprobe,ffplay,x264,x265,nasm} && \
apt purge -y $COMPILE_PACKAGES nasm checkinstall && apt clean && apt autoclean
WORKDIR /root/bin
# CMD ["--help"]
# ENTRYPOINT ["ffmpeg"]
FROM $IMAGE
COPY --from=qemu /usr/bin/qemu-aarch64-static /usr/bin
LABEL org.opencontainers.image.authors="76527413@qq.com"
COPY --from=build /usr/local/bin/ffmpeg /usr/local/bin
RUN sed -i s/ports.ubuntu.com/mirrors.ustc.edu.cn/g /etc/apt/sources.list && \
apt update -y && \
apt install -y \
libx264-dev \
libx265-dev libnuma-dev \
libfdk-aac-dev && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /usr/bin/qemu-aarch64-static && \
echo "/usr/local/lib" > /etc/ld.so.conf.d/libc.conf

@ -0,0 +1,3 @@
docker build --progress=plain -t 76527413/ffmpeg:amd64 .
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker build --progress=plain -f Dockerfile.arm64 -t 76527413/ffmpeg:arm64 .

@ -0,0 +1,33 @@
#https://github.com/tsingsee/EasyPlayer.js http://127.0.0.1:8080/live/h265.flv
#https://github.com/ksvc/h265webplayer
version: "3.8"
services:
srs:
image: 76527413/srs:h265
environment:
- CANDIDATE=*
ports:
- 1935:1935
- 8080:8080
- 1985:1985
- 8000:8000/udp
ffmpeg-h264:
image: 76527413/ffmpeg:amd64
volumes:
- ./h264.mp4:/test.mp4
command: ffmpeg -y -re -stream_loop -1 -i test.mp4 -c:a copy -c:v copy -f flv rtmp://srs/live/h264
depends_on:
- srs
ffmpeg-265:
image: 76527413/ffmpeg:amd64
volumes:
- ./h265.mp4:/test.mp4
command: ffmpeg -y -re -stream_loop -1 -i test.mp4 -c:a copy -c:v copy -f flv rtmp://srs/live/h265
depends_on:
- srs
nginx:
image: nginx:1.21.0
ports:
- 80:80
volumes:
- ./html:/usr/share/nginx/html

@ -0,0 +1,140 @@
/*
* FLV common header
*
* Copyright (c) 2006 The FFmpeg Project
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* FLV common header
*/
#ifndef AVFORMAT_FLV_H
#define AVFORMAT_FLV_H
/* offsets for packed values */
#define FLV_AUDIO_SAMPLESSIZE_OFFSET 1
#define FLV_AUDIO_SAMPLERATE_OFFSET 2
#define FLV_AUDIO_CODECID_OFFSET 4
#define FLV_VIDEO_FRAMETYPE_OFFSET 4
/* bitmasks to isolate specific values */
#define FLV_AUDIO_CHANNEL_MASK 0x01
#define FLV_AUDIO_SAMPLESIZE_MASK 0x02
#define FLV_AUDIO_SAMPLERATE_MASK 0x0c
#define FLV_AUDIO_CODECID_MASK 0xf0
#define FLV_VIDEO_CODECID_MASK 0x0f
#define FLV_VIDEO_FRAMETYPE_MASK 0xf0
#define AMF_END_OF_OBJECT 0x09
#define KEYFRAMES_TAG "keyframes"
#define KEYFRAMES_TIMESTAMP_TAG "times"
#define KEYFRAMES_BYTEOFFSET_TAG "filepositions"
enum {
FLV_HEADER_FLAG_HASVIDEO = 1,
FLV_HEADER_FLAG_HASAUDIO = 4,
};
enum FlvTagType {
FLV_TAG_TYPE_AUDIO = 0x08,
FLV_TAG_TYPE_VIDEO = 0x09,
FLV_TAG_TYPE_META = 0x12,
};
enum {
FLV_STREAM_TYPE_VIDEO,
FLV_STREAM_TYPE_AUDIO,
FLV_STREAM_TYPE_DATA,
FLV_STREAM_TYPE_NB,
};
enum {
FLV_MONO = 0,
FLV_STEREO = 1,
};
enum {
FLV_SAMPLESSIZE_8BIT = 0,
FLV_SAMPLESSIZE_16BIT = 1 << FLV_AUDIO_SAMPLESSIZE_OFFSET,
};
enum {
FLV_SAMPLERATE_SPECIAL = 0, /**< signifies 5512Hz and 8000Hz in the case of NELLYMOSER */
FLV_SAMPLERATE_11025HZ = 1 << FLV_AUDIO_SAMPLERATE_OFFSET,
FLV_SAMPLERATE_22050HZ = 2 << FLV_AUDIO_SAMPLERATE_OFFSET,
FLV_SAMPLERATE_44100HZ = 3 << FLV_AUDIO_SAMPLERATE_OFFSET,
};
enum {
FLV_CODECID_PCM = 0,
FLV_CODECID_ADPCM = 1 << FLV_AUDIO_CODECID_OFFSET,
FLV_CODECID_MP3 = 2 << FLV_AUDIO_CODECID_OFFSET,
FLV_CODECID_PCM_LE = 3 << FLV_AUDIO_CODECID_OFFSET,
FLV_CODECID_NELLYMOSER_16KHZ_MONO = 4 << FLV_AUDIO_CODECID_OFFSET,
FLV_CODECID_NELLYMOSER_8KHZ_MONO = 5 << FLV_AUDIO_CODECID_OFFSET,
FLV_CODECID_NELLYMOSER = 6 << FLV_AUDIO_CODECID_OFFSET,
FLV_CODECID_PCM_ALAW = 7 << FLV_AUDIO_CODECID_OFFSET,
FLV_CODECID_PCM_MULAW = 8 << FLV_AUDIO_CODECID_OFFSET,
FLV_CODECID_OPUS = 9 << FLV_AUDIO_CODECID_OFFSET,
FLV_CODECID_AAC = 10<< FLV_AUDIO_CODECID_OFFSET,
FLV_CODECID_SPEEX = 11<< FLV_AUDIO_CODECID_OFFSET,
};
enum {
FLV_CODECID_H263 = 2,
FLV_CODECID_SCREEN = 3,
FLV_CODECID_VP6 = 4,
FLV_CODECID_VP6A = 5,
FLV_CODECID_SCREEN2 = 6,
FLV_CODECID_H264 = 7,
FLV_CODECID_REALH263= 8,
FLV_CODECID_MPEG4 = 9,
FLV_CODECID_HEVC = 12,
};
enum {
FLV_FRAME_KEY = 1 << FLV_VIDEO_FRAMETYPE_OFFSET, ///< key frame (for AVC, a seekable frame)
FLV_FRAME_INTER = 2 << FLV_VIDEO_FRAMETYPE_OFFSET, ///< inter frame (for AVC, a non-seekable frame)
FLV_FRAME_DISP_INTER = 3 << FLV_VIDEO_FRAMETYPE_OFFSET, ///< disposable inter frame (H.263 only)
FLV_FRAME_GENERATED_KEY = 4 << FLV_VIDEO_FRAMETYPE_OFFSET, ///< generated key frame (reserved for server use only)
FLV_FRAME_VIDEO_INFO_CMD = 5 << FLV_VIDEO_FRAMETYPE_OFFSET, ///< video info/command frame
};
typedef enum {
AMF_DATA_TYPE_NUMBER = 0x00,
AMF_DATA_TYPE_BOOL = 0x01,
AMF_DATA_TYPE_STRING = 0x02,
AMF_DATA_TYPE_OBJECT = 0x03,
AMF_DATA_TYPE_NULL = 0x05,
AMF_DATA_TYPE_UNDEFINED = 0x06,
AMF_DATA_TYPE_REFERENCE = 0x07,
AMF_DATA_TYPE_MIXEDARRAY = 0x08,
AMF_DATA_TYPE_OBJECT_END = 0x09,
AMF_DATA_TYPE_ARRAY = 0x0a,
AMF_DATA_TYPE_DATE = 0x0b,
AMF_DATA_TYPE_LONG_STRING = 0x0c,
AMF_DATA_TYPE_UNSUPPORTED = 0x0d,
} AMFDataType;
#endif /* AVFORMAT_FLV_H */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

@ -0,0 +1,7 @@
#!/bin/bash
TAG=$GIT_BRANCH.$DOCKER_TAG
VERSION=4.0
for tag in {$TAG.$VERSION,$TAG.$(git rev-parse --short HEAD),$TAG.$(date -u +"%Y-%m-%dT%H-%M-%SZ")}; do
docker tag $IMAGE_NAME $DOCKER_REPO:$tag
docker push $DOCKER_REPO:$tag
done

@ -0,0 +1,4 @@
#!/bin/bash
if [ $DOCKER_TAG = arm64 ]; then
docker run --rm --privileged multiarch/qemu-user-static:register --reset
fi

File diff suppressed because one or more lines are too long

@ -0,0 +1,66 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>EasyWasmPlayer</title>
<script src="./EasyWasmPlayer.js"></script>
</head>
<body>
<div style="text-align: center;">
<div style="width:540px;height: 1170px; background-color:pink;margin: auto;display: inline-block;">
<div id="newplay1" onClick="onplay"></div>
<input type="text" id="value1" value="http://127.0.0.1:8080/live/h264.flv"
style="width: 80%;box-sizing: border-box;">
<button id="btn1" style="width: 18%;box-sizing: border-box;">播放</button>
</div>
<div style="width:540px;height: 1170px; background-color:pink;margin: auto;display: inline-block;">
<div id="newplay2" onClick="onplay"></div>
<input type="text" id="value2" value="http://127.0.0.1:8080/live/h265.flv"
style="width: 80%;box-sizing: border-box;">
<button id="btn2" style="width: 18%;box-sizing: border-box;">播放</button>
</div>
</div>
<script>
document.getElementById('value1').value=location.protocol + "//" +location.host + ":8080" +"/live/h264.flv";
document.getElementById('value2').value=location.protocol + "//" +location.host + ":8080" +"/live/h265.flv";
callbackfun = function (e) {
//console.log(e);
}
var player1;
var player2;
function play1() {
if (player1) {
player1.destroy();
}
player1 = new WasmPlayer(null, 'newplay1', callbackfun, {
Height: true
});
var url = document.getElementById('value1').value;
player1.play(url, 1);
}
btn1.onclick = function () {
play1();
}
function play2() {
if (player2) {
player2.destroy();
}
player2 = new WasmPlayer(null, 'newplay2', callbackfun, {
Height: true
});
var url = document.getElementById('value2').value;
player2.play(url, 1);
}
btn2.onclick = function () {
play2();
}
play1();
play2();
</script>
</body>
</html>

Binary file not shown.
Loading…
Cancel
Save