Skip to content
Snippets Groups Projects
Commit 056d6931 authored by gnaegi's avatar gnaegi
Browse files

OO-2013 fix wrong duration calculation

parent 4fd461b2
No related branches found
No related tags found
No related merge requests found
......@@ -30,6 +30,7 @@ import java.util.List;
import org.jcodec.api.FrameGrab;
import org.jcodec.common.FileChannelWrapper;
import org.jcodec.containers.mp4.boxes.MovieBox;
import org.jcodec.containers.mp4.demuxer.MP4Demuxer;
import org.olat.core.commons.services.image.Size;
import org.olat.core.commons.services.image.spi.ImageHelperImpl;
......@@ -128,8 +129,14 @@ public class MovieServiceImpl implements MovieService, ThumbnailSPI {
FileChannel ch = accessFile.getChannel();
FileChannelWrapper in = new FileChannelWrapper(ch);
MP4Demuxer demuxer1 = new MP4Demuxer(in);
long duration = demuxer1.getMovie().getDuration();
return duration;
MovieBox movie = demuxer1.getMovie();
long duration = movie.getDuration();
int timescale = movie.getTimescale();
if (timescale < 1) {
timescale = 1;
}
// Simple calculation. Ignore NTSC and other issues for now
return duration / timescale * 1000;
} catch (Exception | AssertionError e) {
log.error("Cannot extract duration of: " + media, e);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment