pencil2d / pencil

Pencil2D is an easy, intuitive tool to make 2D hand-drawn animations. Pencil2D is open source and cross-platform.
http://pencil2d.org
GNU General Public License v2.0
1.48k stars 272 forks source link

Consecutive playback from last frame of an animation will consistently shift the audio back #1416

Open Jose-Moreno opened 4 years ago

Jose-Moreno commented 4 years ago

Issue Summary

When I was testing the movie import I noticed that playing back an animation with a sound layer from the last frame, repeatedly, that is wait for the animation to end and press the play button again, seems to mess up the caching and shifts the audio back so the video and audio are not synchronized anymore.

Once it ends If I press the "Jump to the Start" button, and play the video/audio sync still gets messed up.

If I play the video but stop it either halfway or about 75% the animation length before it ends by itself, press the "Jump to the Start" button, and then play again the video does NOT get unsynced. If I stop if after that even if it hasn't ended it does get unsynced once i play it back.

Strangely enough, if I let i play with the shifted synchronized and stop it before it reaches the end, but then move the scrub back to the first frame and play again, the playback works properly. If I let it end normally, this doesn't work.

Even more strange, If I use the "Jump to the End" button from the first frame, and then playback from there, the playback does not lose synchronization once it goes back to the first frame.

If I play normally, stop and then use the Jump to the End button, and then play again to it goes back to the first frame, it works as well.

Expected Results

Playback audio should never become unsynced regardless of the frame position the user is located at when they start playback.

Steps to reproduce

Download Sample: https://we.tl/t-DqZDNAr5b7 Link will last a week from the day this issue is submitted so please download it early. If testers can't download, let me know to reupload.

  1. Open Pencil2D
  2. Open the sample immediately
  3. Playback normally Note: Here you'll notice an ungodly lag, the images are getting cached it seems. I'm not sure if this is as normal as it used to be. Play it back various times, no need to let it end, it's just so the lag goes away to force caching. That way you can properly see the video/audio synchronized to normal expectations.
  4. Now for the real test: Playback the video once and let it finish. Take note of how the character says "he won't be a boy forever" it is synced
  5. The playhead should be on the last frame, now press the Play button again. You will notice the video/audio are unsynced now, it will be noticeable around the same part as point 4.
  6. Now before it ends, stop the playback. Press Jump to Start button.
  7. Play back again, now you'll see the lag went away and the video/audio are synced again.

System Information

Version: 0.6.5

commit: 50a0c7c318f38988af85d34e955a5a78d3953474 date: 2020-08-01_01:32:15

Operating System: Windows 10 Pro (10.0) V1909 OS Build 18363.959 CPU Architecture: x86_64 Qt Version: 5.12.9

Jose-Moreno commented 3 years ago

It seems this was partly related to the various issues fixed by #1559 however the other part of this issue seems to be related to #1567

In release v0.6.5, this would happen often with the sample video / audio, however in the recent nightlies following the reproduction steps won't show this behavior. If I don't manage to reproduce it again or if it occurs under the influence of 1567, then i'll close this in favor of the other one which is not really a bug but rather a limitation of the software that has to be addressed by implementing improved playback & preview features.

Jose-Moreno commented 5 months ago

Hi. I had reported an update on this issue on discord, but it was not discussed so I'll report the related info here.

I noticed that If I scrub an audio clip first, click on the timeline to any frame before the audio clip starts, and then play back the animation from that frame position, instead of playing the entire sound, the playhead will traverse over the clip but only play the audible remainder of the sound clip that was not scrubbed through before playback.

This only seem to happen after scrubbing. If I play the animation again the sound will be played normally. If I use the "Jump to Start" button the sound will be played normally.

I recorded a video of the issue last year but the issue is still present in the release candidate for 0.7.0.

1️⃣ st sound: Door slam (wav? came from an old file from 0.6.5) 2️⃣ nd sound: Wilhelm scream (wav) 3️⃣ rd sound: cellphone ringtone Jump to: First Issue 00:20 to hear the complete sounds. 00.40 is where I jump with the playhead to the second clip (I didn't scrub over the first but just clicked on the start of the second one)

Note: There was a second issue that lead to a crash at the end of the video but I can't reproduce that in the RC so let's focus on the first sound scrubbing problem instead.

Second Issue - Click to expand `01:50` I import a third sound since I wanted to test the phenomenon in the same layer as the second sound. `01:58` you can see the third sound was imported over the second sound, but after I clicked and tried to drag the longer one I couldn't at first, then the previous, second sound was pushed away (at first I thought it had been deleted) `02:06` I accidentally moved the scrubber over the first audio clip trying to scrub over what I thought was the disappeared second audio clip `02:20` I moved the second audio next to the third one on the same layer. `02:26` I moved the playhead over the third soundclip, and coincidentially I went back over the first clip (which by way of the previous report should have reset it's own index inpoint to 0 or whatever) `02:30` I scrubbed back to the beginning and played the entire timeline worth of sound clips `02:40` after playback stopped I went back to click on the second sound clip but didn't because I recalled I had partially scrubbed it (but didn't notice 2:26 behavior ) and wanted to test if it would play the rest of the sound I though it had `02:42` then I clicked on the frame rule to move the playhead before that clip to play and Pencil2D crashed 😅

https://github.com/pencil2d/pencil/assets/4912907/cdc5da2f-e02c-42ce-a263-bc7787ced8e2