File tree Expand file tree Collapse file tree 1 file changed +14
-10
lines changed
src/AvTranscoder/transcoder Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -588,15 +588,6 @@ void StreamTranscoder::preProcessCodecLatency()
588
588
wasARewrapCase = true ;
589
589
}
590
590
591
- if (_offset > 0 ) {
592
- const double fps = 1.0 * _outputEncoder->getCodec ().getAVCodecContext ().time_base .den /
593
- (_outputEncoder->getCodec ().getAVCodecContext ().time_base .num * _outputEncoder->getCodec ().getAVCodecContext ().ticks_per_frame );
594
- const double frame_duration = 1.0 / fps;
595
- const double output_latency_duration = frame_duration * (latency - 1 );
596
- LOG_WARN (" Compensate for offset with codec latency by " << output_latency_duration << " seconds (fps=" << fps << " , latency=" << latency << " )" );
597
- _offset -= output_latency_duration;
598
- }
599
-
600
591
while ((latency--) > 0 )
601
592
{
602
593
processFrame ();
@@ -626,7 +617,20 @@ bool StreamTranscoder::processFrame()
626
617
// Manage offset
627
618
if (_offset > 0 )
628
619
{
629
- const bool endOfOffset = _outputStream->getStreamDuration () >= _offset;
620
+ bool endOfOffset = false ;
621
+ if (_currentDecoder == _generators.at (0 ))
622
+ {
623
+ const double fps = 1.0 * _outputEncoder->getCodec ().getAVCodecContext ().time_base .den /
624
+ (_outputEncoder->getCodec ().getAVCodecContext ().time_base .num * _outputEncoder->getCodec ().getAVCodecContext ().ticks_per_frame );
625
+ const double frame_duration = 1.0 / fps;
626
+ const double generated_duration = _currentDecoder->getNbDecodedFrames () * frame_duration;
627
+ endOfOffset = generated_duration >= _offset;
628
+ }
629
+ else
630
+ {
631
+ endOfOffset = _outputStream->getStreamDuration () >= _offset;
632
+ }
633
+
630
634
if (endOfOffset)
631
635
{
632
636
LOG_INFO (" End of positive offset" )
You can’t perform that action at this time.
0 commit comments