I am trying to extract information from a video file (mp4) using ffmpeg in a Lazarus 2.0.0 program. The command I want to use is:
ffmpeg -i testvideo.mp4 -hide_banner (with a file name selected in Lazarus of course) I created this test function: uses Process; function TForm1.GetVideoInfo(videofile: string): string; (* ffmpeg -i testvideo.mp4 -hide_banner *) var i: integer; arguments: array of string; returnstr: string; executable: string; begin Result := ''; lbxResult.Clear; SetLength(arguments,3); executable := 'c:\Programs\ffmpeg\bin\ffmpeg.exe'; arguments[0] := '-i'; arguments[1] := videofile; arguments[2] := '-hide_banner'; if RunCommandIndir(ExtractFileDir(videofile),executable,arguments, returnstr) then Result := returnstr else Result := 'Failed to run command'; end; I call this from a button event: procedure TForm1.btnSelectVideoClick(Sender: TObject); begin dlgOpen.InitialDir := ReadIniString('Files', 'VideoDir', ''); if not dlgOpen.Execute then exit; FVideoDir := ExtractFileDir(dlgOpen.FileName); FVideoFile := dlgOpen.FileName; edInputFile.Text := FVideoFile; WriteIniString('Files', 'VideoDir', FVideoDir); WriteIniString('Files', 'VideoFile', FVideoFile); lbxResult.Items.Text := GetVideoInfo(FVideoFile); end; PROBLEM: ---------- It always returns the error message "Failed to run command". If I use the ffmpeg command used in the GetVideoInfo function directly in a command window in the directory containing the video file it works just fine (long lines are wrapped by the news reader): D:\VIDEO\USA\test>ffmpeg -i testvideo.mp4 -hide_banner Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'D:\VIDEO\USA\test\testvideo.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isommp42 creation_time : 2018-11-17T02:08:51.000000Z Duration: 00:42:54.54, start: 0.000000, bitrate: 377 kb/s Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 302 kb/s, 30 fps, 30 tbr, 15360 tbn , 60 tbc (default) Metadata: creation_time : 2018-11-17T02:08:51.000000Z handler_name : ISO Media file produced by Google Inc. Created on: 11/16/2018. Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 71 kb/s (default) Metadata: creation_time : 2018-11-17T02:08:51.000000Z handler_name : ISO Media file produced by Google Inc. Created on: 11/16/2018. At least one output file must be specified I want to parse this text to extract the video playing time and some other data but I get a false result from the call to RunCommandIndir() and the string variable supposed to hold the returned data is empty. What have I done wrong here? -- Bo Berglund Developer in Sweden -- _______________________________________________ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus