Hi everyone, I'm using 3 commands to slice a video, add watermark on it and convert it to gif animation through ffmpeg nad PHP, how can use these commands to execute at once, commands are: exec('ffmpeg -ss 00:00:08 -i movie.mp4 -to 00:00:10 -c copy -copyts output.mp4'); PHP: exec('ffmpeg -i output.mp4 -i watermark.jpg -filter_complex "[1:v]scale=-1:120*(1/6)[wm];[0:v][wm]overlay=x=main_w-overlay_w-main_w/20:y=main_h-overlay_h-main_w/20" output2.mp4'); PHP: exec('C:\xampp\ffmpeg.exe -i cut.mp4 -pix_fmt rgb24 output.gif'); PHP:
Yes, I'm windows user, And I'm trying to avoid from saving file everytime, proceed all processes at once
Shouldn't something like this work: exec('ffmpeg -ss 00:00:08 -i movie.mp4 -to 00:00:10 -i watermark.jpg -filter_complex "[1:v]scale=-1:120*(1/6)[wm];[0:v][wm]overlay=x=main_w-overlay_w-main_w/20:y=main_h-overlay_h-main_w/20" -pix_fmt rgb24 output.gif'); PHP: Not tested, mind, but taken out all the copying - the only thing I didn't use was the "-c copy -copyts" but as far as I can see that shouldn't be needed as long as you're not remaking the file.
Try running it via command-line, to see what error it gives, or look at the PHP-logs or other logs to see if there's an error there.
Option to (record or transcode stop time) cannot be applied to input file watermark.jpg -- you are trying to apply an input option to an output file or vice versa. Move this option before the file it belongs to. Error parsing options for input file watermark.jpg. Error opening input files: Invalid argument Code (markup):
Aha. Oh, well. You can probably put all of them in one exec(), at least - although I don't exactly remember the syntax. Each string separated by one |, maybe?
Dear But I want to avoid from saving multiple files, like first created cut file from main file, seconds it generates with watermark, and then It saves the gif file, I want to execute all commands and save a single file
Well.. I get that. However, right now, I don't know how But if the concern is the multiple files added, just remove the extra files after running through the commands?
If you're worried about generating duplicate files halfway, you could always use the tempnam() command
I mean It takes time to read file for watermark and after that again get a file and save, It takes time to proceed
Run it on an SSD-drive. The file-fetching will make minimal impact, the real time-consume is the actual processing of the files by ffmpeg.