phpvideotoolkit-v2 icon indicating copy to clipboard operation
phpvideotoolkit-v2 copied to clipboard

Generate command without create file

Open cassianotartari opened this issue 10 years ago • 4 comments

Hello!

Is there a way to get the ffmpeg command that will be executed without run any save method?

My idea is to store in a database these commands to a service consume them.

Thanks.

cassianotartari avatar Mar 31 '15 19:03 cassianotartari

I've been working those day with PVT v2 and I don't know. I think you would use the $process->getExecutedCommand(); But in all cases I used this after a: $process->saveNonBlocking($out_path,$out_fmt,Video::OVERWRITE_EXISTING);

I would also be interested by your need to log the command before any exception to be catched by the save procedure.

What I would do, but not the good way for sure... but might be a way... I would try to save with a dummy path, that could be replaced later, a false and undifined path and id exemple: /where/to/output/id_123456789.mp4

Then some exception will be catched, and you might be able to retrieve the command at this time, because the output path will not be fine.

Not sure if it will be thrown by PVT or FFMPEG, I think PVT might check if the outputpath exists before sending the command to FFMPEG.

Of course, I repeat, NOT the right way, just an idea until some expert answer will be made ;)

Have a nice day!

kemar-and avatar Apr 01 '15 06:04 kemar-and

Sorry not currently, but it wouldn't be to hard to duplicate the Media::save function stripping out any pre-processing and progress handler functionality and then return the following at the end of the function

return $this->_process->getExecBuffer()->getExecString();

The string would include the error, status and completion boundaries, however they wouldn't be to hard to regex out if not needed.

buggedcom avatar Apr 02 '15 16:04 buggedcom

If you do write your own function please submit a pull request.

buggedcom avatar Apr 02 '15 17:04 buggedcom

Sorry for late answer. I was coding something here, the closest I got is something like this, rewriting save method extending PHPVideoToolkit\Video:

        public function getCommand($save_path=null, Format $output_format=null, $overwrite=Media::OVERWRITE_FAIL, ProgressHandlerAbstract &$progress_handler=null)
        {
//          set the input files.
            $this->_process->setInputPath($this->_media_file_path);

//          loop and process the save path to multioutput so we can loop
            $multi_output = $this->_convertOutputPathToMultiOutput($save_path, $output_format);
            $index = 0;

            foreach ($multi_output as $save_path => $output_format)
            {
//              increment the output index so the process moves on to the next process to build if the loop continues.
                $this->_process->setOutputIndex($index);
                $index += 1;

//              add the commands from the output format to the exec buffer
//              NOTE; this cannot be done in _savePreProcess as it must be done after, to ensure all the subclass
//              _savePreProcess functionality and main media class functionality is properly executed.
                $this->_saveAddOutputFormatCommands($output_format);

//              update the output path as the processing path?
                $this->_process->setOutputPath($save_path);
            }
            return $this->_process->getExecBuffer()->getCommand();
        }

I'm not a pro programmer so maybe there is a better way to do that, please correct me if I did something wrong. After that maybe I can create a PR adding the method to Video class.

Thanks

cassianotartari avatar Apr 06 '15 19:04 cassianotartari