Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add patches #2

Merged
merged 2 commits into from
Jun 15, 2024
Merged
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
16 changes: 16 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM ubuntu:20.04

# Avoid warnings by switching to noninteractive
ENV DEBIAN_FRONTEND=noninteractive

# Configure apt and install packages
RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
&& apt-get -y install git iproute2 procps lsb-release \
&& apt-get -y install nasm build-essential gdb \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

# Switch back to dialog for any ad-hoc use of apt-get
ENV DEBIAN_FRONTEND=dialog
16 changes: 16 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "FFmpeg Dev Container",
"dockerFile": "Dockerfile",
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": [
"ms-vscode.cpptools-extension-pack",
"foxundermoon.shell-format"
]
}
},
"forwardPorts": []
}
13 changes: 13 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ name: Build FFmpeg

on:
workflow_dispatch:
inputs:
doRelease:
description: 'Publish new release'
type: boolean
default: false
required: false
buildOnly:
description: 'Only build ffmpeg'
type: boolean
default: false
required: false

jobs:
build:
Expand Down Expand Up @@ -103,6 +114,8 @@ jobs:
path: ./ffmpeg*

publish_release:
name: Publish release
if: ${{ !cancelled() && github.event.inputs.doRelease == true && needs.build.result == 'success' }}
needs: build
runs-on: ubuntu-latest
steps:
Expand Down
33 changes: 33 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug ffmpeg",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/ffmpeg_g",
"args": [
"-i",
"xlive/split-test2.flv",
// "xlive/standard.flv",
"-c",
"copy",
"xlive/out4.mp4"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "build ffmpeg linux x64 if not exist"
}
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.formatOnSave": false
}
16 changes: 16 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build ffmpeg linux x64 if not exist",
"type": "shell",
"command": [
"./xlive/build.sh"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
1 change: 1 addition & 0 deletions libavformat/flv.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ enum {
FLV_CODECID_H264 = 7,
FLV_CODECID_REALH263= 8,
FLV_CODECID_MPEG4 = 9,
FLV_CODECID_HEVC = 12,
};

enum {
Expand Down
14 changes: 13 additions & 1 deletion libavformat/flvdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ static int flv_same_video_codec(AVCodecParameters *vpar, uint32_t flv_codecid)

switch (flv_codecid) {
case MKBETAG('h', 'v', 'c', '1'):
case FLV_CODECID_HEVC:
return vpar->codec_id == AV_CODEC_ID_HEVC;
case MKBETAG('a', 'v', '0', '1'):
return vpar->codec_id == AV_CODEC_ID_AV1;
Expand Down Expand Up @@ -342,6 +343,7 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream,

switch (flv_codecid) {
case MKBETAG('h', 'v', 'c', '1'):
case FLV_CODECID_HEVC:
par->codec_id = AV_CODEC_ID_HEVC;
vstreami->need_parsing = AVSTREAM_PARSE_HEADERS;
break;
Expand Down Expand Up @@ -1288,7 +1290,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
}

if (st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_MPEG4 ||
(st->codecpar->codec_id == AV_CODEC_ID_HEVC && type == PacketTypeCodedFrames)) {
(st->codecpar->codec_id == AV_CODEC_ID_HEVC && (!enhanced_flv || type == PacketTypeCodedFrames))) {
// sign extension
int32_t cts = (avio_rb24(s->pb) + 0xff800000) ^ 0xff800000;
pts = av_sat_add64(dts, cts);
Expand All @@ -1309,6 +1311,16 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
st->codecpar->codec_id == AV_CODEC_ID_AV1 || st->codecpar->codec_id == AV_CODEC_ID_VP9)) {
AVDictionaryEntry *t;

// abort program when meeting the second sequence header
if (stream_type == FLV_STREAM_TYPE_VIDEO) {
static int s_video_header_count = 0;
++s_video_header_count;
if (s_video_header_count > 1) {
av_log(s, AV_LOG_FATAL, "[xlive]EOF new sps pps\n");
return -1;
}
}

if (st->codecpar->extradata) {
if ((ret = flv_queue_extradata(flv, s->pb, stream_type, size)) < 0)
return ret;
Expand Down
3 changes: 3 additions & 0 deletions xlive/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.formatOnSave": true
}
37 changes: 37 additions & 0 deletions xlive/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

if [ ! -f "./ffmpeg" ]; then
./configure \
--disable-everything \
--disable-autodetect \
--disable-encoders \
--disable-decoders \
--enable-decoder='h264,aac,hevc' \
--enable-encoder='aac,libx265' \
--enable-parser='h264,aac,mp3' \
--enable-demuxer='flv,h264,aac,mp3,live_flv' \
--enable-muxer='flv,mp4' \
--enable-protocol='file,pipe' \
--enable-bsf='h264_mp4toannexb,aac_adtstoasc' \
--disable-avdevice \
--disable-swscale \
--disable-postproc \
--disable-doc \
--disable-runtime-cpudetect \
--disable-network \
--enable-gpl \
--enable-version3 \
--enable-avcodec \
--enable-avformat \
--enable-swresample \
--enable-avfilter \
--disable-programs \
--enable-ffmpeg \
--enable-debug=3 \
--disable-optimizations \
--enable-pthreads \
--pkg-config=pkg-config \
--disable-stripping

make -j$(nproc)
fi