0

I am trying to pipe images using windows Powershell

Get-Content  test_*.bmp  | .\ffmpeg  -framerate 1 -i -   -c:v libx264 -r 25 -pix_fmt yuv420p -y video.mp4

Unfortunately, everything is working fine except that the resulting video is corrupted.

Then I tried a simple command in PowerShell like this:

Get-Content  test.bmp  > simple.bmp

This is corrupting the image very similar to the video I created earlier.

Is there a method to PIPE images to FFmpeg using Windows Powershell?

  • Hmmm... I'm not in front of a computer at the moment to test that out but try adding the '' -raw switch parameter to get-content. – Sage Pourpre Nov 25 '21 at 11:08
  • 1
    Maybe by specifying the encoding to byte in addition to the `-raw ` switch `Get-Content -Path 'FilePath' -Encoding byte -Raw` – Sage Pourpre Nov 25 '21 at 11:15
  • What is the single hyphen in your ffmpeg command line for? – Theo Nov 25 '21 at 12:18
  • 2
    In short: As of PowerShell 7.2, output from external programs is invariably decoded _as text_ before further processing, which means that raw byte output cannot be captured with `>`, for instance. See the linked duplicate for details. The workaround is to call your external program via `cmd /c` (Windows) / `sh -c` (Unix-like platforms) and use _their_ `>` operators. – mklement0 Nov 25 '21 at 17:31
  • @Theo single hyphen is equivalent to "pipe:0". It will take the pipe as input. – user2957427 Nov 26 '21 at 10:38
  • 1
    @mklement0 thanks for the answer. It worked. I was reluctant about the 'type', since it was used for merely text files. But it worked on .bmp files. – user2957427 Nov 26 '21 at 10:39

0 Answers0