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

Sound doubling / looping when merging clips. #2159

Open
LindaLawton opened this issue Apr 21, 2024 · 1 comment
Open

Sound doubling / looping when merging clips. #2159

LindaLawton opened this issue Apr 21, 2024 · 1 comment
Labels
question Questions regarding functionality, usage

Comments

@LindaLawton
Copy link

LindaLawton commented Apr 21, 2024

I have a directory full of clips currently there are about 40. I'm trying to merge them into one long video its about 6 minutes long when the merge is complete


def merge_videos(video_paths, output_path):
    success = False
    try:
        videos = []
        for video in video_paths:
            videos.append(VideoFileClip(video))

        # Concatenate the video clips
        final_clip = concatenate_videoclips(videos)

        # Write the final clip to a file
        final_clip.write_videofile(output_path, codec='libx264', audio_codec='aac')
        success = True
    except Exception as e:
        # Handle any errors
        print("Error merging videos:", e)
        return False
    finally:
        # Close the clips
        final_clip.close()
        for video in videos:
            video.close()
        return success

The problem is some of the clips are getting the audio doubled. so its like its just looping the audio in the clip. Its not all of the clips that get their audio tracks looped its just some of them and i cant figure out what the issue could be.

To be clear the videos arnt doubling its just the audio track within some of the videos. I even checked to be sure im not sending the same video more then once.

['output\section_6\Intro.mp4', 'output\section_6\video_with_audio\1.mp4', 'output\section_6\video_with_audio\2.mp4', 'output\section_6\video_with_audio\3.mp4', 'output\section_6\video_with_audio\4.mp4', 'output\section_6\video_with_audio\5.mp4', 'output\section_6\video_with_audio\6.mp4', 'output\section_6\video_with_audio\7.mp4', 'output\section_6\video_with_audio\8.mp4', 'output\section_6\video_with_audio\9.mp4', 'output\section_6\video_with_audio\10.mp4', 'output\section_6\video_with_audio\11.mp4', 'output\section_6\video_with_audio\12.mp4', 'output\section_6\video_with_audio\13.mp4', 'output\section_6\video_with_audio\14.mp4', 'output\section_6\video_with_audio\15.mp4', 'output\section_6\video_with_audio\16.mp4', 'output\section_6\video_with_audio\17.mp4', 'output\section_6\video_with_audio\18.mp4', 'output\section_6\video_with_audio\19.mp4', 'output\section_6\video_with_audio\20.mp4', 'output\section_6\video_with_audio\21.mp4', 'output\section_6\video_with_audio\22.mp4', 'output\section_6\video_with_audio\23.mp4', 'output\section_6\video_with_audio\24.mp4', 'output\section_6\video_with_audio\25.mp4', 'output\section_6\video_with_audio\26.mp4', 'output\section_6\video_with_audio\27.mp4', 'output\section_6\video_with_audio\28.mp4', 'output\section_6\video_with_audio\29.mp4', 'output\section_6\video_with_audio\30.mp4', 'output\section_6\video_with_audio\31.mp4', 'output\section_6\video_with_audio\32.mp4', 'output\section_6\video_with_audio\33.mp4', 'output\section_6\video_with_audio\34.mp4', 'output\section_6\video_with_audio\35.mp4', 'output\section_6\video_with_audio\36.mp4', 'output\section_6\video_with_audio\37.mp4', 'output\section_6\video_with_audio\38.mp4', 'output\section_6\video_with_audio\39.mp4', 'output\section_6\video_with_audio\40.mp4']

@LindaLawton LindaLawton added the question Questions regarding functionality, usage label Apr 21, 2024
@ninjaa
Copy link

ninjaa commented Apr 25, 2024

Hmmm. few things you could look at

  1. cycle through the clips and see if they have both c.duration and c.audio set, and doublecheck that the durations are accurate.
  2. pass the write_logfile=True parameter. This will print out a logfile with the same name as the output movie
  3. Try using another audio_codec? Or just not specifying it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions regarding functionality, usage
Projects
None yet
Development

No branches or pull requests

2 participants