Skip to content

Commit b919a15

Browse files
Merge pull request #312 from avTranscoder/dev/support_ffmpeg_4
FFmpeg 4.* support
2 parents f8b8e8f + b49c7c0 commit b919a15

26 files changed

+335
-205
lines changed

.travis.yml

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,28 @@ env:
2525
- DEPENDENCY_LOG_FILE=${TRAVIS_BUILD_DIR}/build-dependencies-log.txt
2626

2727
- YASM_VERSION=1.3.0
28-
- LAME_VERSION=3.99.5
29-
- FAAC_VERSION=1.28
28+
- LAME_VERSION=3.100
29+
# - FAAC_VERSION=1.28
3030
- XVID_VERSION=1.3.3
31-
- FDKAAC_VERSION=0.1.3
31+
# - FDKAAC_VERSION=0.1.3
3232
- OGG_VERSION=1.3.2
33-
- VORBIS_VERSION=1.3.4
34-
- THEORA_VERSION=1.1.1
33+
- VORBIS_VERSION=1.3.6
34+
# - THEORA_VERSION=1.1.1
3535
- VPX_VERSION=1.4.0
3636
matrix:
37-
- DEPENDENCY_NAME=libav DEPENDENCY_VERSION=11.3 ENABLE_COVERAGE=true
38-
- DEPENDENCY_NAME=libav DEPENDENCY_VERSION=11.3 ENABLE_COVERAGE=false
39-
- DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.4.2 ENABLE_COVERAGE=true
40-
- DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.4.2 ENABLE_COVERAGE=false
41-
- DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.5.7 ENABLE_COVERAGE=false
42-
- DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.6.8 ENABLE_COVERAGE=false
43-
- DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.7.6 ENABLE_COVERAGE=false
44-
- DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.8.6 ENABLE_COVERAGE=false
37+
# - DEPENDENCY_NAME=libav DEPENDENCY_VERSION=11.12 ENABLE_COVERAGE=true
38+
# - DEPENDENCY_NAME=libav DEPENDENCY_VERSION=11.12 ENABLE_COVERAGE=false
39+
# - DEPENDENCY_NAME=libav DEPENDENCY_VERSION=12.3 ENABLE_COVERAGE=true
40+
# - DEPENDENCY_NAME=libav DEPENDENCY_VERSION=12.3 ENABLE_COVERAGE=false
41+
# - DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.4.2 ENABLE_COVERAGE=true
42+
# - DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.4.2 ENABLE_COVERAGE=false
43+
# - DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.5.7 ENABLE_COVERAGE=false
44+
# - DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.6.8 ENABLE_COVERAGE=false
45+
# - DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.7.6 ENABLE_COVERAGE=false
46+
# - DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.8.6 ENABLE_COVERAGE=false
47+
# - DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=4.0 ENABLE_COVERAGE=false
48+
- DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=4.1 ENABLE_COVERAGE=false
49+
- DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=4.2 ENABLE_COVERAGE=true
4550

4651
matrix:
4752
exclude:
@@ -57,6 +62,7 @@ matrix:
5762
env: DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.4.2 ENABLE_COVERAGE=true
5863
allow_failures:
5964
# build with libav
65+
- os: osx
6066
- env: DEPENDENCY_NAME=libav DEPENDENCY_VERSION=11.3 ENABLE_COVERAGE=true
6167
- env: DEPENDENCY_NAME=libav DEPENDENCY_VERSION=11.3 ENABLE_COVERAGE=false
6268
# build with ffmpeg-2.8.6
@@ -75,8 +81,10 @@ addons:
7581
packages:
7682
- cmake
7783
- swig
78-
- python-dev
79-
- python-nose
84+
- python3-dev
85+
- python3
86+
- python3-nose
87+
- python3-coverage
8088
- freeglut3-dev
8189

8290
cache:

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ cmake_minimum_required(VERSION 2.8.11)
22

33
project(AvTranscoder)
44

5+
# All libraries will be put in INSTALL_PREFIX/lib
6+
# RPATH of host points INSTALL_PREFIX/lib
7+
# see: http://www.cmake.org/Wiki/CMake_RPATH_handling
8+
set(CMAKE_MACOSX_RPATH 1)
9+
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
10+
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
11+
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
12+
13+
514
# Define AvTranscoder default path to profiles
615
add_definitions(-DAVTRANSCODER_DEFAULT_AVPROFILES="${CMAKE_INSTALL_PREFIX}/share/avprofiles")
716

appveyor.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ platform:
88
environment:
99
global:
1010
DEPENDENCY_NAME: ffmpeg
11-
DEPENDENCY_VERSION: 2.4.5
11+
DEPENDENCY_VERSION: 4.2.1
1212
DEPENDENCY_INSTALL_PATH: C:\ProgramData\install-dependency
1313
AVTRANSCODER_INSTALL_PATH: C:\projects\avtranscoder\build\install-avtranscoder
1414

