Android mediaplayer stream recorded video from WCF REST server - android

Hey I'm struggling with a real hard problem for a few days now, hope you guys can help me.
my android app records videos and uploads them to my WCF restful sever, the server streams back the files. all is working well on firefox and chrome, the video is beying streamed without any problems.
on the same android application i recorded the video there is a problem, short videos (under a minute) are beying streamed without any trouble, yet when the video becomes longer the mediaplayer seems to not load it.
I have tried changing the mediarecorder profile fileformat and videocodec yet no change, ive read mediaplayer only supports mpeg4 and 3gp video stream over HTTP and ive tried all the combinations.
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
CamcorderProfile profile = CamcorderProfile.get(CamcorderProfile.QUALITY_LOW);
profile.fileFormat =2;
profile.videoCodec=3;
mediaRecorder.setProfile(profile);
im pretty sure my server handles the streaming well since its works on browsers, also other formats like audio 3gp and mp3 stream fine on the app only the video isnt streaming.
can somebody put me on the right track here?
Thanks!

well after tampering around i finally found the cause to all this.
it seems the android mediarecorder appends the moov atom to the end of the recorder video yet when streaming with the mediaplayer the file must have its moov atom in the begining.
so there u go for anybody struggling with recorder videos not streaming back

Related

Android RTSP stream from IP camera without delay

I need to stream rtsp-video from IP camera in local network to my android app. It's very easy to use VideoView and play it as url, or SurfaceView and play stream on it with native MediaPlayer. But when I stream that way - I've recieved a 6-second delay when my phone is buffering that video. As I read, there is no way to change buffer size of MediaPlayer. But I saw several apps that stream video from my camera in almost real-time. I've read a lot about this - cause I'm not the first one who encountered this problem - but didn't find any useful info.
Many thanks for any help!
I'm using vlc-android, it works well to play my cameras' rtsp links:
https://github.com/mrmaffen/vlc-android-sdk#get-it-via-maven-central
The delay is about 1 second.

What format can I use to record on android and play it in ios

I have tried so many different formats when I record a audio on android, that I get dizzy by just thinking about it. When I record by using .wav on ios, I can play it on android without any problem. But Im not able to play the recorded audio from a android on a ios.
I have tried to play it as a base64 and streaming by using the url. I don't know what to do play it, since nothing seems to work. But if some one just can point me in the right direction when it comes to what format I should use to record the audio on android so I can play it on ios, I would be very greatfull.
What I have so far:
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setAudioSamplingRate(44100);
recorder.setAudioEncodingBitRate(96000);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
but I got no idea what I should name the file I record on (like this record.mp3). Im using cordova so I have to do it when I start the recording. I have tried mp4, m4v, m4a, mp4, mp4, mpeg4 and mpeg. I have tried to record the file as a wav file as well, but then I get audio/x-wav in my base64 string.. Do I need to change the samplingRate, bitrate, outputformat or audio encoder to something else if I want to use .wav (not x-wav) and still make it work on ios?
After googling this issue, it seems even the very popular app "Evernote" has the same issue, and users are gutted about it. I did come across this question here on SO:
audio format for iOS and Android
They use a web service to convert the files to mp3, which works universally. I am sure you could find some way to do this without a middle man, but it should "point you in the right direction".
Hope this helps.
Cheers

How to Control media player android while Playing Rtsp Link on Samsung Galaxy S3?

I have made a small app for playing live stream.It is working good on other devices but on Samsung Galaxy S3 can not control the media player. I am using media player using the following code
sdrPlayer = new MediaPlayer();
sdrPlayer.setOnErrorListener(video.this);
sdrPlayer.setOnCompletionListener(video.this);
sdrPlayer.setOnPreparedListener(video.this);
sdrPlayer.setOnBufferingUpdateListener(video.this);
sdrPlayer.setDataSource(video.this, Uri.parse(url));
sdrPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
sdrPlayer.setScreenOnWhilePlaying(true);
sdrPlayer.prepareAsync();
but media player is throwing the issue media player error (1, -110) but I do not know the meaning of this error and also there is no proper documentation. I found this documentation but I can not get the error and also media player starts playing a bit late after calling start function in on prepare listener.I can not control the pause and play of the stream.
Any kind of help will be highly appreciable.
It is not enough of information. I think adding more code, may be even full file, would help. As per my experience, S3 is less troublesome device on playing rtsp streams, I have created rtsp player too. You might have done something wrong. Let's also ask what the stream you are trying to play, hls, anything else?
You could also do the following:
try to play the stream with some desktop player: quicktime, mplayer.
Do they play it right?
try to validate the stream with one of those rtsp streams validators, do they find it ok?

Stuttering playback on large MP4 with Vitamio

I'm creating an app that has a function that plays user selected video's. Nothing fancy, just playback of video's on the device itself without any advanced settings. Since MediaPlayer has issues with some video types I use Vitamio. It works great on smaller compressed video's but when I select a mp4 video that I've recorded with my phone itself it stutters, both audio and video. I tried changing video quality of the Vitamio Media Player, but it doesn't seem to have any effect.
I'm quite stuck in finding a solution, anyone who has any experience with this?
Please sure the video you recorded is ok, you can playback the video use VPlayer. or pull the video to your computer playback it.
if first ok ,you can try use Vitamio hardware decoder playback it.

How to record audio in mp4/m4a format in Android 2.3(Gingerbread)?

I am trying to record audio in my Android app, but I want the audio file in .mp4 format with AAC LC encoding ; playable on my desktop. So, using the following code, I tried to record, and i was able to play it back on my android.
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mRecorder.setOutputFile("/mnt/sdcard/abcapp/test.mp4");
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
But, when I tried to play it on my PC, I was not able to play the mp4 file. I tried it using all the media players including VLC, KMPlayer, etc. but was not able to play it.
The most irritating point is that there are apps on the Play Store like "Easy Voice Recorder" which record in .mp4 and can be played back using Windows Media Player.
Please help.
Thanks
Found the solution. Actually, might as well call it a bug in Android.
I did not stop the audio using mRecorder.stop() but had set mRecorder.setMaxDuration(10000). So, the audio recorder stopped automatically and did not encode the audio to AAC or did not apply the appropriate containers, hence would not get the proper files.
The solution is simple in case you are using mRecorder.setMaxDuration(), implement the containing class with MediaRecorder.OnInfoListener and when the callback for the time out occurs call mRecorder.stop()

Categories

Resources