mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-05 12:14:27 +00:00
Added delay to video playback to properly seek
This commit is contained in:
@@ -127,6 +127,7 @@ public class MovieExporter {
|
||||
Arrays.sort(frameNumArray);
|
||||
FLVTAG lastTag = null;
|
||||
int frameNum = 0;
|
||||
int internalFrameDelay = 5 * 1000;
|
||||
for (int i = 0; i < frameNumArray.length; i++) {
|
||||
VideoFrameTag tag = frames.get(frameNumArray[i]);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
@@ -199,10 +200,10 @@ public class MovieExporter {
|
||||
}
|
||||
|
||||
baos.write(tag.videoData.getRangeData());
|
||||
flv.writeTag(lastTag = new FLVTAG((long)Math.floor(ffdecInternal ? frameNum * 5000.0 : (frameNum * 1000.0 / swf.frameRate)), new VIDEODATA(frameType, videoStream.codecID, baos.toByteArray())));
|
||||
flv.writeTag(lastTag = new FLVTAG((long)Math.floor(ffdecInternal ? frameNum * internalFrameDelay : (frameNum * 1000.0 / swf.frameRate)), new VIDEODATA(frameType, videoStream.codecID, baos.toByteArray())));
|
||||
}
|
||||
if (ffdecInternal && lastTag != null) {
|
||||
lastTag.timeStamp = frameNum * 5000 + 10000;
|
||||
lastTag.timeStamp = frameNum * internalFrameDelay + 2 * internalFrameDelay;
|
||||
flv.writeTag(lastTag);
|
||||
}
|
||||
return fos.toByteArray();
|
||||
|
||||
@@ -307,27 +307,24 @@ public class DefineVideoStreamTag extends DrawableTag implements BoundedTag, Tim
|
||||
}
|
||||
|
||||
synchronized (DefineVideoStreamTag.class) {
|
||||
|
||||
if (!(activeFrame != null && lastFrame == f)) {
|
||||
synchronized (getFrameLock) {
|
||||
activeFrame = null;
|
||||
getFrameLock.notifyAll();
|
||||
}
|
||||
if (!(activeFrame != null && lastFrame == f))
|
||||
{
|
||||
initPlayer();
|
||||
|
||||
|
||||
if (mediaPlayer.isFinished()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
float oneFr = 1f / (getNumFrames() + 2);
|
||||
|
||||
synchronized (getFrameLock) {
|
||||
activeFrame = null;
|
||||
}
|
||||
mediaPlayer.setPosition(((float) f) / (getNumFrames() + 2) - (f == 0 ? 0 : oneFr / 10f));
|
||||
|
||||
try {
|
||||
synchronized (getFrameLock) {
|
||||
if (activeFrame == null) {
|
||||
//System.out.println("waiting...");
|
||||
getFrameLock.wait();
|
||||
Thread.sleep(10); //magic, but should work
|
||||
mediaPlayer.pause();
|
||||
//System.out.println("awakened");
|
||||
}
|
||||
}
|
||||
@@ -352,7 +349,6 @@ public class DefineVideoStreamTag extends DrawableTag implements BoundedTag, Tim
|
||||
}
|
||||
}
|
||||
}
|
||||
//System.out.println("toImage return");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user