@@ -25,10 +25,10 @@ install:
2525

2626
# Get the correct python version
2727
- ps: if($env:platform -eq 'x86') {
28-
$env:PYTHON = "C:\Python27";
28+
$env:PYTHON = "C:\Python35";
2929
}
3030
else {
31-
$env:PYTHON = "C:\Python27-x64";
31+
$env:PYTHON = "C:\Python35-x64";
3232
}
3333
# Prepend newly installed Python to the PATH of this build
3434
- cmd: set PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%
@@ -37,7 +37,7 @@ install:
3737
- "python --version"
3838
- "python -c \"import struct; print(struct.calcsize('P') * 8)\""
3939
# Upgrade to the latest version of pip to avoid it displaying warnings about it being out of date.
40-
- pip install --disable-pip-version-check --user --upgrade pip
40+
- "python -m pip install --disable-pip-version-check --user --upgrade pip"
4141

4242
# Install tests dependencies
4343
- pip install nose

src/AvTranscoder/encoder/VideoEncoder.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ void VideoEncoder::setupEncoder(const ProfileLoader::Profile& profile)
7777
if(profile.count(constants::avProfileProcessStat))
7878
{
7979
LOG_INFO("SetUp video encoder to compute statistics during process")
80+
#ifdef AV_CODEC_FLAG_PSNR
81+
encoderFlags |= AV_CODEC_FLAG_PSNR;
82+
#else
8083
encoderFlags |= CODEC_FLAG_PSNR;
84+
#endif
8185
}
8286
_codec.getAVCodecContext().flags |= encoderFlags;
8387
_codec.openCodec();

src/AvTranscoder/file/OutputFile.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,12 @@ IOutputStream::EWrappingStatus OutputFile::wrap(const CodedData& data, const siz
200200
packet.dts = av_rescale_q(data.getAVPacket().dts, srcTimeBase, dstTimeBase);
201201
}
202202
// add stream PTS if already incremented
203-
const int currentStreamPTS = _outputStreams.at(streamIndex)->getStreamPTS();
204-
if(packet.pts != AV_NOPTS_VALUE && packet.pts < currentStreamPTS)
205-
{
206-
packet.pts += currentStreamPTS;
207-
packet.dts += currentStreamPTS;
208-
}
203+
// const int currentStreamPTS = _outputStreams.at(streamIndex)->getStreamPTS();
204+
// if(packet.pts != AV_NOPTS_VALUE && packet.pts < currentStreamPTS)
205+
// {
206+
// packet.pts += currentStreamPTS;
207+
// packet.dts += currentStreamPTS;
208+
// }
209209
}
210210

211211
// copy duration of packet wrapped
@@ -332,11 +332,19 @@ void OutputFile::setOutputStream(AVStream& avStream, const ICodec& codec)
332332
// depending on the format, place global headers in extradata instead of every keyframe
333333
if(_formatContext.getAVOutputFormat().flags & AVFMT_GLOBALHEADER)
334334
{
335+
#ifdef AV_CODEC_FLAG_GLOBAL_HEADER
336+
avStream.codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
337+
#else
335338
avStream.codec->flags |= CODEC_FLAG_GLOBAL_HEADER;
339+
#endif
336340
}
337341

