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

Problems with VideoFileClip() at the moment of audio processing #2137

Open
kaynshae opened this issue Mar 14, 2024 · 1 comment
Open

Problems with VideoFileClip() at the moment of audio processing #2137

kaynshae opened this issue Mar 14, 2024 · 1 comment
Labels
bug Issues that report (apparent) bugs.

Comments

@kaynshae
Copy link

I ran into a problem, I process a large number of videos, but on some videos the script just gets up and does nothing. I wondered why this is so?

As a result, the problem is in the line(everything is running before it):
s = self.proc.stdout.read(L) in read_chunk() readers.py . It just doesn't output anything.

The bottom line is that videos that have sound, process everything correctly, then I started testing videos that don't have sound, for some reason self.reader.infos['audio_found'] == True. Because of this, audio editing is being launched. Then everything is fine, the result is self.proc =={'bufsize': 200000, 'stdout': -1, 'stderr': -1, 'stdin': -3, 'creationflags': 134217728}, the same as in a normal video. self.proc.stdout == <_io.BufferedReader name=6> as in a normal video, but when another read() element is added, the script just freezes.

I couldn't come up with a solution. So I'm informing you about it.

I understand that this is most likely a problem with the file itself. Since the properties of the video file display the audio stream rate and so on. Although in fact there is no sound.

But, I need some more checking, waiting, I don't know. If, for example, there is no response within 3 minutes, the script throws an error.

@kaynshae kaynshae added the bug Issues that report (apparent) bugs. label Mar 14, 2024
@kaynshae
Copy link
Author

kaynshae commented Mar 15, 2024

Fixed the problem via timeout. Checking the validity of the file via VideoFileClip. If no response has been received within 10 seconds, it ends.

import multiprocessing
import time
from moviepy.editor import VideoFileClip, CompositeVideoClip
import sys

def process_video_clip(video):
    dir_movies = r"D:\AutoMaterial Random\videos"
    with VideoFileClip(dir_movies + "\\" + video) as main_clip:
        sum = 1

if __name__ == '__main__':
    video = sys.argv[1]
    p = multiprocessing.Process(target=process_video_clip, args=(video,))
    multiprocessing.freeze_support()
    p.start()

    # We wait 10 seconds or until the process is completed
    p.join(10)

    if p.is_alive():
        print("Stop process")
        p.terminate()
        p.join()
        with open("file.txt", "w") as file:
            file.write("False")
            print("write False")
    else:
        with open("file.txt", "w") as file:
            file.write("True")
            print("write True")

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.
Projects
None yet
Development

No branches or pull requests

1 participant