2
My Code::

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        VideoView videoView = (VideoView) findViewById(R.id.videoView1);
        MediaController mediaController = new MediaController(this);
        mediaController.setAnchorView(videoView);

        Uri video = Uri
                .parse("www.logisticinfotech.com/client/Malasiya Cup/movie.mp4");
        videoView.setMediaController(mediaController);
        videoView.setVideoURI(video);
        videoView.start();

    }

Error::Sorry,This video cannot be played.

Logcat::

01-03 20:19:14.044: DEBUG/AndroidRuntime(454): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
01-03 20:19:14.044: DEBUG/AndroidRuntime(454): CheckJNI is ON
01-03 20:19:14.224: DEBUG/AndroidRuntime(454): --- registering native functions ---
01-03 20:19:14.874: INFO/ActivityManager(59): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.logistic.videoview/.MainActivity }
01-03 20:19:15.014: DEBUG/AndroidRuntime(454): Shutting down VM
01-03 20:19:15.044: DEBUG/dalvikvm(454): Debugger has detached; object registry had 1 entries
01-03 20:19:15.134: INFO/AndroidRuntime(454): NOTE: attach of thread 'Binder Thread #3' failed
01-03 20:19:15.784: INFO/StagefrightPlayer(34): setDataSource('www.logisticinfotech.com/client/Malasiya Cup/movie.mp4')
01-03 20:19:15.805: ERROR/MediaPlayer(420): error (1, -2147483648)
01-03 20:19:15.834: INFO/ActivityManager(59): Displayed activity com.logistic.videoview/.MainActivity: 821 ms (total 821 ms)
01-03 20:19:15.885: ERROR/MediaPlayer(420): Error (1,-2147483648)
01-03 20:19:15.885: DEBUG/VideoView(420): Error: 1,-2147483648
Samir Mangroliya
  • 39,918
  • 16
  • 117
  • 134

4 Answers4

2

I'd recommend you have a look at Android's overview of supported media formats. This site covers everything from the first versions of Android to the latest:

Android Supported Media Formats

I'm guessing you're trying to include a video in your application, and that it needs to work on all devices, so I'd suggest you go ahead and try to encode a video with a profile similar to the SD (High quality) listed on the above mentioned site.

There are plenty of free video converters available that you can use for encoding the video - one of them could be Freemake Video Converter.

Michell Bak
  • 13,182
  • 11
  • 64
  • 121
1

To expand further on my comment, I had fought a lot with different encodings/formats/etc until I got the one that worked on all android devices (at least all that I tested). Using ffmpeg, here's what finally worked:

/usr/bin/ffmpeg -i inputfile.ext -y -s 320x240 -vcodec libx264 -vpre medium -vpre baseline -acodec libfaac output.mp4
Aleks G
  • 56,435
  • 29
  • 168
  • 265
  • I fallowed the steps from here : http://jungels.net/articles/ffmpeg-howto.html . Everything seemed to work fine, but now when I use the command given by you, it says: Unknown encoder 'libx264' .what to do? – Iulia Barbu Jan 03 '12 at 16:09
  • What operating system are you using ffmpeg on? If it's windows it may be 'x264' (without the 'lib'). Otherwise you may have an incomplete installation of ffmpeg. Run `ffmpeg -codecs` to see if x264 codec is installed. – Aleks G Jan 03 '12 at 16:15
  • I'm using mac os. On ffmpeg -codecs run , i have in the list : D V D h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 . – Iulia Barbu Jan 03 '12 at 16:18
  • That's your issue. You don't have the x264 encoder installed. My mac osx can run this command with no problem - and my line contains ` EV libx264 libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10` Try recompiling the ffmpeg, running `configure` with `./configure --enable-shared --disable-mmx --enable-libmp3lame --enable-gpl --enable-zlib --enable-libvorbis --enable-libfaac --enable-nonfree --enable-libx264 --enable-pthreads --enable-libtheora --arch=x86_64` – Aleks G Jan 03 '12 at 16:25
  • I'll try that , and be back to tell if it worked. Thanks in advance! – Iulia Barbu Jan 03 '12 at 16:27
  • @AleksG What you do for play video in videoview? – Samir Mangroliya Jan 03 '12 at 16:47
  • @Samir My playback code is pretty much the same as in the original question – Aleks G Jan 03 '12 at 16:56
  • What should i do for remove this alert and play video? – Samir Mangroliya Jan 03 '12 at 17:04
  • it seems I'm doing something wrong but I don't know what. I've done it all over again , and at command ./configure --enable-shared --disable-mmx --enable-libmp3lame --enable-gpl --enable-zlib --enable-libx264 --enable-pthreads --arch=x86_64 I have this error : ERROR: libx264 not found – Iulia Barbu Jan 04 '12 at 08:59
  • x264 is an external library depencency, you need to build/install it separately before compiling ffmpeg - have a look at this page: http://www.martinlos.com/?p=41 - specifically, search for 'x264'. While there, you may want to check other optional dependencies. – Aleks G Jan 04 '12 at 09:12
  • ok I have installed x264 , it sais successfully in usr/bin. but when I give the command you gave , it still says unknown x264. Do you happen to have a link to a good tutorial for installing ffmpeg? I believe it's something wrong with the paths :( – Iulia Barbu Jan 04 '12 at 10:29
  • I myself used the page I gave you as a reference - and it seems to work, try following those steps. – Aleks G Jan 04 '12 at 11:19
0

i had d same issue and i resolved by adding a delay of 250ms. actually the error occurs when we try to capture and play immediately. At that time, the engine is not yet ready to play (coz it hasnt reached End of streami.e. hasnt read the video completely)

user874014
  • 21
  • 2
0

I have the same problem , I just figured out that it cames from the video format and encoding. But I didn't really fing the combination thet works on all devices.

thanks for give the answer if you find it!

Iulia Barbu
  • 1,522
  • 12
  • 25
  • have a look at this : http://stackoverflow.com/questions/4022072/android-video-streaming-problem – Iulia Barbu Jan 03 '12 at 15:07
  • hello Samir, this is my issue to. I don't know how to encode my video to work , that's why I'm trying this thing with ffmpeg. (I've just gave you the link that helped me somehow to clear things in my mind) – Iulia Barbu Jan 04 '12 at 09:02