338342
// if the codec is experimental, allow it
343+
#ifdef AV_CODEC_CAP_EXPERIMENTAL
344+
if(codec.getAVCodec().capabilities & AV_CODEC_CAP_EXPERIMENTAL)
345+
#else
339346
if(codec.getAVCodec().capabilities & CODEC_CAP_EXPERIMENTAL)
347+
#endif
340348
{
341349
LOG_WARN("This codec is considered experimental by libav/ffmpeg:" << codec.getCodecName());
342350
avStream.codec->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;

src/AvTranscoder/filter/Filter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Filter::Filter(const std::string& name, const std::string& options, const std::s
1515
, _options(options)
1616
, _instanceName(instanceName.empty() ? name : instanceName)
1717
{
18-
_filter = avfilter_get_by_name(name.c_str());
18+
_filter = (AVFilter*)avfilter_get_by_name(name.c_str());
1919
if(!_filter)
2020
{
2121
std::string msg("Cannot find filter ");

src/AvTranscoder/properties/StreamProperties.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,13 @@ std::string StreamProperties::getCodecName() const
9393
if(!_codecContext || !_codec)
9494
throw std::runtime_error("unknown codec");
9595

96+
#ifdef AV_CODEC_CAP_TRUNCATED
97+
if(_codec->capabilities & AV_CODEC_CAP_TRUNCATED)
98+
_codecContext->flags |= AV_CODEC_FLAG_TRUNCATED;
99+
#else
96100
if(_codec->capabilities & CODEC_CAP_TRUNCATED)
97101
_codecContext->flags |= CODEC_FLAG_TRUNCATED;
102+
#endif
98103

99104
if(!_codec->name)
100105
throw std::runtime_error("unknown codec name");
@@ -107,9 +112,13 @@ std::string StreamProperties::getCodecLongName() const
107112
if(!_codecContext || !_codec)
108113
throw std::runtime_error("unknown codec");
109114

115+
#ifdef AV_CODEC_CAP_TRUNCATED
116+
if(_codec->capabilities & AV_CODEC_CAP_TRUNCATED)
117+
_codecContext->flags |= AV_CODEC_FLAG_TRUNCATED;
118+
#else
110119
if(_codec->capabilities & CODEC_CAP_TRUNCATED)
111120
_codecContext->flags |= CODEC_FLAG_TRUNCATED;
112-
121+
#endif
113122
if(!_codec->long_name)
114123
throw std::runtime_error("unknown codec long name");
115124

src/AvTranscoder/properties/VideoProperties.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,13 @@ std::string VideoProperties::getProfileName() const
6262
if(!_codecContext || !_codec)
6363
throw std::runtime_error("unknown codec");
6464

65+
#ifdef AV_CODEC_CAP_TRUNCATED
66+
if(_codec->capabilities & AV_CODEC_CAP_TRUNCATED)
67+
_codecContext->flags |= AV_CODEC_FLAG_TRUNCATED;
68+
#else
6569
if(_codec->capabilities & CODEC_CAP_TRUNCATED)
6670
_codecContext->flags |= CODEC_FLAG_TRUNCATED;
71+
#endif
6772

6873
const char* profile = NULL;
6974
if((profile = av_get_profile_name(_codec, getProfile())) == NULL)
@@ -427,7 +432,8 @@ size_t VideoProperties::getDtgActiveFormat() const
427432
{
428433
if(!_codecContext)
429434
throw std::runtime_error("unknown codec context");
430-
return _codecContext->dtg_active_format;
435+
// return _codecContext->dtg_active_format;
436+
return 0;
431437
}
432438

433439
size_t VideoProperties::getReferencesFrames() const

src/AvTranscoder/stream/OutputStream.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ OutputStream::OutputStream(OutputFile& outputFile, const size_t streamIndex)
2020

2121
float OutputStream::getStreamDuration() const
2222
{
23-
const AVFrac& outputPTS = _outputAVStream.pts;
2423
const AVRational& outputTimeBase = _outputAVStream.time_base;
2524

2625
// check floating point exception
27-
if(outputTimeBase.den == 0 || outputPTS.den == 0)
26+
if(outputTimeBase.den == 0)
2827
{
2928
LOG_WARN("Cannot compute stream duration of output stream at index " << _streamIndex)
3029
return 0.f;
@@ -36,7 +35,7 @@ float OutputStream::getStreamDuration() const
3635
// returns the pts of the last muxed packet, converted from timebase to seconds
3736
return av_q2d(outputTimeBase) * av_stream_get_end_pts(&_outputAVStream);
3837
#else
39-
return av_q2d(outputTimeBase) * (outputPTS.val + (outputPTS.num / outputPTS.den));
38+
return av_q2d(outputTimeBase) * _outputAVStream.pts;
4039
#endif
4140
}
4241

@@ -45,11 +44,12 @@ size_t OutputStream::getNbFrames() const
4544
return _outputAVStream.nb_frames;
4645
}
4746

48-
int OutputStream::getStreamPTS() const
49-
{
50-
const AVFrac& outputPTS = _outputAVStream.pts;
51-
return (outputPTS.val + (outputPTS.num / outputPTS.den));
52-
}
47+
// int OutputStream::getStreamPTS() const
48+
// {
49+
// // const AVFrac& outputPTS = _outputAVStream.pts;
50+
// // return (outputPTS.val + (outputPTS.num / outputPTS.den));
51+
// return _outputAVStream.pts;
52+
// }
5353

5454
IOutputStream::EWrappingStatus OutputStream::wrap(const CodedData& data)
5555
{

src/AvTranscoder/stream/OutputStream.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class AvExport OutputStream : public IOutputStream
1818
size_t getStreamIndex() const { return _streamIndex; }
1919
float getStreamDuration() const;
2020
size_t getNbFrames() const; ///< If audio stream, returns number of packets
21-
int getStreamPTS() const; ///< Get current AVStream PTS
21+
// int getStreamPTS() const; ///< Get current AVStream PTS
2222

2323
bool isPTSGenerated() const { return _isPTSGenerated; }
2424
IOutputStream::EWrappingStatus wrap(const CodedData& data);

0 commit comments

Comments
 (0)