moviepy icon indicating copy to clipboard operation
moviepy copied to clipboard

Moviepy disabling escape characters

Open Azrielx86 opened this issue 2 years ago • 2 comments

Expected Behavior

It's supposed to print the progress on a single line.

C:\Users\edgar\Desktop>python test.py
>56.00% (56 of 100)

Actual Behavior

But when importing it, escape characters are ignored.

C:\Users\edgar\Desktop>python test.py
>0.00% (0 of 100)
>1.00% (1 of 100)
>2.00% (2 of 100)
>3.00% (3 of 100)
>4.00% (4 of 100)
>5.00% (5 of 100)
>6.00% (6 of 100)
>7.00% (7 of 100)
>8.00% (8 of 100)

Steps to Reproduce the Problem

from time import sleep
from moviepy import editor as mp

def print_progress(progress, current, end):
    print(f'\033[K>{progress:.2f}% ({current} of {end})\033[F\n', end='')
    sleep(0.2)

end = 100
for i in range(end):
    print_progress(i * 100 / end, i, end)

It only happens when importing moviepy.

Specifications

  • Python Version: Python 3.10.4
  • Moviepy Version: 1.0.3
  • Platform Name: Windows
  • Platform Version: 11 21H2

Azrielx86 avatar Jul 29 '22 01:07 Azrielx86

Sorry, can you explain a bit better what (you think) this has to do with MoviePy? I'm having trouble identifying the underlying problem from your description, so can't tag this issue.

keikoro avatar Aug 23 '22 18:08 keikoro

Your issue reminds me of #1751, please look at my comments there and report back here (or close the issue if it turns out your problem is of the same nature).

keikoro avatar Aug 23 '22 18:08 keikoro

Closing due to lack of response.

keikoro avatar Oct 10 '22 22:10 keikoro

@keikoro Hi, I came across the same issue. It seems like moviepy disables ANSI escape code on the command line. For example, the following code uses escape code to generate orange output in terminal:

print('\u001B[38;2;255;128;0m hello \u001B[39m')

image

But once moviepy is imported, the color is no longer displayed:

import moviepy

print('\u001B[38;2;255;128;0m hello \u001B[39m')

image

This issue can be reproduced on windows Terminal (not on PyCharm). Maybe this library changes the terminal running environment? I have no idea.

wzy1935 avatar Jan 19 '23 09:01 wzy1935

@wzy1935 Thanks for the helpful comment. I'll reopen the issue – could you still add your system/install specs to yours (like in our issue templates)?

keikoro avatar Feb 06 '23 23:02 keikoro

@keikoro Sure,

Specifications

  • Python Version: 3.10.5
  • MoviePy Version: 2.0.0.dev2 (installed by hand with branch master)
  • Platform Name: Windows 11 Home
  • Platform Version: 10.0.22621

wzy1935 avatar Feb 07 '23 12:02 wzy1935