Program uses the threading module but I did not notice any parallelism in the execution. What's wrong?

1

I made a script to decrease the quality of some mp3s by calling the ffmpeg program through the subprocess module. I added Threads thinking of doing the process in parallel for several files at the same time. The program works but I have seen NO parallelism. I kept track of the program and noticed that apparently it is "converted" one MP3 at a time. Where is the parallelism? What did I do wrong?

I also noticed that, running through IDLE, the '' released '' prompt even though the program continues to run, ie I can not tell when it has finished ...

import subprocess

from threading import Thread


def ConverteMusica(a):

    input_file_fmt = '{}.mp3'
    output_file_fmt = a

    for x in range(1, 5):
        subprocess.call(['ffmpeg',
                         '-i',
                         input_file_fmt.format(x),
                         '-acodec',
                         'libmp3lame',
                         '-ac',
                         '2',
                         '-ab',
                         '16k',
                         '-ar',
                         '44100',
                         output_file_fmt.format(x)])


MeuConversor1 = Thread(target=ConverteMusica,args=["Personalidades_Famosas_Elogiam_Cultura_Vedica.mp3"])
MeuConversor2 = Thread(target=ConverteMusica,args=["Sri_Caitanya_caritamrta_Madhya_lila_20_378_Aula_100.mp3"])
MeuConversor3 = Thread(target=ConverteMusica,args=["Sri_Caitanya_caritamrta_Madhya_lila_22_1_Aula_101.mp3"])
MeuConversor4 = Thread(target=ConverteMusica,args=["Sri_Caitanya_caritamrta_Madhya_lila_22_66_Aula_102.mp3"])


MeuConversor1.start()
MeuConversor2.start()
MeuConversor3.start()
MeuConversor4.start()
    
asked by anonymous 10.04.2018 / 02:14

0 answers