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

Actual command string #76

Closed
yeahbutwalter opened this issue Nov 17, 2016 · 6 comments
Closed

Actual command string #76

yeahbutwalter opened this issue Nov 17, 2016 · 6 comments

Comments

@yeahbutwalter
Copy link

Is there a way to get the actual string being executed? Would be extremely useful for debugging.

@bramp
Copy link
Owner

bramp commented Nov 17, 2016

First off, how are you executing the command? This library provides a few different ways.

You may call the FFmpegBuilder.build() to get a List of the arguments, for example:

List<String> args = new FFmpegBuilder()
  .setInput("input.mp4")
  .addOutput("output.mp4")
  .build()

If you call

FFmpeg ffmpeg = new FFmpeg("/path/to/ffmpeg");
ffmpeg.run(builder)

then that basically calls .build(), and prepends the path to ffmpeg. It may change the arguments slightly if you are using the SinglePassFFmpegJob or TwoPassFFmpegJob.

You could also hook into FFmpeg, for example:

ffmpeg = new FFmpeg("/path/to/ffmpeg", new ProcessFunction() {

  final ProcessFunction runner = new RunProcessFunction();

  @Override
  public Process run(List<String> args) throws IOException {
    System.out.println(args);
    return runner.run(args);
  }
});

I'm open to suggestions on a way to make this easier for your usecase.

@bramp bramp added the question label Nov 17, 2016
@yeahbutwalter
Copy link
Author

FFmpegBuilder.build() is protected. It would be neat to be able to do

FFmpegBuilder builder = new FFmpegBuilder()
    .setInput(infile)             
    .addInput(sampleWatermarkImg)
    .overrideOutputFiles(true) 
    .addOutput(destFile)   
    .setVideoCodec(codec)     
    .addExtraArgs(extraArgs)  
    .setVideoFrameRate(24, 1)     
    .setVideoResolution( iwidth , newHeight) 
    .setComplexVideoFilter("overlay=main_w-overlay_w-10:main_h-overlay_h-10")
    .setStrict(FFmpegBuilder.Strict.EXPERIMENTAL) 
    .done();

  log.debug( "Running ffmpeg as " + builder.getExecString());

or similar. Just to see what exactly is being called for debugging.

@yeahbutwalter
Copy link
Author

I have a situation where the same code works on a windows machine but not on Debian. The error I get is

[NULL @ 0x3c0eca0] Unable to find a suitable output format for ''

Which is why I really would like to see the exact command being executed rather than a list of arguments.

@yeahbutwalter
Copy link
Author

The culprit turns out to be

.addExtraArgs(extraArgs)

The args list is

[/home/peter/ffmpeg-3.2-64bit-static/ffmpeg, -y, -v, error, -i, /opt/foo/sb_video/original/fdafc21385a841f3acb3fd7cd1912975.mp4, -i, /opt/foo/sb_images/sb_watermark_25.png, -strict, experimental, -vcodec, libx264, -s, 852x480, -r, 24/1, -filter_complex, overlay=main_w-overlay_w-10:main_h-overlay_h-10, , /opt/foo/sb_video/sample/fdafc21385a841f3acb3fd7cd1912975.mp4]

where the culprit is the empty argument. For some reason this works on windows but not on Debian. With a clear command string I could have spotted this in the logs rightaway.

Anyways, thanks again for a great lib!

@bramp
Copy link
Owner

bramp commented Nov 18, 2016

build() being protected is a oversight and I will change that.

I will also not allow empty extra args.

Finally, the reason it is return as a list of arguments is because that is how it is passed to the ffmpeg binary. For example if there is a single element in the array with spaces in the middle, when it is executed the process see it as if the full argument had quotes around it.

However, I guess there is a subtle difference in how window and Linux parses a empty arguments.

I'll keep this bug open while I address my first two points.

@bramp bramp reopened this Nov 18, 2016
bramp added a commit that referenced this issue Nov 20, 2016
@bramp
Copy link
Owner

bramp commented Nov 20, 2016

Ok, build() is actually public, and has been for a while. I suspect you are using a older version, please update to the latest version (currently 0.6.1).

I've pushed be6fbe8 to check that at-least one argument is passed to addExtraArgs(...) and that the first argument is not a blank string.

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

No branches or pull requests

2 participants