2

I want to reproduce this command

ffmpeg -i image.png -i audio.wav -acodec libvo_aacenc -vcodec libx264 output.flv

with PHP-FFMpeg

I can't find in documentationa way to add multiple input file (-i image.png -i audio.wav)

Filo
  • 2,829
  • 1
  • 21
  • 36
  • 2
    PS: Do not use `libvo_aacenc`; it's very low quality. Use `libfdk_aac` or `aac` instead. – slhck Jul 17 '17 at 11:42
  • 1
    Quickly sweeping trough the relevant code parts, looks like you can add multiple video- and audio streams to the FFmpeg object, but I'm not sure if it can handle it. Try to issue the `open()` function multiple times, and see if that works... I'm almost sure that it can handle it if the video and audio streams are from different files. But multiple streams of the same type... well, it's not guaranteed to work. – Gergely Lukacsy Jul 17 '17 at 12:17

2 Answers2

1

This is currently not possible. It's a feature request, open since 2013.

My guess is that the library was built around being able to handle only one open stream, which makes the refactoring required a little harder.

Best to run the command manually.

slhck
  • 36,575
  • 28
  • 148
  • 201
  • Thank you for pointing it out! I found a little "hack" that seems to work... https://stackoverflow.com/a/45193948/3625883 – Filo Jul 19 '17 at 14:43
  • 1
    Heh, yeah, that will probably work :) I'll leave my answer posted but I can also delete it if you want. – slhck Jul 19 '17 at 15:12
1

I found a simply solution (hack): to add the second input as a filter

$video = $this->ffmpeg->open($imageSource);
$video->addFilter(new SimpleFilter(['-i ', $audioSource]));

it seems to works as expected

Filo
  • 2,829
  • 1
  • 21
  • 36