ffenc two pass encoding for codecs other than libx264

This commit is contained in:
jeanlf
2022-02-23 12:12:06 +01:00
parent 418db4149a
commit e2696b6fd4
14 changed files with 81 additions and 14 deletions

View File

@@ -1,4 +1,10 @@
22/02/2022: GPAC 2.0
# On-going: GPAC 2.1-DEV
## Filters
- 2-pass encoding for FFmpeg codecs other than libx264
# 22/02/2022: GPAC 2.0
## Adaptive Streaming
- Low Latency HLS (LL-HLS, generation and playback)

View File

@@ -24,6 +24,8 @@
# GPAC Introduction
Current version: 2.1-DEV
Latest Release: 2.0
GPAC is an open-source multimedia framework focused on modularity and standards compliance.
@@ -128,7 +130,10 @@ Targets:
- [ ] User authentication for HTTP and RTSP servers
- [ ] DASH event support
- [ ] Web integration (emscripten, Remotery UI)
- [ ] Better TTML2 / SMPTE ST 2052-1 support
- [ ] configure buffer level per filter
- [ ] GUI cleanup ?
- [ ] deprecate `:filemode` in ROUTE

View File

@@ -35,7 +35,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.0</string>
<string>2.1-DEV</string>
<key>CFBundleSignature</key>
<string>gpac</string>
<key>CFBundleVersion</key>

View File

@@ -30,7 +30,7 @@ mv ftmp $source
# patch file gpac.spec
source="gpac.spec"
sed -e "s/Version:.*/Version: $version/;" $source | sed -e "s/Release:.*/Release: $version/;" | sed -e "s/Source0:.*/Source0: gpac-$version.tar.gz%{?_with_amr:Source1:http:\/\/www.3gpp.org\/ftp\/Specs\/archive\/26_series\/26.073\/26073-700.zip}/;" > ftmp
sed -e "s/Version:.*/Version: $version/;" $source | sed -e "s/Release:.*/Release: $version/;" | sed -e "s/Source0:.*/Source0: gpac-$version.tar.gz/;" > ftmp
rm $source
mv ftmp $source

2
debian/changelog vendored
View File

@@ -1,4 +1,4 @@
gpac (2.0) stable; urgency=low
gpac (2.1-DEV) stable; urgency=low
* Initial release - see https://github.com/gpac/gpac/releases for more details

View File

@@ -1,11 +1,11 @@
# $Id: gpac.spec,v 1.5 2008-12-02 18:04:42 jeanlf Exp $
Summary: Framework for production, encoding, delivery and interactive playback of multimedia content
Name: gpac
Version: 2.0
Release: 2.0
Version: 2.1-DEV
Release: 2.1-DEV
License: LGPL
Group: Applications/Multimedia
Source0: gpac-2.0.tar.gz
Source0: gpac-2.1-DEV.tar.gz
URL: http://gpac.io/
BuildRoot: %{_tmppath}/%{name}-root
Requires: SDL

View File

@@ -42,7 +42,7 @@
* SONAME versions must be digits (not strings)
*/
/*! Macro giving GPAC version name expressed as a printable string*/
#define GPAC_VERSION "2.0"
#define GPAC_VERSION "2.1-DEV"
// WARNING: when bumping, reflect the changes in share/python/libgpac.py !!
/*! ABI Major number of libgpac */

View File

@@ -1,6 +1,6 @@
;--------------------------------
;General
!define GPAC_VERSION 2.0
!define GPAC_VERSION 2.1-DEV
!include default.out
!define GPAC_ROOT ..\..\..

View File

@@ -9,7 +9,7 @@
<p style="text-align: center; Font-Size: 24pt">
<br/>
<b>GPAC Configuration file documentation
<br/>GPAC Version 2.0</b>
<br/>GPAC Version 2.1-DEV</b>
</p>
<br/><br/>

View File

@@ -7455,6 +7455,10 @@ When forcing a closed GOP boundary, the filter will flush, destroy and recreate
If .I fintra is not set and the output of the encoder is a DASH session in live profile without segment timeline, .I fintra will be set to the target segment duration and .I rc will be set.
.br
.br
The filter will look for property logpass on input PID to set 2-pass log filename, otherwise defaults to ffenc2pass-PID.log.
.br
.br
.SH Options (expert):
.LP
@@ -10057,7 +10061,7 @@ Authors: GPAC developers, see git repo history (-log)
.br
For bug reports, feature requests, more information and source code, visit https://github.com/gpac/gpac
.br
build: 1.1.0-DEV-rev1777-gb91a8dad3-master
build: 2.1-DEV-rev0-g418db4149-master
.br
Copyright: (c) 2000-2022 Telecom Paris distributed under LGPL v2.1+ - http://gpac.io
.br

View File

@@ -4591,7 +4591,7 @@ Authors: GPAC developers, see git repo history (-log)
.br
For bug reports, feature requests, more information and source code, visit https://github.com/gpac/gpac
.br
build: 1.1.0-DEV-rev1777-gb91a8dad3-master
build: 2.1-DEV-rev0-g418db4149-master
.br
Copyright: (c) 2000-2022 Telecom Paris distributed under LGPL v2.1+ - http://gpac.io
.br

