MP4Parser Can we have Android MediaPlayer directly act as a sink?
Asked Answered
B

0

1

Lets say my I have my Mp4Parser Container java object and then instead of writing to a file and then supplying the URL of this file to the Android Media Player to play this video.

Container outMux = new DefaultMp4Builder().build(countVideo);
        FileOutputStream fos = new FileOutputStream(
                new File("outputFinalVideo.mp4"));
        outMux.writeContainer(fos.getChannel());
        fos.close();

In the above I am concatenating multiple videos and then Muxing with Audio and then I want this to be in memory and play directly in android media player or if there is any other way.

Can we write the object representation to Android media Player directly so android media player will be acting like a sink. Is that even possible ? or is there any better way to achieve playing this video all in memory ?

So it will be like all done in Memory rather than writing to a file as the sink and then supplying the file URL to the android media player.

import android.media.MediaPlayer;
public class MainActivity implements Activity{

    private MediaPlayer mediaPlayer; 
    //url is the url for the outputFinalVideo.mp4 after being generated
    mediaPlayer.setDataSource(getApplicationContext(), url);

.......

}

The video is 20 minute long I was able to do everything in memory in iOS using AVFoundation Framework.

Blastopore answered 27/4, 2015 at 2:45 Comment(2)
I swear there is an advanced android guide by google that shows a super nifty trick for recording video directly into memory. that would be the same idea. it was very involved though and not a simple implementation. I have been googling for 15 minutes and am unable to find it nowPanathenaea
@user2635995 please do post the link if you find one. I almost gave up. Thanks !Blastopore

© 2022 - 2024 — McMap. All rights reserved.