Recent

Author Topic: TProcess ffmpeg freezes  (Read 932 times)

domasz

  • Hero Member
  • *****
  • Posts: 527
TProcess ffmpeg freezes
« on: August 07, 2024, 05:49:45 pm »
I just want to save first frame from MP4 file as PNG. The same code works fine for other programs (like imagemagick) but for some reason ffmpeg freezes. When I run the command normally (from cmd) ffmpeg doesn't wait for enter or any other key, just exits.

Code: Pascal  [Select][+][-]
  1.   Proc := TProcess.Create(nil);
  2.   Proc.CommandLine := 'ffmpeg -i "input.mp4" -vframes 1 thumb.png';
  3.  
  4.   Proc.Options := [poWaitOnExit];
  5. //  Proc.ShowWindow := swoHIDE;
  6.   Proc.Execute;
  7.   Proc.Free;  
« Last Edit: August 07, 2024, 06:03:30 pm by domasz »

Hartmut

  • Hero Member
  • *****
  • Posts: 803
Re: TProcess ffmpeg freezes
« Reply #1 on: August 07, 2024, 06:00:26 pm »
try "ffmpeg" instead of "fmpeg" in line 2

domasz

  • Hero Member
  • *****
  • Posts: 527
Re: TProcess ffmpeg freezes
« Reply #2 on: August 07, 2024, 06:03:22 pm »
Thanks, but that's not the problem.

Hartmut

  • Hero Member
  • *****
  • Posts: 803
Re: TProcess ffmpeg freezes
« Reply #3 on: August 07, 2024, 06:06:56 pm »
Did you set the correct working dir?
Maybe you must specify the path to ffmpeg.
Which OS do you use?
« Last Edit: August 07, 2024, 06:08:29 pm by Hartmut »

domasz

  • Hero Member
  • *****
  • Posts: 527
Re: TProcess ffmpeg freezes
« Reply #4 on: August 07, 2024, 06:18:09 pm »
All dirs are fine. Ffmpeg does launch just fine, it loads the correct file. It just doesn't quit on it's own.

OS: Windows 10.

Hartmut

  • Hero Member
  • *****
  • Posts: 803
Re: TProcess ffmpeg freezes
« Reply #5 on: August 07, 2024, 06:27:05 pm »
That means, file "thumb.png" is correctly created and after that ffmpeg hangs?

If file "thumb.png" already exists, than it can be that ffmpeg asks if to overwrite it. This can be suppressed with parameter -y

BildatBoffin

  • New Member
  • *
  • Posts: 27
Re: TProcess ffmpeg freezes
« Reply #6 on: August 07, 2024, 06:30:56 pm »
In case you are piping you must consume stdout. Does not seem to be the case here tho.

domasz

  • Hero Member
  • *****
  • Posts: 527
Re: TProcess ffmpeg freezes
« Reply #7 on: August 07, 2024, 06:50:32 pm »
Sorry guys. You are all right and the code does work. I had a problem somewhere (kinda) else.

Before I try to convert with ffmpeg I try with imagemagick. And imagemagick found ffmpeg.exe and tried to convert the file with ffmpeg and froze, for some reason. I renamed ffmpeg to ffmpeg2 and now it works nicely.

 

TinyPortal © 2005-2018