Reputation: 2715
I am trying to get the example from here working to record a webpage with phantomjs and pipe the stdout, which are images, to the ffmpeg command to create the video. The command stated that you need to run is:
phantomjs runner.js | ffmpeg -y -c:v png -f image2pipe -r 25 -t 10 -i - -c:v libx264 -pix_fmt yuv420p -movflags +faststart dragon.mp4
If I run a similar version of that command directly in the terminal, I can get it working just fine. The issue is that I need to run the above command through the Golang os/exec package. With the:
cmd := exec.Command(parts[0], parts[1:]...)
method, the first parameter is the base executable of the command being executed and it is not honoring the pipe. I would like to get this working in one command so I don't have to write all the images to files and then run a second ffmpeg command to read from all of those images. Any suggestions?
Upvotes: 3
Views: 5846
Reputation: 540
I think this will help you.
cmd := "phantomjs runner.js | ffmpeg -y -c:v png -f image2pipe -r 25 -t 10 -i - -c:v libx264 -pix_fmt yuv420p -movflags +faststart dragon.mp4"
output, err := exec.Command("bash","-c",cmd).Output()
if err != nil {
return fmt.Sprintf("Failed to execute command: %s", cmd)
}
fmt.Println(string(output))
Upvotes: 11