MP4 container writer in Java - java

I would like to find a FREE MP4 (container) writer for Java. I do not need an encoder, only something which can write the correct atoms given their expected values. Bonus for such a library that also can write "valid" F4V.
I would prefer a pure Java solution rather than something using JNI or external executables.

Even though my answer comes very late you could have a look into my MP4 Parser/Unparser at Github. You can parse MP4 files, modify them and write the result. You can even start from scratch creating boxes programatically and write your object representation to some sink.

You can have a look at JCodec ( http://jcodec.org ). It contains an MP4 library and MP4 demuxer and muxer.

May be you are looking for something like StreamBaby.

Can't vouch for it, but red5 is an open source flash server written in Java, which claims support for streaming mp4 and has implementations of mp4 IO objects which may be able to create said format.
Also, IBM created their Toolkit For MPEG-4 a while back and though it's not free, it might help.

FFMPEG's java bindings?
http://fobs.sourceforge.net/f4jmf_first.html
Or simpler a JNA proxy over some C++ MP4 library.

I have implemented a QuickTimeWriter class which can write a QuickTime container in pure Java.
As far as I know, the QuickTime file format is structurally equivalent to MPEG-4 Part 14. There are only a few minor differences in the fields inside atoms/boxes.
So, with an MPEG-4 spec on your lap, and a few hours of work, you should be good.

The Java I've seen which modifies MP4 files would invoke Nero AAC Codec externally (a Windows native .exe which Nero does not supply the source for) to modify AAC files (which are Apple's audio-only MP4 files). It works for audio only, not to video.

Related

Play m4a files in Java

I want to create a media player in Java. The mp3 support already works with the JLayer library but which library can play m4a files?
I read about vlcj here on stackoverflow, but this seems to depend on Swing/AWT which I wouldn't use because I want to port the application to Android later on.
Have you looked at JAAD? It's a Javasound SPI that decodes AAC audio, I've used it with success previously.
Note that m4a is a container format, and while it usually contains (in my experience) AAC audio, in theory it could contain other formats instead.
You can find some information about getting it working without Javasound (and a test case) here.
This answer is indirect. I don't really know anything about m4a files. But what I have found is an open source library that can stream them as a flash server named red5. It's written in Java so theoretically you should be able to browse their code to figure out how to do it.
Hopefully someone here can give a more direct answer, this is the best I can do.
If you have Java 7 or later, you have access to the Javafx library. You can also use your media player (like iTunes or Windows Media Player) to convert to the simpler mp3 version and run that. I wouldn't recommend .wav files as they have significantly more data usage than mp3s, (which condense the file size by compressing the .wav data and omitting inaudible and otherwise garbage-y data).
import javafx.scene.media.*;
String name = "song.mp3";
Media song = new Media(name);
MediaPlayer player = new MediaPlayer(song);
player.play();

Is there any Java MultiMedia Conversion Library

I wonder if there is a lib, like Apache Commons, or something of that sort to help convert media-files (e.g. avi, mkv, mp4 etc) any-to-any? For example an InputFile is in format .avi and an OutputFile is in mp4.
See either of the following to convert between a range of formats.
Jffmpeg is a plugin that allows the playback of a number of common audio and video formats. It is based around a Java port of parts of the FFMPEG project, supporting a number of codecs in pure Java code. Where codecs have not yet been ported, a JNI wrapper allows calls directly into the full FFMPEG code.
Xuggle - A free open-source library for Java developers to uncompress, manipulate, and compress recorded or live video in real time.
The only library I know for that is ffmpeg, but you will have to run it through JNI.

Video Transcoding/Conversion using Java

I would like to convert a video from one format to another. Initially, I want to convert MP4 to AVI or any other more suitable video format.
Came across the ffmpeg library. Is is the best solution?
Came across Xubber and Jave for the same? Any experiences?
I tried jffmpeg that is a direct java wrapper on ffmpeg, but didn't found much documentation over that so moved on.
I tried to use Xubber and succeded also but it requires lot of pre-configurartions like you have to install .exe file prior and set XUBBER_HOME vars etc.
I have found nice and easy to implement solution ie JAVE http://www.sauronsoftware.it/projects/jave/index.php
Try this one.

Video converting into mp3 on Java, Android

I need to convert mp4/flv files info mp3 in my Android application, but I don't know C/C++ and Android NDK. Do you know libraries/methods for easy converting on Java? Thank you for anyway.
Your question is how to extract audio from MP4/ FLV files and save as mp3 file. Right ?
Then, very sorry, Android SDK does not provide any API for transformating or track extraction.
Also using available media framework to achieve the same is also not trivial (and even if you do, you will lose portability).
What I would suggest is to use your MP4 & FLV Parser to extract audio track, do transcoding (if audio track is non-mp3), and save the transcoded (if audio track extracted is mp3, then extracted data) data.
Or you can port FFMPEG code base and use the same. This again may be overkill for your small task.
Suppose you just want to extract mp3 track from MP4, then you understand the native mp4 parser and use the APIs for extraction. You may have to replicate some code from stagefright / opencore.
Shash
it's probably irrelevant for you anymore but if some one still need a mp4 to mp3 parser here's an api that can do the job

Splitting/Merging 3gp files using a java library

I'm wondering if there's a java library out there that can manipulate 3gp files. Mostly I'm interested in splitting or merging existing video files.
I've looked at JMF (java media framework), but it doesn't support 3gp…and FFmpeg looks promising, but it's not clear that the library allows splitting/merging of existing files.
Does such a library exist?
Try Xuggler http://www.xuggle.com/ (its FREE btw)

Categories

Resources