0

I have this function running fine from the editor. But when compiled with sx_Freese, I get the error NoneType' object has no attribute 'write'. I have found the line producing the error, but have no idea how to fix it.

def cut_out_a_movie_piece(movie_path, start1, stop1, start2=None, stop2=None):

    from moviepy.editor import concatenate_videoclips, VideoFileClip

    try:
        movie_name = pathlib.Path(movie_path).stem

        ext = pathlib.Path(movie_path).suffix

        folder = pathlib.Path(movie_path).parent

        new_full_path = os.path.join(folder,movie_name + ".mp4")

        clip1 = VideoFileClip(movie_path).subclip(start1,stop1)

        if start2 and stop2:
            clip2 = VideoFileClip(movie_path).subclip(start2,stop2)
            combined = concatenate_videoclips([clip1,clip2])
            combined.write_videofile(new_full_path)
        else:
            clip1.write_videofile(new_full_path) # this is the line 338, producing the error
            shutil.move(new_full_path,r'D:\_MUSIC\Filmi_Musica')
    except Exception as e:
        with open('Run_Scripts_ERROS.LOG', "a") as f:
            f.write(str(e))
            f.write('\n')
            f.write(f'line # ----> {e.__traceback__.tb_lineno}')
            f.write('\n')
            f.write(f'that was in cut_out_a_movie_piece')

Exception output:

'NoneType' object has no attribute 'write'
line # ----> 338

UPDATE

Compiling with pyinstaller I got no problems, so this particular problem is definitely connected somehow to sx_freeze.

LetzerWille
  • 5,355
  • 4
  • 23
  • 26

0 Answers0