Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get formed FFMPEG cli command as string #348

Open
phtaran opened this issue Apr 17, 2023 · 2 comments
Open

Cannot get formed FFMPEG cli command as string #348

phtaran opened this issue Apr 17, 2023 · 2 comments

Comments

@phtaran
Copy link

phtaran commented Apr 17, 2023

Hi,

Currently the library provides ability to build command for ffmpeg in builder-like style and then execute it, but I didn't find a way how to get raw ffmpeg command which will be executed
Result of execution contains some useful data about processing, though also misses what command was executed

To Reproduce

var result = FFmpeg.atPath()
    .addInput(UrlInput.fromUrl(pathToSrc))
    .setOverwriteOutput(true)
    .addArguments("-movflags", "faststart")
    .addOutput(UrlOutput.toUrl(pathToDst))
    .execute()    // how to get command which will be executed?

Expected behavior
extra method or way to get raw ffmpeg command. Smth like this:

ProcessHandler<FFmpegResult> runner = Ffmpeg.atPath()
                       ... // constructing command
                       .build(); 
String rawCliCommand = runner.getRawCmd();                       
runner.execute();

currently, I din't find a way how to solve this via subclassing, because I cannot override ProcessHandler<FFmpegResult> runner creation to create another runner with extended info.

Additional context

Cases where raw ffmpeg command is useful

  • unit tests - I want to have regression that I create proper commands
  • logs - I want to add ffmpeg command to error logs to immediately correlate what command produced an error, especially if logs contain several executions in parallel. Jafree has logs but I cannot override them anyhow and having way to obtain raw ffmpeg command gives more possibilities for custom logs.

any feedback is appreciated, if you can implement these possibilities or just advise how I can bypass this with some workarounds, for instance how to override and enhance this behavior without creating separate fork. Thanks.

P.S. I really like this lib, good and convenient api.

@kokorin
Copy link
Owner

kokorin commented Apr 21, 2023

Sorry for late reply, cli command is logged, please check logging framework configuration.
Regarding regression tests, I'm not sure it can be useful. It looks like CLI command builder testing. Instead I would suggest validation of ffmpeg/ffprobe results, it makes sense to use the same media files as inputs to make sure tests are stable. For more details about that you can check tests in Jaffree itself and Artifacts class in particular.
Regarding parallel execution of several Jaffree processes: logback classic allows adding of thread name to log message. If that is not enough you can add custom log suffix using Jaffree API

@phtaran
Copy link
Author

phtaran commented Apr 23, 2023

so your idea is to use integration tests and verify result via ffprobe. It makes sense, though I would like to have kind of unit tests, where I execute some logic and then can check what command is formed to make sure my logic works fine. This is one use case. Also, I didn't find how to test certain cases in the way you said. For example, I scale video to different aspect ratio and use padding with black borders - it seems not possible or difficult to test that video scaled correctly and has black borders. But I could check at least command I formed.
No push for this, just wondering - is it difficult to implement getting command with minimal intrusiveness, so maybe I could contribute to this? One way I see is providing adding getter to ProcessHandler and adding getter for it in Ffmpeg class. Another option is to add command to execution result (what Ffmpeg...execute() returns) and exceptions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants