A Java API to read, write and create MP4 files

Overview
  • Build status: Build Status
  • Current central released version 1.x branch: Maven Central
  • Current central released version 2.x branch: Maven Central

Java MP4 Parser

A Java API to read, write and create MP4 container. Manipulating containers is different from encoding and decoding videos and audio.

Using the library

The library is published to Maven repositories. Each release is pushed to a staging repository which is published on the release page. On request specific releases can be pushed to maven central.

Gradle:

  compile 'org.mp4parser:isoparser:1.9.27'

Maven:

  <dependency>
    <groupId>org.mp4parser</groupId>
    <artifactId>isoparser</artifactId>
    <version>1.9.27</version>
  </dependency>

For projects that do not use a dependency management tool each release's artifacts (jar, javadoc-jar, source-jar) are attached to the release page. Please be aware that the project requires the aspectj-rt.jar library.

What can you do?

Typical tasks for the MP4 Parser are:

  • Muxing audio/video into an MP4 file
  • Append recordings that use same encode settings
  • Adding/Changing metadata
  • Shorten recordings by omitting frames

My examples will all use H264 and AAC as these two codecs are most typical for MP4 files. AC-3 is also not uncommon as the codec is well known from DVD. There are also MP4 files with H263/MPEG-2 video tracks but they are no longer used widespread as most android phones. You can also

Muxing Audio/Video

The API and the process is straight-forward:

  1. You wrap each raw format file into an appropriate Track object.
H264TrackImpl h264Track = new H264TrackImpl(new FileDataSourceImpl("video.h264"));
AACTrackImpl aacTrack = new AACTrackImpl(new FileDataSourceImpl("audio.aac"));
  1. These Track object are then added to a Movie object
Movie movie = new Movie();
movie.addTrack(h264Track);
movie.addTrack(aacTrack);
  1. The Movie object is fed into an MP4Builder to create the container.
Container mp4file = new DefaultMp4Builder().build(movie);
  1. Write the container to an appropriate sink.
FileChannel fc = new FileOutputStream(new File("output.mp4")).getChannel();
mp4file.writeContainer(fc);
fc.close();

There are cases where the frame rate is signalled out of band or is known in advance so that the H264 doesn't contain it literally. In this case you will have to supply it to the constructor.

There are Track implementations for the following formats:

  • H264
  • AAC
  • AC3
  • EC3

and additionally two subtitle tracks that do not directly wrap a raw format but they are conceptually similar.

Typical Issues

Audio and video are not in sync. Whenever there are problems with timing possible make sure to start

Audio starts before video

In AAC there are always samplerate/1024 sample/s so each sample's duration is 1000 * 1024 / samplerate milliseconds.

  • 48KHz => ~21.3ms
  • 44.1KHz => ~23.2ms

By omitting samples from the start you can easily shorten the audio track. Remove as many as you need. You will not be able to match audio and video exactly with that but the human perception is more sensible to early audio than to late audio.

Remember: If someone is only 10 meters away the delay between audio and video is >30ms. The brain is used to that!

AACTrackImpl aacTrackOriginal = new AACTrackImpl(new FileDataSourceImpl("audio.aac"));
// removes the first sample and shortens the AAC track by ~22ms
CroppedTrack aacTrackShort = new CroppedTrack(aacTrackOriginal, 1, aacTrack.getSamples().size());

Append Recordings with Same Encode Settings

It is important to emphasize that you cannot append any two tracks with:

  • Different resolutions
  • Different frame-rates

What can't you do?

Create JPEGs from a movie. No - this is no decoder. The MP4 Parser doesn't know how to do that. Create a movie from JPEGs

