Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frozen seconds in beginning of subclip using ffmpeg_extract_subclip() #847

Closed
grszkthfr opened this issue Sep 6, 2018 · 10 comments
Closed
Labels
bug Issues that report (apparent) bugs. lib-misc Issues pertaining to misc. 3rd-party libraries. video Related to VideoClip and related classes, or handling of video in general.

Comments

@grszkthfr
Copy link
Contributor

grszkthfr commented Sep 6, 2018

Hi everyone,

not sure if this is a bug, however I have an issue here:

The docs of ffmpeg state, that -ss should be specified before -i, at least when input seeking.

But I think ffmpeg_extract_subclip(), specifies it after -i. That is at least what causes trouble when I call ffmpeg_extract_subclip()

For myself:

~\AppData\Local\imageio\ffmpeg\ffmpeg-win32-v3.2.4.exe -y -i raw\pt01c.avi -ss 33.00 -t 40.00 -vcodec copy -acodec copy corridor\pt01-corridor.avi

leads to a frozen video sequence of 2-6 seconds in the beginning of the video with sound playing.

Whereas

C:\Users\jog54yy\AppData\Local\imageio\ffmpeg\ffmpeg-win32-v3.2.4.exe -y  -ss 33.00 -i raw\pt01c.avi  -t 40.00 -vcodec copy -acodec copy corridor\pt01-corridor.avi

works as expected.

Is there any thing that I am missing? Is that how it is thought to be? Is there a way to specifiy the order of specification of -iand -ss?

Edit: Looks like Issue #508 but this did not help.

Best Jonas


Here's the rest:

Expected Behavior

No frozen seconds before video starts playing.

Actual Behavior

ffmpeg_extract_subclip() produces frozen seconds before video starts playing, sound is good form the beginning. However, couldn't test for synchrony (That is what other report as well, when specifing it the wrong way).

Steps to Reproduce the Problem

see above

Specifications

  • Python Version: 3.7.0
  • Moviepy Version: 0.2.3.5
  • Platform Name: Windows
  • Platform Version: Windwos 10
@Zulko
Copy link
Owner

Zulko commented Sep 6, 2018

You may be right. There is no way to choose the order of -i nd -ss in moviepy, but if one works and the other not, then its a bug and needs a PR. I am too busy to test it unfortunately, but I think we can trust you on this.

@keikoro keikoro added bug Issues that report (apparent) bugs. lib-misc Issues pertaining to misc. 3rd-party libraries. video Related to VideoClip and related classes, or handling of video in general. labels Dec 16, 2018
@gpotter2
Copy link

gpotter2 commented Mar 4, 2019

I can confirm the fix is correct. There’s also
https://stackoverflow.com/a/33188399/5459467 which points in the same direction.

@Zulko very sorry to bother, but it would be very cool if you could merge that 😄

@Zulko
Copy link
Owner

Zulko commented Mar 4, 2019

@gpotter2 I merged #848. Sorry for being slow.

@gpotter2
Copy link

gpotter2 commented Mar 4, 2019

@Zulko Thanks a lot for your quick response. You should be able to close #508, #579 and this issue now

@keikoro keikoro closed this as completed Mar 5, 2019
@DallasHoelscher
Copy link

I know this is closed, but is it possible this issue is still happening with concatenate_videoclips. My clips where I use ffmpeg_extract_subclip() are creating the clips correctly, with no pause. When I concatenate the clips together in the end though the very first clip has a 5 second pause with no audio or video playing.

@Bootscreen
Copy link

what do i need when i want this fix? currently i installed it with pip and get version 1.0.0 from end of february.

@gpotter2
Copy link

The commit is 8 months old, but was merged 2 moths ago. Therefore it's not in 1.0. You need to download and install the master branch

@halesyy
Copy link

halesyy commented Jul 22, 2020

@DallasHoelscher still having this issue now mid-2020, super frustrating. It's happened to me out of thin air.

@keikoro
Copy link
Collaborator

keikoro commented Oct 2, 2020

@halesyy Did you have a look at what @gpotter2 said to the previous commenter? I.e. was your issue also related to your using version 1.0? Otherwise we could reopen the issue.

@idanavin
Copy link

idanavin commented May 2, 2021

Hey, still having issue with that.
The changes made here #848 in this commit: 099a288

Although this might be the cause of black frames coming from #508
I changed it locally and it worked, clips without the freezes

def ffmpeg_extract_subclip(filename, t1, t2, targetname=None):
    """ Makes a new video file playing video file ``filename`` between
        the times ``t1`` and ``t2``. """
    name, ext = os.path.splitext(filename)
    if not targetname:
        T1, T2 = [int(1000*t) for t in [t1, t2]]
        targetname = "%sSUB%d_%d.%s" % (name, T1, T2, ext)
    
    cmd = [get_setting("FFMPEG_BINARY"),"-y",
           "-i", filename,
           "-ss", "%0.2f"%t1,
           "-t", "%0.2f"%(t2-t1),
           "-map", "0", "-vcodec", "copy", "-acodec", "copy", targetname]
    
    subprocess_call(cmd)

Also, changing the values to (or removing them):

-acodec libmp3lame -vcodec libx264

Solve minor time issues with some of the shorter clips, but take a lot more processing power
A good refrence: https://stackoverflow.com/a/63233644

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues that report (apparent) bugs. lib-misc Issues pertaining to misc. 3rd-party libraries. video Related to VideoClip and related classes, or handling of video in general.
Projects
None yet
Development

No branches or pull requests

8 participants