View File

@@ -2835,7 +2835,7 @@ Authors: GPAC developers, see git repo history (-log)
.br
For bug reports, feature requests, more information and source code, visit https://github.com/gpac/gpac
.br
build: 1.1.0-DEV-rev1777-gb91a8dad3-master
build: 2.1-DEV-rev0-g418db4149-master
.br
Copyright: (c) 2000-2022 Telecom Paris distributed under LGPL v2.1+ - http://gpac.io
.br

View File

@@ -257,7 +257,7 @@ Authors: GPAC developers, see git repo history (-log)
.br
For bug reports, feature requests, more information and source code, visit https://github.com/gpac/gpac
.br
build: 1.1.0-DEV-rev1777-gb91a8dad3-master
build: 2.1-DEV-rev0-g418db4149-master
.br
Copyright: (c) 2000-2022 Telecom Paris distributed under LGPL v2.1+ - http://gpac.io
.br

View File

@@ -134,6 +134,8 @@ typedef struct _gf_ffenc_ctx
#endif
u32 premul_timescale;
FILE *logfile_pass1;
} GF_FFEncodeCtx;
static GF_Err ffenc_configure_pid_ex(GF_Filter *filter, GF_FilterPid *pid, Bool is_remove, Bool is_force_reconf);
@@ -214,6 +216,13 @@ static void ffenc_finalize(GF_Filter *filter)
av_packet_free(&ctx->pkt);
#endif
if (ctx->logfile_pass1) {
if (ctx->encoder->stats_out) fprintf(ctx->logfile_pass1, "%s", ctx->encoder->stats_out);
gf_fclose(ctx->logfile_pass1);
}
if (ctx->encoder->stats_in)
gf_free(ctx->encoder->stats_in);
if (ctx->encoder) {
avcodec_free_context(&ctx->encoder);
}
@@ -1705,6 +1714,47 @@ static GF_Err ffenc_configure_pid_ex(GF_Filter *filter, GF_FilterPid *pid, Bool
if (codec->capabilities & AV_CODEC_CAP_AUTO_THREADS)
ctx->encoder->thread_count = 0;
//setup 2 pass encoding
if (ctx->encoder->flags & (AV_CODEC_FLAG_PASS1|AV_CODEC_FLAG_PASS2)) {
char szLogFile[GF_MAX_PATH];
const GF_PropertyValue *p = gf_filter_pid_get_property_str(pid, "logpass");
if (p && (p->type==GF_PROP_STRING) && p->value.string) {
sprintf(szLogFile, "%s", p->value.string);
} else {
u32 id=0;
p = gf_filter_pid_get_property(pid, GF_PROP_PID_ID);
if (p) id = p->value.uint;
sprintf(szLogFile, "ffenc2pass-%d.log", id);
}
if (ctx->rc) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CODEC, ("[FFEnc] Multi-pass encoding not compatible with `rc`, disabling reset coder flag\n", szLogFile));
ctx->rc = 0;
}
if (!strcmp(codec->name, "libx264")) {
av_dict_set(&options, "stats", szLogFile, AV_DICT_DONT_OVERWRITE);
} else {
if (ctx->encoder->flags & AV_CODEC_FLAG_PASS2) {
u32 len=0;
GF_Err e = gf_file_load_data(szLogFile, (u8**) &ctx->encoder->stats_in, &len);
if (!e && !gf_utf8_is_legal(ctx->encoder->stats_in, len)) {
e = GF_NON_COMPLIANT_BITSTREAM;
}
if (e) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODEC, ("[FFEnc] Error reading log file %s for pass-2 encoding: %s\n", szLogFile, gf_error_to_string(e) ));
if (ctx->encoder->stats_in) gf_free(ctx->encoder->stats_in);
return e;
}
}
if (ctx->encoder->flags & AV_CODEC_FLAG_PASS1) {
FILE *f = gf_fopen(szLogFile, "w");
if (!f) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODEC, ("[FFEnc] Error opening log file %s for pass-1 encoding\n", szLogFile));
return GF_IO_ERR;
}
ctx->logfile_pass1 = f;
}
}
}
av_dict_copy(&options, ctx->options, 0);
res = avcodec_open2(ctx->encoder, codec, &options );
@@ -1849,6 +1899,8 @@ GF_FilterRegister FFEncodeRegister = {
"\n"
"When forcing a closed GOP boundary, the filter will flush, destroy and recreate the encoder to make sure a clean context is used, as currently many encoders in libavcodec do not support clean reset when forcing picture types.\n"
"If [-fintra]() is not set and the output of the encoder is a DASH session in live profile without segment timeline, [-fintra]() will be set to the target segment duration and [-rc]() will be set.\n"
"\n"
"The filter will look for property `logpass` on input PID to set 2-pass log filename, otherwise defaults to `ffenc2pass-PID.log`.\n"
)
.private_size = sizeof(GF_FFEncodeCtx),
SETCAPS(FFEncodeCaps),