0

In my code i have this line:

self.p1 = Popen([self.ffmpeg_path,'-y','-loglevel','quiet','-i',self.retransmition_url,'epalxeis-radio.mp3'],stdin=PIPE,stdout=PIPE,stderr=PIPE, bufsize=1)

which read an web radio stream and saves it locally with filename "epalxeis-radio.mp3"

Using python to launch the script - works! Using pyinstaller to launch the exe - works! Using InnoSetup to launch the exe after installation - not working :(.

The problem is that there is no epalxeis-radio.mp3 created when i try the third case (innosetup).

The ffmpeg_path is: self.ffmpeg_path = os.path.abspath("extra/ffmpeg.exe") and there is the extra folder in the same directory which is the innosetup exe.

From Windows task manager there is no ffmpeg.exe shown in the tasks list.

What wrong?

Edit: I used a smaller script to test the error:

from subprocess import Popen, DEVNULL, STDOUT, PIPE
import os
import time
ffmpeg_path = os.path.abspath("extra/ffmpeg.exe")
retransmition_url = "http://shaincast.caster.fm:40636/listen.mp3?authn76260dc1cdf44a9132c0b63f85d9c67a"
with Popen([ffmpeg_path,'-y','-loglevel','quiet','-i',retransmition_url,'epalxeis-radio.mp3'],stdin=PIPE,stdout=PIPE,stderr=PIPE) as p1:
    time.sleep(1)

in pyinstaller exe runs, but in innosetup exe stop immediately.

Chris P
  • 2,059
  • 4
  • 34
  • 68

1 Answers1

0

The problem was that ffmpeg will want write permission in a folder that application doesn't have write permission.

So to solve this problem, i change self.ffmpeg_path to C:/extra/(ff****.exe) And then append this path to system enviroment variables by adding a registry entry in innosetup file.

Code:

[Registry]
Root: HKCU; Subkey: "Environment"; \
    ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};C:\extra"

To avoid repeated entries after uninstall - reinstall, use this code as suggested here:

[Registry]
Root: HKCU; Subkey: "Environment"; \
    ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};C:\extra"; \
    Check: NeedsAddPath('C:\extra')


[Code]

function NeedsAddPath(Param: string): boolean;
var
  OrigPath: string;
begin
  if not RegQueryStringValue(HKEY_CURRENT_USER,
    'Environment',
    'Path', OrigPath)
  then begin
    Result := True;
    exit;
  end;
  { look for the path with leading and trailing semicolon }
  { Pos() returns 0 if not found }
  Result := Pos(';' + Param + ';', ';' + OrigPath + ';') = 0;
end;
Chris P
  • 2,059
  • 4
  • 34
  • 68