-
Notifications
You must be signed in to change notification settings - Fork 115
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
Get from AudioInputStream to MediaAudio #139
Comments
@Wattful did you resolve your issue? Also does anyone know if humble-video can record both audio and webcam and create a single video file (with audio and video in it) e.g. mp4? |
I never resolved my issue, ended up using FFMpeg. |
@Wattful thanks for your answer - did you use a wrapper library that wrapped FFMpeg like:
or did you use something like Runtime.exec(..) and execute ffmpeg command line tool directly? I am super interested in knowing the best way to record audio and video and save it in a single file instead of 2 separate files. I am using Java for the rest of the app, so a Java wrapper solution or Java solution would be good. I do not understand why the JDK does not provide such basic functionality in the jdk / jvm itself instead of depending on these third party libraries. Maybe it is a licensing issue - I do not know. However, if web browsers can record video and audio then so should it be an easy matter for the jdk. Thank you for your time |
This one:
merges a mp3 file and a mp4 file into a mp4 file. It is using JavaCV as the wrapper library for FFMpeg For the use case of recording from webcam and mic I am not sure if I should (i) Record the webcam and create a mp4. And record audio separately into another file like mp3 and then finally merge the audio and video files together. or (ii) if there is a way to record video frames and audio samples simultaneously and create a mp4 in one go. Do you have any experience of what is possible @Wattful with library code? |
It turns out that our use cases are extremely similar. I also used FFMpeg to merge audio and video into a single file, although mine was pre-generated as opposed to live. The tool that I wrote is open-source, you can check it out for yourself: https://github.com/Wattful/AskReddit-video/. Specifically this line is where I merge audio and video together. As you can see, I used FFMpeg command line with Runtime.exec(). Out of the two strategies you propose, I used strategy one (two wouldn't have made sense because my input wasn't live). I'm not sure if number two is possible using FFMpeg, and if it is, it's probably much harder to work with than strategy one. |
@Wattful Thank you for your answer. I have included this comment here for the benefit of others. I came across this example:
The above example is about recording live video from the webcam and audio from the mic and producing a mp4 file. It is using javacv which internally uses stuff like FFMPeg. It has permission issues with jdk 14 and MacOS Catalina. However it works with jdk 16 if you run your IDE from the terminal. My IDE is STS (based on eclipse). I think it is missing a camera permission in its info.plist. If I run the IDE from the terminal. it is probably looking at a different info.plist file in the terminal, which has the correct entries for Catalina. Catalina introduced security for the webcam which has stopped past stuff working. This is the version of Java which worked for me with the above link.
For the above link example my pom.xml file looked like:
I have extra java spring boot dependencies that are not needed for the example. I added them because I like dependency injection. I am rewriting the example in the above link so it is more readable and is not hard coded to a specific webcam or mic. |
My goal is to get from
javax.sound.sampled.AudioInputStream
to humbleMediaAudio
.I thought that
MediaAudioConverter
would be useful as its javadoc states that it "Converts from Humble MediaAudio to byte arrays that can be used in Java's sound system and back." However, there is no method defined in the interface that can convert from java audio toMediaAudio
.Is there any way to get from
AudioInputStream
toMediaAudio
? Am I missing something obvious?The text was updated successfully, but these errors were encountered: