kokorin / Jaffree

______ Stop the War in Ukraine! _______ Java ffmpeg and ffprobe command-line wrapper
Apache License 2.0
471 stars 80 forks source link

How to perform screen recorder using this library? #375

Closed kumarkrish85 closed 11 months ago

kumarkrish85 commented 11 months ago

Describe the issue I am trying to perform screen recording along with audio and save the file as .mp4, i have installed ffmpeg and added in the system path, i can execute the ffmpeg command from any windows path. But while executing it from the example code i am getting an error.

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Sample file If applicable, attach a file with which the issue can be reproduced

Expected behavior A clear and concise description of what you expected to happen.

Logs

ffmpeg -hide_banner -loglevel error -f dshow -i audio="@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{C96EF9E4-FF73-4008-97E1-01F0015E368B}" -f gdigrab -framerate 30 -i desktop -c:v libx264 %video_file_name%".mp4"

exception from the java console:

Exception in thread "main" com.github.kokorin.jaffree.process.JaffreeAbnormalExitException: Process execution has ended with non-zero status: -13. Check logs for detailed error message. at com.github.kokorin.jaffree.process.ProcessHandler.interactWithProcess(ProcessHandler.java:220) at com.github.kokorin.jaffree.process.ProcessHandler.execute(ProcessHandler.java:162) at com.github.kokorin.jaffree.ffmpeg.FFmpeg.execute(FFmpeg.java:421)

please help @kokorin

Additional context Windows using gdigrab

kokorin commented 11 months ago

What happens when you execute the above ffmpeg command from command line?

kumarkrish85 commented 11 months ago

I can successfully execute the ffmpeg command from command line and see the mp4 file with audio. The ffmpeg exes are saved inside C: folders.

cc: @kokorin

kokorin commented 11 months ago

Configure Jaffree (FFmpeg#setLogLevel) and log framework you use to print debug logs and post logs here. P.S. One should start with checking debug logs before creating issues

kumarkrish85 commented 11 months ago

Thanks @kokorin

Below are the exception after enabling logger.

15:29:37.603 [StdErr] ERROR com.github.kokorin.jaffree.process.BaseStdReader - [out#0/mp4 @ 0000023e51e49ec0] [fatal] Error opening output C:\twatme.mp4: Permission denied 15:29:37.620 [StdErr] ERROR com.github.kokorin.jaffree.process.BaseStdReader - [error] Error opening output file C:\twatme.mp4. 15:29:37.620 [StdErr] ERROR com.github.kokorin.jaffree.process.BaseStdReader - [fatal] Error opening output files: Permission denied Exception in thread "main" com.github.kokorin.jaffree.process.JaffreeAbnormalExitException: Process execution has ended with non-zero status: -13. Check logs for detailed error message. at com.github.kokorin.jaffree.process.ProcessHandler.interactWithProcess(ProcessHandler.java:220) at com.github.kokorin.jaffree.process.ProcessHandler.execute(ProcessHandler.java:162) at com.github.kokorin.jaffree.ffmpeg.FFmpeg.execute(FFmpeg.java:421) at org.example.Main.main(Main.java:40)

kokorin commented 11 months ago

And logs clearly show that the user which runs JVM has no permissions to create C:\twatme.mp4

kumarkrish85 commented 11 months ago

Thanks @kokorin i tried inside the folder where I have complete permission, it worked. Thanks for your help.