Trying to chain processes together on a pipeline

Andrew Berg bahamutzero8825 at gmail.com
Sat Jul 2 14:25:39 CEST 2011


This code is working:
>     try:
>         ffmpeg_proc = subprocess.Popen(queue[position].ffmpeg_cmd,
> stdout=subprocess.PIPE, stderr=open(os.devnull, 'w'))
>     except WindowsError as exc:
>         log_windows_error(exc, queue[position].ffmpeg_cmd, 'critical')
>         break
>     if queue[position].vol != 1:
>         try:
>             sox_proc = subprocess.Popen(queue[position].sox_cmd,
> stdin=ffmpeg_proc.stdout, stdout=subprocess.PIPE,
> stderr=open(os.devnull, 'w'))
>             wav_pipe = sox_proc.stdout
>         except WindowsError as exc:
>             log_windows_error(exc, queue[position].sox_cmd, 'critical')
>             break
>         finally:
>             ffmpeg_proc.stdout.close()
>     else:
>         wav_pipe = ffmpeg_proc.stdout
>     try:
>         nero_aac_proc = subprocess.Popen(queue[position].nero_aac_cmd,
> stdin=wav_pipe)
>     except WindowsError as exc:
>         log_windows_error(exc, queue[position].nero_aac_cmd, 'critical')
>         break
>     finally:
>         if queue[position].vol != 1:
>             sox_proc.stdout.close()
>         else:
>             ffmpeg_proc.stdout.close()
>     ffmpeg_proc.wait()
>     if queue[position].vol != 1:
>         sox_proc.wait()
>     nero_aac_proc.wait()
I can't figure out what I changed since the last time I tried and
failed, though; I only ran it again after directing the stderr of FFmpeg
and SoX to actual files to see if they could gives me any clues.



More information about the Python-list mailing list