[haiku-commits] Re: haiku: hrev50806 - in src: kits/media add-ons/media/plugins/ffmpeg

  • From: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 30 Dec 2016 22:54:27 +0100

On Fri, Dec 30, 2016 at 10:18:52PM +0100, Stephan Aßmus wrote:

    *frameCount = fStream->nb_frames;
-// if (*frameCount == 0) {
+   if (*frameCount == 0) {
            // Calculate from duration and frame rate
            *frameCount = (int64)(*duration * frameRate / 1000000LL);
            TRACE("  frameCount calculated: %lld, from context: %lld\n",
                    *frameCount, fStream->nb_frames);
-// } else
-//         TRACE("  frameCount: %lld\n", *frameCount);
+   } else
+           TRACE("  frameCount: %lld\n", *frameCount);

I take the blame for not putting a comment there explaining why it was
commented out. But you could of course ask here before commiting a change,
it is after all quite likely that there was a reason it was commented out.
If memory serves, there are streams where the frame-count is very
unreliable. Perhaps videos with variable frame-rate. I would guess that
overall it worked better for a greater range of files, at least the files I
was using for testing back then.

But the computation from the duration and frame rate results in rounding
errors, which create various problems on their own, as it is not
reliably possible to detect the end of stream then.

BePac Deluxe was a clear problem, but there are similar issues in other
places. For example, in MediaPlayer the position would not always go to
the end or reach the end of the slider before the file is done playing.
And in WebPositive, sometimes the end of the stream would not be
detected and a web page would be stuck waiting forever for a video or
sound to play.

If the frame count is unreliable, we will have to compute it in a more
precise way in these cases, or generate or cut some frames at the end of
the file to match exactly what we report. It is possible that the
original problem was solved by ffmpeg updates, as far as I know this
code was written against a 0.6.x version of ffmpeg and there have been
quite a lot of changes since then.

We will see if someone encounters new problems, and start building a
test suite with the files that don't work with these changes.

-- 
Adrien.

Other related posts: