I tested the StageFright record sample (frameworks/base/cmds/stagefright/record) to create a mpeg2 TS file. While it can be played on Android default Media player, it cannot be played in Windows Media Player or MPlayer. Any suggestions?
Note that I modified the original record sample source to create MPEG-TS file instead of MP4 file.
Which codec you used to create the mpeg2 TS file. May be difference in the codec used is the problem.
Related
I use code below generated a aac audio file. And the file plays fine on my windows machine. But it cannot be played on my android device using a MediaPlayer. What should I do to make the file playable on a android device? Thanks!
MediaRecorder recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.AAC_ADTS);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
recorder.setAudioEncodingBitRate(16 * 44100);
recorder.setAudioSamplingRate(44100);
recorder.setAudioChannels(2);
recorder.setOutputFile(mTempFile.getAbsolutePath());
"Can Android play a ADTS AAC file?..."
Not with default apps. Only if you code such an app. Use the MediaCodec API to manually send each of your aac frame's bytes to the decoder.
If you can handle bytes and familiar with aac frame structre, then check these as starting points :
Decoding AAC using MediaCodec API on Android
PCM -> AAC (Encoder) -> PCM(Decoder) in real-time with correct optimization
"But it cannot be played on my android device using a MediaPlayer... What should I do to make the file playable on a android device?..."
The aac data must exist inside a container format like m4a or mp4. MediaPlayer (strangely) does not play raw aac data, yet does not expect raw mp3 to be contained.
note:
When placed inside one of the above, you will lose the ADTS header for each frame (since that information will now exist in other parts of the container's metadata).
I would like to show some video in my android application.
Video are like: http://myserver.com/video/myvideo.mov All the video are in .mov and some in .flv.
.mov have H264 - MPEG-4 AVC (avc1) video channel, and MPEG ACC Audio (mp4a) audio channel.
.flv have Flash Video (flv1) video channel, and MPEG Audio layer 1/2/3 (mpga) audio channel.
If I play the .mov with the default android player I can see the video image, but I can't hear anithing.
With the .flv I can see and hear the file in the default android player.
Is there a way to play correctly the .mov with the MPEG ACC Audio (mp4a) audio channel?
Anyone know if there is a custom library to play this .mov files? Thank you in advance!
As stated here MOV container even with H264/AAC inside is not supported in Android. The underlying reason is that MOV (aka quicktime file format) is a proprietary container from Apple (it is a close one from MP4 but still not the same) - most of the time it works 100% only on Apple device and/or quicktime player.
FLV container from Adobe is also not supported in Android (FLV can be packed with H263 or H264 video inside).
It can work on some device but as you experienced it, it can be clunky and surely inconsistent across devices.
Your best bet is to package/transcode your file in a format where you know you will have cross-Android compatibility.
If you want it badly you could think about building your own video player/decoder to play back mov/flv files (like with ffmpeg) but it is an advanced project in itself and providing code for that would be outside of the scope of stackoverflow - maybe have a look here.
I'm developing an Android App that records screen video and audio.
I recorded these 2 files : mp3 audio file and mp4 video file(no sound).
Now I want to mix them and create a new mp4 video file(with sound).
From Android 4.3, Google suggests using the MediaMuxer class to mix stream audio and video. I have tried many times without success.
Any solution to resolve my issue with MediaMuxer API from Google?
Any help will be greatly appreciated.
MediaMuxer does not transcode.
If you write out an MPEG4 file, it will expect the video file to be MPEG4/AAC and the audio file to be an AAC file (m4a) as well.
Once you feed it with an m4a, muxing will succeed.
This is a full sample source code to merge wav audio file to mp4 video file :
https://github.com/tqnst/MP4ParserMergeAudioVideo
Hello i am trying to get my android 2.2 app stream music. So far I have been able to stream from a radio station via the mediaPlayer.setDataSource("STREAM HERE")
I have tried with a m3u file and it won't work (unless my m3u file is wrong). Can it support xspf or what other file types?
How could i go about solving this problem?
thanks a lot
The setDataSource() method on the media player will accept file or URIs for a media source. Look at this list to see what media formats the media player accepts: http://developer.android.com/guide/appendix/media-formats.html
I am fairly certain that the media player will not play playlist files like M3U. You would have to create your own M3U player, which could be accomplished via the MediaPlayer method: setOnCompletionListener(MediaPlayer.OnCompletionListener listener)
Register a callback to be invoked when the end of a media source has been reached during playback.
When playback is done, you could start playing the next media resource in your playlist.
I have an MP4 file that I play with the MediaPlayer example in API demos on the emulator. Only the sound is played. No video. Why would this be and how do i get it to play?
BTW: .3gp files to play both audio and video in the same example.
Thanks!
The supported media formats are listed here: http://developer.android.com/guide/appendix/media-formats.html . Make sure your mp4 file uses the right format (H.264 AVC or H.263).