Skip to content

Commit 33723c8

Browse files
author
Clement Champetier
committed
StreamTranscoder: throw if a stream needs to switch to a generator but cannot
* Updated doc of the method. * Added a python test.
1 parent 1a512f9 commit 33723c8

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

src/AvTranscoder/transcoder/StreamTranscoder.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -560,10 +560,9 @@ void StreamTranscoder::needToSwitchToGenerator(const bool needToSwitch)
560560
if(needToSwitch && !canSwitchToGenerator())
561561
{
562562
std::stringstream os;
563-
LOG_WARN("The stream " << _inputStream->getStreamIndex() << " has a duration of " << getDuration()
564-
<< "s. It needs to switch to a generator during the process, but it cannot. "
565-
<< "No generator will be used for this stream.")
566-
return;
563+
os << "The stream at index " << _inputStream->getStreamIndex() << " has a duration of " << getDuration() << "s.";
564+
os << " It needs to switch to a generator during the process, but it cannot. ";
565+
throw std::runtime_error(os.str());
567566
}
568567
_needToSwitchToGenerator = needToSwitch;
569568
}

src/AvTranscoder/transcoder/StreamTranscoder.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class AvExport StreamTranscoder
2727
public:
2828
/**
2929
* @brief Rewrap the given stream.
30-
* @note offset feature when rewrap a stream is not supported
3130
**/
3231
StreamTranscoder(IInputStream& inputStream, IOutputFile& outputFile, const float offset = 0);
3332

test/pyTest/testOffset.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@
1515
from pyAvTranscoder import avtranscoder as av
1616

1717

18+
@raises(RuntimeError)
19+
def testRewrapVideoPositiveOffsetWithoutGenerator():
20+
"""
21+
Add a positive offset supposed to have a generator.
22+
Depending on the codec and the given parameters, the generator could not be instanciate.
23+
"""
24+
inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_RAW_FILE']
25+
outputFileName = "testPositiveOffsetWithoutGenerator.h264"
26+
offset = 10
27+
28+
ouputFile = av.OutputFile( outputFileName )
29+
transcoder = av.Transcoder( ouputFile )
30+
31+
transcoder.addStream( av.InputStreamDesc(inputFileName, 0), "", offset )
32+
33+
1834
def testTranscodeAudioPositiveOffset():
1935
"""
2036
Transcode one audio stream (profile wave24b48kmono) with offset at the beginning of the process.

0 commit comments

Comments
 (0)