Comments
  • NoSuchElementException when accessing list but .size() works ok

    NoSuchElementException when accessing list but .size() works ok

    Hello, I'm concatenating several videos to make one. It works for some videos (mainly rather short ones, the longest I tried with success was 5 min 56 sec total. But when I try to join longer set of videos I get exception on audio track .getSamples(). All audio tracks are cropped because of syncing issues so the are CroppedTrack in fact.

    Now more into details. I'm using version 1.1.7 which I believe is the latest.

    This is how error looks like in Watch: how

    As you can see size() works but whole list not.

    The code where this happens is:

    public List<Sample> getSamples() {
        return origTrack.getSamples().subList(fromSample, toSample);
    }
    

    in CroppedTrack.java. If I get into origTrack.getSamples() and run watch on private variable samples I get the error that is attached.

    I think something may be wrong with the implementation of AbstractArray for cropped list. I will try to debug further to find out what's happening but maybe you'll have time to make it even faster.

    The problem is with test case. It doesn't happen for all videos. I crop all of them and some are concatenated without a problem and others throw exception. The one rule I noticed so far, but can't tell it's 100% is that it doesn't work for long video sets. But maybe it's not about time but number of tracks. In this example there are 14 video tracks appended to each other. The error is thrown on second audio track. I go back to debugging. Let me know if you need more details on this.

    Btw. great job with the library! I will donate for sure when this finally works for me :).

    opened by Episodex 48
  • Replacing audio of video

    Replacing audio of video

    Hello, I want to replace an audio of a video with another audio(not append).In other words,I want to remove audio from the video and add other audio to the video.Is it possible through this library?

    opened by bkjbkjbnkj687698698 26
  • Opening IsoFile throws OutOfMemory Exception on Android

    Opening IsoFile throws OutOfMemory Exception on Android

    Hello everyone. I was using this library for a project at work. I noticed that issue #284 was closed, but I wanted to submit another issue that's similar in nature.

    The project is in Kotlin, but I can convert to Java if it helps with readability of this ticket.

    Device: Google Pixel 2 XL Android Q Beta 2 On IsoParser version 1.9.38

    I'm trying to open an IsoFile via like this: val isoFile = IsoFile(Channels.newChannel(ByteArrayInputStream(base64DecodedString)

    The resulting StackTrace error is the following:

    java.lang.OutOfMemoryError: Failed to allocate a 2064261160 byte allocation with 7167453 free bytes and 505MB until OOM, target footprint 14334909, growth limit 536870912 at java.nio.HeapByteBuffer.<init>(HeapByteBuffer.java:54) at java.nio.HeapByteBuffer.<init>(HeapByteBuffer.java:49) at java.nio.ByteBuffer.allocate(ByteBuffer.java:282) at org.mp4parser.support.AbstractBox.parse(AbstractBox.java:96) at org.mp4parser.AbstractBoxParser.parseBox(AbstractBoxParser.java:115) at org.mp4parser.BasicContainer.initContainer(BasicContainer.java:107) at org.mp4parser.IsoFile.<init>(IsoFile.java:57) at org.mp4parser.IsoFile.<init>(IsoFile.java:52) at com.realeyes.adinsertion.exoplayer.PsshParser$Companion.getWidevinePSSH(PsshParser.kt:69) at com.realeyes.adinsertion.components.ads.live.VodPlaylistAdStitcher.checkForDrmKey(VodPlaylistAdStitcher.java:250) at com.realeyes.adinsertion.components.ads.live.VodPlaylistAdStitcher.parseWithVmapPrerolls(VodPlaylistAdStitcher.java:205) at com.realeyes.adinsertion.components.ads.live.VodPlaylistAdStitcher.getPlaylist(VodPlaylistAdStitcher.java:103) at com.realeyes.adinsertion.components.ads.StitchingAdManager.parse(StitchingAdManager.java:68) at com.realeyes.adinsertion.components.ads.StitchingAdManager.parse(StitchingAdManager.java:24) at com.google.android.reexoplayer2.upstream.ParsingLoadable.load(ParsingLoadable.java:158) at com.google.android.reexoplayer2.upstream.Loader$LoadTask.run(Loader.java:389) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:919)

    Would greatly appreciate any advice on the following. I can't seem to determine if it's a truly known bug or not, or if it's something I'm messing up. Let me know if I can give any more information on the issue I'm experiencing.

    opened by thenotoriousrog 13
  • ArrayIndexOutOfBoundsException in DefaultMp4Builder.createStco

    ArrayIndexOutOfBoundsException in DefaultMp4Builder.createStco

    I'm getting an ArrayIndexOutOfBoundsException with length=8; index=8 when trying to mux aac audio and raw h264 video into an mp4.

    I'm using isoparser:1.0.6 from maven

    The h264 video is generated using libopenh264

    Here's the exception: Caused by: java.lang.ArrayIndexOutOfBoundsException: length=8; index=8 at com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder.createStco(DefaultMp4Builder.java:497) at com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder.createStbl(DefaultMp4Builder.java:360) at com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder.createTrackBox(DefaultMp4Builder.java:321) at com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder.createMovieBox(DefaultMp4Builder.java:225) at com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder.build(DefaultMp4Builder.java:115) at com.smithmicro.mp4Parser.Mp4ParserAudioMuxer.muxH264VideoAACAudio(Mp4ParserAudioMuxer.java:49) at org.jcodec.jcodec_samples.MainActivity.DoOpenh264EncodeTest(MainActivity.java:177) at org.jcodec.jcodec_samples.MainActivity.onCreate(MainActivity.java:124)

    Here's my code:

    public static boolean muxH264VideoAACAudio(int fps, String h264VideoFile, String aacAudioFile, String outputFile){
    
            H264TrackImpl h264Track;
            AACTrackImpl aacTrack;
    
            try {
                h264Track = new H264TrackImpl(new FileDataSourceImpl(h264VideoFile), "eng", fps, 1);
                aacTrack = new AACTrackImpl(new FileDataSourceImpl(aacAudioFile), "eng");
            }
            catch(FileNotFoundException e){
                e.printStackTrace();
                return false;
            }
            catch (IOException e) {
                e.printStackTrace();
                return false;
            }
    
            Movie movie = new Movie();
            movie.addTrack(h264Track);
            movie.addTrack(aacTrack);
    
            Container mp4file = new DefaultMp4Builder().build(movie);
    
            try {
                FileChannel fc = new FileOutputStream(new File(outputFile)).getChannel();
                mp4file.writeContainer(fc);
                fc.close();
            } catch (FileNotFoundException e) {
                e.printStackTrace();
                return false;
            }catch (IOException e) {
                e.printStackTrace();
                return false;
            }
    
            return true;
        }
    
    opened by BrianSDev 13
  • Tutorial how to set up aspectj runtime weaving with gradle ?

    Tutorial how to set up aspectj runtime weaving with gradle ?

    I'm currently getting

    java.lang.RuntimeException: java.lang.NoSuchMethodException: [class java.lang.String] at com.coremedia.iso.PropertyBoxParserImpl.createBox(PropertyBoxParserImpl.java:120) at com.coremedia.iso.AbstractBoxParser.parseBox(AbstractBoxParser.java:101)

    Which to me looks like it could be something to do with me not setting up aspect-j

    I'm on android.. and I'm not too familiar with the gradle compiler options. Is there like a sample gradle file/ tutorial out there I can use to make sure I have aspectJ runtime weaving compiling ? I've search a lot on the internet with no avail.. Was wondering how the any fellow android developer is doing it ?

    Thanks :)

    opened by renatofernandes28 13
  • Sample Code for Cutting/Shorten Videos

    Sample Code for Cutting/Shorten Videos

    I'm new to this lib, and i want to cut videos and encode and decode a video from .MOV (ios) to .mp4 Can you post a sample code demonstrating the cutting of videos.

    opened by iAviatorJose 13
  • java.lang.ArrayIndexOutOfBoundsException: length=8; index=8

    java.lang.ArrayIndexOutOfBoundsException: length=8; index=8

    Hi, I am having strange problem. I am recording vidoe files from Android surface(originally from GoPro3) and I am adding audio track. I get exception on some files. I can play those files, ffprobe does not show anything strange. And the error shows only in combination with audio track.

    Example: Load mp4 - load video8, extract video track, add to new Movie, save - ok; Load mp4 - load video9, extract video track, add to new Movie, save - ok; Load mp4 - load video8. extract video, add to new Movie, load .aac file, add to movie, ok; Load mp4 - load video9. extract video, add to new Movie, load .aac file, add to movie, error;

    Files are here: https://www.dropbox.com/sh/jvrd5qovoz488du/AACbFSWHNCxqVO1CE1dTwGIca?dl=0

    Here is my code:

    public void openFiles(){
            String dir = Environment.getExternalStorageDirectory()+"/";
            try {
                String video = dir + "video_track9.mp4";
                Movie originalVideo = MovieCreator.build(video);
                List<Track> tracks = originalVideo.getTracks();
                Track videoTrack = null;
                for (int i = 0; i < tracks.size(); i++) {
                    Track t = tracks.get(i);
                    if (t.getHandler().equals("vide")){
                        videoTrack = tracks.get(i);
                    }
                }
                if(null != videoTrack) {
                    Log.d("Main", "start saving: ");
                    Uri uri = Uri.parse(dir + "/twentysec.aac");
                    AACTrackImpl aacTrack = new AACTrackImpl(new FileDataSourceImpl(uri.getPath()));
                    Movie movie = new Movie();
                    movie.addTrack(aacTrack);
                    movie.addTrack(videoTrack);
                    Container mp4file = new DefaultMp4Builder().build(movie);
                    FileChannel fc = new FileOutputStream(dir + "test_output_track9.mp4").getChannel();
                    mp4file.writeContainer(fc);
                    fc.close();
                    Log.d("Main", "saving done: " + video);
                }
                else{
                    Log.d("Main", "mo video track");
                }
            } catch (IOException e) {
                e.printStackTrace();
                Log.d("Muxing",e.toString());
            }
        }
    

    And here is full exception:

    java.lang.ArrayIndexOutOfBoundsException: length=8; index=8
            at com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder.createStco(DefaultMp4Builder.java:497)
            at com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder.createStbl(DefaultMp4Builder.java:360)
            at com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder.createTrackBox(DefaultMp4Builder.java:321)
            at com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder.createMovieBox(DefaultMp4Builder.java:225)
            at com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder.build(DefaultMp4Builder.java:115)
            at com.example.marek.audiorecorder.MainActivity.openFiles(MainActivity.java:92)
            at com.example.marek.audiorecorder.MainActivity.onClick(MainActivity.java:68)
            at android.view.View.performClick(View.java:4761)
            at android.view.View$PerformClick.run(View.java:19767)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5312)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
    

    The problem is, I do not know where to look for the error. Is it in video or audio track? Also, when I tried to use FragmentedMp4Builder - the movie was saved. But library I use for reading the final file had problems reading it, so FragmentedMp4Builder is not a solution for me... The error log shows error on line:

    Container mp4file = new DefaultMp4Builder().build(movie);
    

    Thanks for repsonse!

    opened by m-o 12
  • null pointer exception

    null pointer exception

    hai sannies,

    I am getting null pointer exception at

    at com.googlecode.mp4parser.authoring.tracks.H264TrackImpl$SliceHeader.(H264TrackImpl.java:541)

    for the below code,

    H264TrackImpl h264Track = new H264TrackImpl(new FileDataSourceImpl(android.os.Environment.getExternalStorageDirectory().getAbsolutePath() + "/test.h264"));

    Movie movie = new Movie(); movie.addTrack(h264Track); Container mp4file = new DefaultMp4Builder().build(movie);

    FileChannel fc = new FileOutputStream(new File(android.os.Environment.getExternalStorageDirectory().getAbsolutePath() + "/decodingvideo.mp4")).getChannel(); mp4file.writeContainer(fc); fc.close();

    Please help me how to do this?

    opened by mohanraj546 11
  • Simple audio track tests are giving strange parse errors

    Simple audio track tests are giving strange parse errors

    I'm getting these kinds of exceptions from various test programs. From trying to debug the issue, I get very strange behavior with the bit alignment when trying to read the audio files.

    Exception in thread "main" java.io.IOException: Expected Start Word 0xfff
        at com.googlecode.mp4parser.authoring.tracks.AACTrackImpl.readADTSHeader(AACTrackImpl.java:293)
        at com.googlecode.mp4parser.authoring.tracks.AACTrackImpl.readSamples(AACTrackImpl.java:325)
        at com.googlecode.mp4parser.authoring.tracks.AACTrackImpl.(AACTrackImpl.java:142)
        at com.googlecode.mp4parser.authoring.tracks.AACTrackImpl.(AACTrackImpl.java:135)
    

    I initially received a similar error with an mp3 test:

    Exception in thread "main" java.io.IOException: Expected Start Word 0x7ff
        at com.googlecode.mp4parser.authoring.tracks.MP3TrackImpl.readMP3Header(MP3TrackImpl.java:200)
        at com.googlecode.mp4parser.authoring.tracks.MP3TrackImpl.readSamples(MP3TrackImpl.java:175)
        at com.googlecode.mp4parser.authoring.tracks.MP3TrackImpl.(MP3TrackImpl.java:64)
        at com.googlecode.mp4parser.authoring.tracks.MP3TrackImpl.(MP3TrackImpl.java:53)
        at Greg2.main(Greg2.java:26)
    

    and it seemed that making test changes to the MP3TrackImpl.java class after the code causing the problem would affect earlier code. For example, if I commented out the line:

            hdr.layer = brb.readBits(2); // C
    

    The code would make it past the above code.

    I was also playing around with the bits coming back from the line:

            BitReaderBuffer brb = new BitReaderBuffer((ByteBuffer) bb.rewind());
            int sync = brb.readBits(11); // A
    

    and everything worked fine up to a >>> 4 on sync. However, if I did a >>> 5, the bits would then get scrambled. It is as if the jvm is improperly optimizing the code or messing up the memory alignment.

    I've tested these things against multiple releases: isoparser-1.0.3.11.jar isoparser-1.0.4.1.jar isoparser-1.0.4.2.jar

    Any ideas?

    opened by gbildson 10
  • OutOfMemoryError when try to get size of moov box

    OutOfMemoryError when try to get size of moov box

    I got OutOfMemoryError when I run this code: MovieBox moov = isoFile.getBoxes(MovieBox.class).get(0); mMoovSize = moov.getSize();

    Here is the log: java.lang.OutOfMemoryError: Failed to allocate a 1751411830 byte allocation with 13437012 free bytes and 236MB until OOM 01-15 11:59:05.475: E/AndroidRuntime(10820): at java.nio.ByteBuffer.allocate(ByteBuffer.java:56) 01-15 11:59:05.475: E/AndroidRuntime(10820): at com.googlecode.mp4parser.AbstractBox.parse(AbstractBox.java:110) 01-15 11:59:05.475: E/AndroidRuntime(10820): at com.coremedia.iso.AbstractBoxParser.parseBox(AbstractBoxParser.java:107) 01-15 11:59:05.475: E/AndroidRuntime(10820): at com.googlecode.mp4parser.BasicContainer.next(BasicContainer.java:185) 01-15 11:59:05.475: E/AndroidRuntime(10820): at com.googlecode.mp4parser.BasicContainer.hasNext(BasicContainer.java:161) 01-15 11:59:05.475: E/AndroidRuntime(10820): at com.googlecode.mp4parser.util.LazyList.blowup(LazyList.java:30) 01-15 11:59:05.475: E/AndroidRuntime(10820): at com.googlecode.mp4parser.util.LazyList.size(LazyList.java:77) 01-15 11:59:05.475: E/AndroidRuntime(10820): at com.googlecode.mp4parser.BasicContainer.getContainerSize(BasicContainer.java:67) 01-15 11:59:05.475: E/AndroidRuntime(10820): at com.coremedia.iso.boxes.MetaBox.getSize(MetaBox.java:95) 01-15 11:59:05.475: E/AndroidRuntime(10820): at com.googlecode.mp4parser.BasicContainer.getContainerSize(BasicContainer.java:70) 01-15 11:59:05.475: E/AndroidRuntime(10820): at com.googlecode.mp4parser.AbstractContainerBox.getSize(AbstractContainerBox.java:57)

    opened by sunshinetpu 9
  • MP3TrackImpl

    MP3TrackImpl

    Hi! I have a problem using MP3TrackImpl: java.io.IOException: Expected Start Word 0x7ff 01-05 11:05:19.754 11731-11870/de.fsappz.musicvideomaker W/System.err: at com.googlecode.mp4parser.authoring.tracks.MP3TrackImpl.readMP3Header(MP3TrackImpl.java:183) 01-05 11:05:19.754 11731-11870/de.fsappz.musicvideomaker W/System.err: at com.googlecode.mp4parser.authoring.tracks.MP3TrackImpl.readSamples(MP3TrackImpl.java:154) 01-05 11:05:19.754 11731-11870/de.fsappz.musicvideomaker W/System.err: at com.googlecode.mp4parser.authoring.tracks.MP3TrackImpl.<init>(MP3TrackImpl.java:60) 01-05 11:05:19.754 11731-11870/de.fsappz.musicvideomaker W/System.err: at com.googlecode.mp4parser.authoring.tracks.MP3TrackImpl.<init>(MP3TrackImpl.java:53)

    Im using MP3TrackImpl like this: MP3TrackImpl mp3Track = new MP3TrackImpl(new FileDataSourceImpl(audio); (Exception is thrown in this line)

    Thank you very much!

    opened by fsappz78 8
  • java.lang.OutOfMemoryError: Direct buffer memory

    java.lang.OutOfMemoryError: Direct buffer memory

    java.lang.OutOfMemoryError: Direct buffer memory
    	at java.nio.Bits.reserveMemory(Bits.java:695)
    	at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:123)
    	at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:311)
    	at org.mp4parser.support.AbstractBox.parse(AbstractBox.java:95)
    	at org.mp4parser.AbstractBoxParser.parseBox(AbstractBoxParser.java:107)
    	at org.mp4parser.BasicContainer.initContainer(BasicContainer.java:107)
    	at org.mp4parser.IsoFile.<init>(IsoFile.java:55)
    	at org.mp4parser.IsoFile.<init>(IsoFile.java:38)
    	at com.xxx.controller.LiveController.update(LiveController.kt:84)
    	at com.xxx.controller.LiveController.dvr$lambda-0(LiveController.kt:74)
    	at java.lang.Thread.run(Thread.java:748)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	at java.lang.Thread.run(Thread.java:748)
    
    val fileName = "xxx.flv"
    val file = File(fileName)
    println("${fileName}======>>${file.length()}")
    val isoFile = IsoFile(fileName)
    println("${isoFile.movieBox.movieHeaderBox.duration}============")
    
    opened by JakeWoki 0
  • fix:

    fix:"ClassLoader.getSystemResourceAsStream" NullPointException

    Fix: #449

    Problem: jdk17, "org.mp4parser.muxer.container.mp4.MovieCreator.build(path)" throw NPE

    java.lang.NullPointerException: inStream parameter is null
            at java.base/java.util.Objects.requireNonNull(Objects.java:233)
            at java.base/java.util.Properties.load(Properties.java:407)
            at org.mp4parser.PropertyBoxParserImpl.<init>(PropertyBoxParserImpl.java:52)
            at org.mp4parser.IsoFile.<init>(IsoFile.java:53)
            at org.mp4parser.muxer.container.mp4.MovieCreator.build(MovieCreator.java:54)
    

    And I find in "org/mp4parser/PropertyBoxParserImpl.java:48 " return null

    InputStream is = ClassLoader.getSystemResourceAsStream("isoparser2-default.properties"); //return null 
    
    opened by laoLiangLoveProgram 0
  • How to release resources

    How to release resources

    Code:

    public static boolean audioVideoMerge(@NotNull String audio, @NotNull String video, @NotNull String output) {
    		boolean success = false;
    		try (FileOutputStream fos = new FileOutputStream(output); 
                                DataSource videoDataSource = new FileDataSourceImpl(video); 
                                DataSource audioDataSource = new FileDataSourceImpl(audio)) {
    			Movie countVideo = MovieCreator.build(videoDataSource);
    			MovieCreator.build(audioDataSource).getTracks().forEach(countVideo::addTrack);
    			Container out = new FragmentedMp4Builder().build(countVideo);
    			out.writeContainer(fos.getChannel());
    			success = true;
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    		new File(audio).delete();
                    new File(video).delete();
    		return success;
    }
    

    Result: audio file exists video file exists

    Is this a bug? Must use System.gc() and wait time to delete.

    opened by hnuuhc 1
  • Cant Trim Videos

    Cant Trim Videos

    Hi! want to share my experience and error that I encounter, I migrate from version1.2.x to 1.9.x, Screenshot_20221001_085650 as you can see, The error is in the MovieCreator.build, I checked first if the src file is null (but its not): here is the code: private static void generateVideo(@NonNull File src, @NonNull File dst, long startMs, long endMs, @NonNull OnVideoTrimListener callback) throws Exception { Movie movie = MovieCreator.build(src.getAbsolutePath()); //the error T_T /*other code to trim videos*/ }

    Anyone can guide on why and how?

    Thanks!

    opened by STICKnoLOGIC 0
  • Will your library support OpenHarmony platform by JavaScript language ?

    Will your library support OpenHarmony platform by JavaScript language ?

    I am developing an OpenHarmony application with JavaScript language which used your library, will your library support OpenHarmony platform by JavaScript language?If so, I want to contribute to the OpenHarmony build of this library.Expecte for your reply!

    opened by yuangerep 1
  • VP9 support for mp4parser

    VP9 support for mp4parser

    Hi everyone! I have issues getting mp4parser working with VP9 encoded files. When trying, I get the following error message:

    [...]
    java.lang.AssertionError: stsd contains not only sample entries. Something's wrong here! Bailing out
            at org.mp4parser.muxer.container.mp4.DefaultMp4SampleList.<init>(DefaultMp4SampleList.java:58)
    [...]
    

    Is there any way to enable vp9 support? Thanks for your help! Jan

    opened by yetanotherjan 0
Releases(mp4parser-project-1.0.7.1)
Owner
Sebastian Annies
Sebastian Annies
Android Application that plays music through a Spotify API based on a user's current location found through Google Maps API and also checking Google Weather API.

GeoStereo Android Application that plays music through a Spotify API based on a user's current location found through Google Maps API and also checkin

Jonah Douglas 1 Jun 16, 2022
Blade is an open source music player for Android, allowing you to play music from multiple services : files on your phone, Spotify, and more.

Blade Player Blade is an open source music player for Android, allowing you to play music from multiple services : files on your phone, Spotify, and m

Valentin HAUDIQUET 72 Jan 5, 2023
Wynncraft API Wrapper - Simple wrapper to get Wynncraft Stats of a player or a guild and more in Java

WynncraftAPIWrapper Simple wrapper to get Wynncraft Stats of a player or a guild

byBackfish 3 Sep 27, 2022
Video Transcoder is an application which uses the open source program FFmpeg to transcode video files from one format to another.

Video Transcoder Do you want to encode videos on your phone into different formats, trim videos, or extract audio? Are you looking for a free solution

Branden Archer 358 Dec 30, 2022
Noice is an android app that allows you to create your own set of background sounds by mixing clips from environmental sources.

A native Android app to relax, improve focus and boost productivity with minimal background noise.

Ashutosh Gangwar 666 Jan 3, 2023
ZExoRecyclerPlayer is an Android library that allows developers to easily create RecyclerView with Exoplayer .

ZExoRecyclerPlayer Description ZExoRecyclerPlayer is an Android library that allows developers to easily create RecyclerView with Exoplayer . Please f

mohammed alzoubi 4 Dec 12, 2022
A simple library for parsing and playing links from YouTube, YouTube Music, Vimeo and Rutube is WebView without the need to connect api data services. Request caching is available now

Android Oembed Video A simple library for parsing and playing links from YouTube, YouTube Music, Vimeo and Rutube and others in the WebView without th

Alexey Mostovoy 32 Oct 8, 2022
Convert your YouTube channel into a native Android app using YouTube Data API v3.

Convert your YouTube channel into an app. Screenshots • Description • Features • Configuration • Documentation Screenshots Description Channelify is a

Aculix Technologies LLP 121 Dec 26, 2022
The official Android client library for api.video

api.video Android client api.video is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing

api.video 7 Dec 3, 2022
Autodownload MP3 API With Kotlin

Autodownload MP3 API Overview This project leverages Spring Boot, Google's YouTube API, and youtube-dl to provide an API to download videos and conver

Julien 1 Jul 1, 2022
Android app that uses Spotify API to recommend new music based on your listening history

Android app that uses Spotify API to recommend new music based on your listening history. Written in Kotlin and uses Spotify Web API and Android SDK. New music is presented in swipe cards where a left swipe plays the next song and a right swipe can add the app to your liked songs in Spotify.

null 3 Jun 5, 2022
api.video Android player

api.video is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand & low latency live streaming features in your app.

api.video 9 Dec 15, 2022
Free p2p cdn android github sdk to reduce video streaming costs of live and on demand video using webrtc by upto 90% and improve scalability by 6x - 🚀 Vadootv 🚀

Android p2p cdn sdk to distribute load and reduce costs(https://peervadoo.com) Vadootv is a p2p sdk integration to reduce your video streaming costs b

Vadootv 40 Oct 5, 2022
Simple and lightweight, yet polished and powerful Android video player based on ExoPlayer

Just (Video) Player Android video player based on ExoPlayer It uses ExoPlayer's extension-ffmpeg with all its audio formats enabled (it can handle eve

Marcel Dopita 677 Dec 28, 2022
Fermata Media Player is a free, open source audio and video player with a simple and intuitive interface.

Fermata Media Player About Fermata Media Player is a free, open source audio and video player with a simple and intuitive interface. It is focused on

Andrey 227 Jan 6, 2023
Echo is a lightweight and minimal music player for Android, built with Android Studio and written in Kotlin

Echo - Echo, A light-weight, minimal music player for Android, with shuffle, favorites and audio visualization

Divins Mathew 0 Feb 7, 2022
Is an All in One app for Muslims with lots of features such as Prayer Times & Adhan, Collections of Dhikr and Prayer sourced from Authentic Hadith, The Holy Qur'an, Qibla, Notes and many more!

Is an All in One app for Muslims with lots of features such as Prayer Times & Adhan, Collections of Dhikr and Prayer sourced from Authentic Hadith, The Holy Qur'an, Qibla, Notes and many more!

DzikirQu 112 Dec 26, 2022
Android app for streaming and downloading Movies, TV-Series and Anime.

CloudStream ⚠️ Warning: By default this app doesn't provide any video sources, you have to install extensions in order to add functionality to the app

null 309 Aug 21, 2022