Skip to content

Commit 0f285b2

Browse files
committed
Merge pull request #201 from cchampet/dev_addTestsForProcessStat
Added pyTests to check ProcessStat Appveyor: up ffmpeg version to v2.4.5
2 parents 6419a2d + c488619 commit 0f285b2

18 files changed

+234
-60
lines changed

INSTALL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ AvTranscoder uses CMake as build system.
44

55
#### Dependencies
66
AvTranscoder can depend on ffmpeg, libav, or any fork of these projects that follow the same API.
7-
* Recommended ffmpeg versions: 2.2.11, 2.4.2, 2.5.7
7+
* Recommended ffmpeg versions: 2.4.2, 2.4.5, 2.5.7
88
* Recommended libav versions: 11.3
99

1010
#### To build

appveyor.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ platform:
55
- x86
66
# - x64
77

8+
environment:
9+
FFMPEG_VERSION: 2.4.5
10+
811
matrix:
912
fast_finish: true
1013

src/AvTranscoder/file/InputFile.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@ namespace avtranscoder
2222

2323
InputFile::InputFile(const std::string& filename)
2424
: _formatContext(filename, AV_OPT_FLAG_DECODING_PARAM)
25-
, _properties(_formatContext)
25+
, _properties(NULL)
2626
, _filename(filename)
2727
, _inputStreams()
2828
{
29+
// Fill the FormatContext with the stream information
2930
_formatContext.findStreamInfo();
3031

32+
// Get the stream information as properties
33+
_properties = new FileProperties(_formatContext);
34+
3135
// Create streams
3236
for(size_t streamIndex = 0; streamIndex < _formatContext.getNbStreams(); ++streamIndex)
3337
{
@@ -37,6 +41,7 @@ InputFile::InputFile(const std::string& filename)
3741

3842
InputFile::~InputFile()
3943
{
44+
delete _properties;
4045
for(std::vector<InputStream*>::iterator it = _inputStreams.begin(); it != _inputStreams.end(); ++it)
4146
{
4247
delete(*it);
@@ -45,7 +50,7 @@ InputFile::~InputFile()
4550

4651
void InputFile::analyse(IProgress& progress, const EAnalyseLevel level)
4752
{
48-
_properties.extractStreamProperties(progress, level);
53+
_properties->extractStreamProperties(progress, level);
4954
}
5055

5156
FileProperties InputFile::analyseFile(const std::string& filename, IProgress& progress, const EAnalyseLevel level)
@@ -160,8 +165,8 @@ std::string InputFile::getFormatMimeType() const
160165
double InputFile::getFps()
161166
{
162167
double fps = 1;
163-
if(_properties.getNbVideoStreams())
164-
fps = _properties.getVideoProperties().at(0).getFps();
168+
if(_properties->getNbVideoStreams())
169+
fps = _properties->getVideoProperties().at(0).getFps();
165170
return fps;
166171
}
167172

src/AvTranscoder/file/InputFile.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class AvExport InputFile
6868
* @note require to launch analyse() before to fill the property struture
6969
* @return structure of media metadatas
7070
**/
71-
const FileProperties& getProperties() const { return _properties; }
71+
const FileProperties& getProperties() const { return *_properties; }
7272

7373
/**
7474
* @brief Get stream type: video, audio, subtitle, etc.
@@ -121,7 +121,7 @@ class AvExport InputFile
121121

122122
protected:
123123
FormatContext _formatContext;
124-
FileProperties _properties;
124+
FileProperties* _properties;
125125
std::string _filename;
126126
std::vector<InputStream*> _inputStreams; ///< Has ownership
127127
};

src/AvTranscoder/stat/AudioStat.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ class AvExport AudioStat
1919
}
2020

2121
public:
22+
float getDuration() const { return _duration; }
23+
size_t getNbPackets() const { return _nbPackets; }
24+
25+
private:
2226
float _duration;
2327
size_t _nbPackets;
2428
};

src/AvTranscoder/stat/VideoStat.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
namespace avtranscoder
66
{
77

8-
double VideoStat::psnr(const double d)
8+
double VideoStat::toPSNR(const double mse)
99
{
10-
return -10.0 * log10(d);
10+
return -10.0 * log10(mse);
1111
}
1212
}

src/AvTranscoder/stat/VideoStat.hpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,18 @@ class AvExport VideoStat
2121
}
2222

2323
public:
24-
static double psnr(const double d);
24+
float getDuration() const { return _duration; }
25+
size_t getNbFrames() const { return _nbFrames; }
26+
size_t getQuality() const { return _quality; }
27+
double getPSNR() const { return _psnr; }
2528

26-
public:
29+
void setQuality(const size_t quality) { _quality = quality; }
30+
void setPSNR(const double mse) { _psnr = VideoStat::toPSNR(mse); }
31+
32+
private:
33+
static double toPSNR(const double mse);
34+
35+
private:
2736
float _duration;
2837
size_t _nbFrames;
2938
size_t _quality; ///< Between 1 (good) and FF_LAMBDA_MAX (bad). 0 if unknown.

src/AvTranscoder/stat/stat.i

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
%{
2-
#include <AvTranscoder/stat/ProcessStat.hpp>
32
#include <AvTranscoder/stat/VideoStat.hpp>
43
#include <AvTranscoder/stat/AudioStat.hpp>
4+
#include <AvTranscoder/stat/ProcessStat.hpp>
55
%}
66

7-
%include <AvTranscoder/stat/ProcessStat.hpp>
87
%include <AvTranscoder/stat/VideoStat.hpp>
98
%include <AvTranscoder/stat/AudioStat.hpp>
9+
%include <AvTranscoder/stat/ProcessStat.hpp>

src/AvTranscoder/transcoder/Transcoder.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -580,9 +580,9 @@ void Transcoder::fillProcessStat(ProcessStat& processStat)
580580
const AVCodecContext& encoderContext = encoder->getCodec().getAVCodecContext();
581581
if(encoderContext.coded_frame && (encoderContext.flags & CODEC_FLAG_PSNR))
582582
{
583-
videoStat._quality = encoderContext.coded_frame->quality;
584-
videoStat._psnr = VideoStat::psnr(encoderContext.coded_frame->error[0] /
585-
(encoderContext.width * encoderContext.height * 255.0 * 255.0));
583+
videoStat.setQuality(encoderContext.coded_frame->quality);
584+
videoStat.setPSNR(encoderContext.coded_frame->error[0] /
585+
(encoderContext.width * encoderContext.height * 255.0 * 255.0));
586586
}
587587
}
588588
processStat.addVideoStat(streamIndex, videoStat);

test/pyTest/testInputFile.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import os
2+
3+
# Check if environment is setup to run the tests
4+
if os.environ.get('AVTRANSCODER_TEST_VIDEO_MOV_FILE') is None:
5+
from nose.plugins.skip import SkipTest
6+
raise SkipTest("Need to define environment variables "
7+
"AVTRANSCODER_TEST_VIDEO_MOV_FILE")
8+
9+
from nose.tools import *
10+
11+
from pyAvTranscoder import avtranscoder as av
12+
13+
14+
@raises(IOError)
15+
def testCreateInputFileFromUnexistingFilename():
16+
"""
17+
Create an InputFile from an unexisting filename.
18+
"""
19+
inputFileName = "testCreateInputFileFromUnexistingFilename"
20+
av.InputFile( inputFileName )
21+
22+
23+
def testInputFileAnalyseFirstGop():
24+
"""
25+
Analyse the first gop of an InputFile, and check if the correct attributes are filled.
26+
"""
27+
inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_MOV_FILE']
28+
inputFile = av.InputFile( inputFileName )
29+
30+
# The analyse of the first GOP is not done yet
31+
videoProperties = inputFile.getProperties().getVideoProperties()[0]
32+
assert_equals(videoProperties.isInterlaced(), False)
33+
assert_equals(videoProperties.isTopFieldFirst(), False)
34+
assert_equals(videoProperties.getGopStructure(), ())
35+
36+
# Analyse first GOP
37+
progress = av.NoDisplayProgress()
38+
inputFile.analyse( progress, av.eAnalyseLevelFirstGop )
39+
40+
# Check properties after GOP analysis
41+
videoProperties = inputFile.getProperties().getVideoProperties()[0]
42+
assert_not_equals(videoProperties.getGopStructure(), ())

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy