Skip to content

OuputFile: can instanciate it without extension #264

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

Merged
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
4 changes: 2 additions & 2 deletions src/AvTranscoder/file/FormatContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@ void FormatContext::setOutputFormat( const std::string& filename, const std::str
msg += filename;
if( ! shortName.empty() )
{
msg += ", ";
msg += ", formatName = ";
msg += shortName;
}
if( ! mimeType.empty() )
{
msg += ", ";
msg += ", mimeType = ";
msg += mimeType;
}
throw std::ios_base::failure( msg );
Expand Down
4 changes: 2 additions & 2 deletions src/AvTranscoder/file/OutputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
namespace avtranscoder
{

OutputFile::OutputFile( const std::string& filename )
OutputFile::OutputFile( const std::string& filename, const std::string& formatName, const std::string& mimeType )
: _formatContext( AV_OPT_FLAG_ENCODING_PARAM )
, _outputStreams()
, _frameCount()
, _previousProcessedStreamDuration( 0.0 )
, _profile()
{
_formatContext.setFilename( filename );
_formatContext.setOutputFormat( filename );
_formatContext.setOutputFormat( filename, formatName, mimeType );
}

OutputFile::~OutputFile()
Expand Down
9 changes: 7 additions & 2 deletions src/AvTranscoder/file/OutputFile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ class AvExport OutputFile : public IOutputFile

public:
/**
* @brief Open an output media file
* @brief Create an output media file.
* @param filename resource to access
* @param formatName should matches with the names of the registered formats
* @param mimeType should matches with the MIME type of the registered formats
* @note The caller should indicate formatName and/or mimeType if the filename has no extension.
* @note The ressource is allocated when beginWrap.
* @see beginWrap
**/
OutputFile( const std::string& filename = "" );
OutputFile( const std::string& filename, const std::string& formatName = "", const std::string& mimeType = "" );

~OutputFile();

Expand Down
174 changes: 87 additions & 87 deletions test/pyTest/testEProcessMethod.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# Check if environment is setup to run the tests
if os.environ.get('AVTRANSCODER_TEST_VIDEO_AVI_FILE') is None or os.environ.get('AVTRANSCODER_TEST_AUDIO_MOV_FILE') is None or os.environ.get('AVTRANSCODER_TEST_AUDIO_WAVE_FILE') is None:
from nose.plugins.skip import SkipTest
raise SkipTest("Need to define environment variables AVTRANSCODER_TEST_VIDEO_AVI_FILE / AVTRANSCODER_TEST_AUDIO_MOV_FILE / AVTRANSCODER_TEST_AUDIO_WAVE_FILE")
from nose.plugins.skip import SkipTest
raise SkipTest("Need to define environment variables AVTRANSCODER_TEST_VIDEO_AVI_FILE / AVTRANSCODER_TEST_AUDIO_MOV_FILE / AVTRANSCODER_TEST_AUDIO_WAVE_FILE")

from nose.tools import *

Expand All @@ -14,117 +14,117 @@


def testEProcessMethodShortest():
"""
Process with method eProcessMethodShortest, check output duration.
"""
inputFileName_longest = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE']
inputFileName_shortest = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE']
outputFileName = "testEProcessMethodShortest.mov"
"""
Process with method eProcessMethodShortest, check output duration.
"""
inputFileName_longest = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE']
inputFileName_shortest = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE']
outputFileName = "testEProcessMethodShortest.mov"

ouputFile = av.OutputFile( outputFileName )
transcoder = av.Transcoder( ouputFile )
transcoder.setProcessMethod( av.eProcessMethodShortest )
ouputFile = av.OutputFile( outputFileName )
transcoder = av.Transcoder( ouputFile )
transcoder.setProcessMethod( av.eProcessMethodShortest )

transcoder.add( inputFileName_longest, 0, "" )
transcoder.add( inputFileName_shortest, 0, "" )
transcoder.add( inputFileName_longest, 0, "" )
transcoder.add( inputFileName_shortest, 0, "" )

progress = av.ConsoleProgress()
transcoder.process( progress )
progress = av.ConsoleProgress()
transcoder.process( progress )

# get src file
src_inputFile_shortest = av.InputFile( inputFileName_shortest )
src_properties_shortest = src_inputFile_shortest.getProperties()
# get src file
src_inputFile_shortest = av.InputFile( inputFileName_shortest )
src_properties_shortest = src_inputFile_shortest.getProperties()

# get dst file
dst_inputFile = av.InputFile( outputFileName )
dst_properties = dst_inputFile.getProperties()
# get dst file
dst_inputFile = av.InputFile( outputFileName )
dst_properties = dst_inputFile.getProperties()

assert_equals( dst_properties.getDuration(), src_properties_shortest.getDuration() )
assert_equals( dst_properties.getDuration(), src_properties_shortest.getDuration() )


def testEProcessMethodLongest():
"""
Process with method eProcessMethodLongest, check output duration.
"""
inputFileName_longest = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE']
inputFileName_shortest = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE']
outputFileName = "testEProcessMethodLongest.mov"
"""
Process with method eProcessMethodLongest, check output duration.
"""
inputFileName_longest = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE']
inputFileName_shortest = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE']
outputFileName = "testEProcessMethodLongest.mov"

ouputFile = av.OutputFile( outputFileName )
transcoder = av.Transcoder( ouputFile )
transcoder.setProcessMethod( av.eProcessMethodLongest )
ouputFile = av.OutputFile( outputFileName )
transcoder = av.Transcoder( ouputFile )
transcoder.setProcessMethod( av.eProcessMethodLongest )

transcoder.add( inputFileName_longest, 0, "" )
transcoder.add( inputFileName_shortest, 0, "" )
transcoder.add( inputFileName_longest, 0, "" )
transcoder.add( inputFileName_shortest, 0, "" )

progress = av.ConsoleProgress()
transcoder.process( progress )
progress = av.ConsoleProgress()
transcoder.process( progress )

# get src file
src_inputFile_longest = av.InputFile( inputFileName_longest )
src_properties_longest = src_inputFile_longest.getProperties()
src_inputFile_longest = av.InputFile( inputFileName_longest )
src_properties_longest = src_inputFile_longest.getProperties()

# get dst file
dst_inputFile = av.InputFile( outputFileName )
dst_properties = dst_inputFile.getProperties()
# get dst file
dst_inputFile = av.InputFile( outputFileName )
dst_properties = dst_inputFile.getProperties()

assert_equals( dst_properties.getDuration(), src_properties_longest.getDuration() )
assert_equals( dst_properties.getDuration(), src_properties_longest.getDuration() )


def testEProcessMethodBasedOnStream():
"""
Process with method testEProcessMethodBasedOnStream, check output duration.
"""
inputFileName_first = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE']
inputFileName_second = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE']
inputFileName_third = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE']
outputFileName = "testEProcessMethodShortest.mov"
"""
Process with method testEProcessMethodBasedOnStream, check output duration.
"""
inputFileName_first = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE']
inputFileName_second = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE']
inputFileName_third = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE']
outputFileName = "testEProcessMethodShortest.mov"

ouputFile = av.OutputFile( outputFileName )
transcoder = av.Transcoder( ouputFile )
transcoder.setProcessMethod( av.eProcessMethodBasedOnStream, 1 )
ouputFile = av.OutputFile( outputFileName )
transcoder = av.Transcoder( ouputFile )
transcoder.setProcessMethod( av.eProcessMethodBasedOnStream, 1 )

transcoder.add( inputFileName_first, 0, "" )
transcoder.add( inputFileName_second, 0, "" )
transcoder.add( inputFileName_third, 0, "" )
transcoder.add( inputFileName_first, 0, "" )
transcoder.add( inputFileName_second, 0, "" )
transcoder.add( inputFileName_third, 0, "" )

progress = av.ConsoleProgress()
transcoder.process( progress )
progress = av.ConsoleProgress()
transcoder.process( progress )

# get src file
src_inputFile_second = av.InputFile( inputFileName_second )
src_properties_second = src_inputFile_second.getProperties()
# get src file
src_inputFile_second = av.InputFile( inputFileName_second )
src_properties_second = src_inputFile_second.getProperties()

# get dst file
dst_inputFile = av.InputFile( outputFileName )
dst_properties = dst_inputFile.getProperties()
# get dst file
dst_inputFile = av.InputFile( outputFileName )
dst_properties = dst_inputFile.getProperties()

assert_equals( dst_properties.getDuration(), src_properties_second.getDuration() )
assert_equals( dst_properties.getDuration(), src_properties_second.getDuration() )


def testEProcessMethodBasedOnDuration():
"""
Process with method eProcessMethodBasedOnDuration, check output duration.
"""
inputFileName_first = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE']
inputFileName_second = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE']
inputFileName_third = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE']
outputFileName = "testEProcessMethodBasedOnDuration.mov"

ouputFile = av.OutputFile( outputFileName )
transcoder = av.Transcoder( ouputFile )
transcoder.setProcessMethod( av.eProcessMethodBasedOnDuration, 0, 50 )

transcoder.add( inputFileName_first, 0, "" )
transcoder.add( inputFileName_second, 0, "" )
transcoder.add( inputFileName_third, 0, "" )

progress = av.ConsoleProgress()
transcoder.process( progress )

# get dst file
dst_inputFile = av.InputFile( outputFileName )
dst_properties = dst_inputFile.getProperties()

assert_equals( dst_properties.getDuration(), 50 )
"""
Process with method eProcessMethodBasedOnDuration, check output duration.
"""
inputFileName_first = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE']
inputFileName_second = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE']
inputFileName_third = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE']
outputFileName = "testEProcessMethodBasedOnDuration.mov"

ouputFile = av.OutputFile( outputFileName )
transcoder = av.Transcoder( ouputFile )
transcoder.setProcessMethod( av.eProcessMethodBasedOnDuration, 0, 50 )

transcoder.add( inputFileName_first, 0, "" )
transcoder.add( inputFileName_second, 0, "" )
transcoder.add( inputFileName_third, 0, "" )

progress = av.ConsoleProgress()
transcoder.process( progress )

# get dst file
dst_inputFile = av.InputFile( outputFileName )
dst_properties = dst_inputFile.getProperties()

assert_equals( dst_properties.getDuration(), 50 )

80 changes: 40 additions & 40 deletions test/pyTest/testNbFrames.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# Check if environment is setup to run the tests
if os.environ.get('AVTRANSCODER_TEST_VIDEO_AVI_FILE') is None:
from nose.plugins.skip import SkipTest
raise SkipTest("Need to define environment variable AVTRANSCODER_TEST_VIDEO_AVI_FILE")
from nose.plugins.skip import SkipTest
raise SkipTest("Need to define environment variable AVTRANSCODER_TEST_VIDEO_AVI_FILE")

from nose.tools import *

Expand All @@ -14,55 +14,55 @@


def testNbFramesVideoRewrap():
"""
Rewrap one video stream, check nb frames.
"""
inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE']
outputFileName = "testNbFramesVideoRewrap.mov"
"""
Rewrap one video stream, check nb frames.
"""
inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE']
outputFileName = "testNbFramesVideoRewrap.mov"

ouputFile = av.OutputFile( outputFileName )
transcoder = av.Transcoder( ouputFile )
ouputFile = av.OutputFile( outputFileName )
transcoder = av.Transcoder( ouputFile )

transcoder.add( inputFileName, 0, "" )
transcoder.add( inputFileName, 0, "" )

progress = av.ConsoleProgress()
transcoder.process( progress )
progress = av.ConsoleProgress()
transcoder.process( progress )

# get src file of rewrap
src_inputFile = av.InputFile( inputFileName )
src_properties = src_inputFile.getProperties()
src_videoStream = src_properties.getVideoProperties()[0]
# get src file of rewrap
src_inputFile = av.InputFile( inputFileName )
src_properties = src_inputFile.getProperties()
src_videoStream = src_properties.getVideoProperties()[0]

# get dst file of rewrap
dst_inputFile = av.InputFile( outputFileName )
dst_properties = dst_inputFile.getProperties()
dst_videoStream = dst_properties.getVideoProperties()[0]
# get dst file of rewrap
dst_inputFile = av.InputFile( outputFileName )
dst_properties = dst_inputFile.getProperties()
dst_videoStream = dst_properties.getVideoProperties()[0]

assert_equals( src_videoStream.getNbFrames(), dst_videoStream.getNbFrames() )
assert_equals( src_videoStream.getNbFrames(), dst_videoStream.getNbFrames() )

def testNbFramesVideoTranscode():
"""
Transcode one video stream (to h264), check nb frames.
"""
inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE']
outputFileName = "testNbFramesVideoTranscode.mov"
"""
Transcode one video stream (to h264), check nb frames.
"""
inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE']
outputFileName = "testNbFramesVideoTranscode.mov"

ouputFile = av.OutputFile( outputFileName )
transcoder = av.Transcoder( ouputFile )
ouputFile = av.OutputFile( outputFileName )
transcoder = av.Transcoder( ouputFile )

transcoder.add( inputFileName, 0, "mpeg2" )
transcoder.add( inputFileName, 0, "mpeg2" )

progress = av.ConsoleProgress()
transcoder.process( progress )
progress = av.ConsoleProgress()
transcoder.process( progress )

# get src file of transcode
src_inputFile = av.InputFile( inputFileName )
src_properties = src_inputFile.getProperties()
src_videoStream = src_properties.getVideoProperties()[0]
# get src file of transcode
src_inputFile = av.InputFile( inputFileName )
src_properties = src_inputFile.getProperties()
src_videoStream = src_properties.getVideoProperties()[0]

# get dst file of transcode
dst_inputFile = av.InputFile( outputFileName )
dst_properties = dst_inputFile.getProperties()
dst_videoStream = dst_properties.getVideoProperties()[0]
# get dst file of transcode
dst_inputFile = av.InputFile( outputFileName )
dst_properties = dst_inputFile.getProperties()
dst_videoStream = dst_properties.getVideoProperties()[0]

assert_equals( src_videoStream.getNbFrames(), dst_videoStream.getNbFrames() )
assert_equals( src_videoStream.getNbFrames(), dst_videoStream.getNbFrames() )
Loading