ffmpeg-cli-wrapper icon indicating copy to clipboard operation
ffmpeg-cli-wrapper copied to clipboard

FFmpegBuilder to parse the full ffmpeg command string

Open qinfchen opened this issue 6 years ago • 3 comments
trafficstars

Is your feature request related to a problem? Please describe. There is a wiki that shows examples of how to convert a ffmpeg command string to FFmpegBuilder instance. So it seems like many people have trouble converting some of the commands.

Describe the solution you'd like It would be extremely helpful and useful if FFmpegBuilder can parse a ffmpeg command string and turn it to a FFmpeg instance. This would make this library a lot easier to use and more useful IMO.

qinfchen avatar Sep 11 '19 14:09 qinfchen

I guess if you just want a normal command line string, why not invoke ProcessBuilder directly? I think the purpose of the library is to construct the command line string.

However, I'm happy to understand the use case more.

bramp avatar Sep 11 '19 16:09 bramp

Sure. I have a service that runs these commands in separate threads and these commands are configurable by users. so I'd like to validate ffmepg arguments first and make sure that the command is valid to prevent arbitrary code execution.

qinfchen avatar Sep 11 '19 16:09 qinfchen

friendly ping, any thoughts?

qinfchen avatar Mar 28 '20 02:03 qinfchen

Sorry for the late update:

The way we and ffmpeg handle parameters makes this extremely hard. A general ffmpeg command has the following structure: ffmpeg {global options} ({input options} {input})+ ({output options} {output})+

We don't implement all existing options (not all documented default options). We have to append extra options to global, input, and output to allow most commands still.

Currently, inputs are only partially supported, there not handled in the correct way. But even if we would handle them according to the specification, given a ffmpeg command like this: ffmpeg -y -unknown -to ..., We couldn't determine if the "unknown" flag should be mapped to the first input or if it belongs to the global options.

More severe: ffmpeg ... -unknown output.mp4 .... Depending on -unknown, output.mp4 might be an actual output file or another parameter.

Last: There is no existing code for us to perform a reverse mapping. This would essentially double our mappings, as we would have to do them both ways and add all the synonyms ffmpeg supports on top of that. I would love to implement this over our existing serialization method, but we must rewrite much of our internal handling.

We can approach a minimal version (without extra args) after #318 if you're still interested in this. Feel free to re-open or start a new issue if interested.

Euklios avatar Mar 13 '24 15:03 Euklios