B4A Library FFmpeg_b4a - a FFmpeg library for b4a (decoding/streaming)

Mark Zraik

Member
Licensed User
Longtime User

moster67

Expert
Licensed User
Longtime User
Well, ALL of the files I've tested do not work, so it is probably a bug somewere... For instance, take this one:

http://download.wavetlan.com/SVV/Media/HTTP/BlackBerry.mp4

If you look carefully in the unfiltered log, you can see the following message:
B4X:
No codec could be found with id 13

Apparently the previous error message is not entirely the reason for the failure but it probably pops up nonetheless since it is somehow related to the missing codec. By having a look at the unfiltered log, I can see that the missing codec is
B4X:
Video: mpeg4 (mp4v / 0x7634706D), 320x180, 348 kb/s

I built a new FFMpeg build and compiled the same and now the BlackBerry.mp4 file works fine.
 

wimpie3

Well-Known Member
Licensed User
Longtime User

This does not seem to be working. I get an error:
B4X:
java.lang.ClassCastException: android.widget.VideoView cannot be cast to tv.danmaku.ijk.media.widget.VideoView

However, this code seems to work:

B4X:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <tv.danmaku.ijk.media.widget.VideoView android:id="@+id/videoViewRelative"
        android:layout_alignParentTop="true"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    </tv.danmaku.ijk.media.widget.VideoView>

</RelativeLayout>
 

moster67

Expert
Licensed User
Longtime User


Great!
 

wimpie3

Well-Known Member
Licensed User
Longtime User
Where can I download the new version with the new FFMPEG?
 

wimpie3

Well-Known Member
Licensed User
Longtime User
No idea on where I can download the most recent version with the latest FFMPEG?
 

moster67

Expert
Licensed User
Longtime User
FFMpeg_B4A (version 1.22)

Final version of FFMpeg_B4A was released (I don't consider it a beta any more). There is now a single library with support for armeabi, armeabi-v7a and x86.
Please read also the added "Important final notes" section in the first post for important information about the library.
 

wimpie3

Well-Known Member
Licensed User
Longtime User
Unfortunately, I get the same error on the backberry.mp4 file:

B4X:
IjkMediaPlayer_native_init
IjkMediaPlayer_native_setup
IjkMediaPlayer_setAvFormatOption
ijkmp_set_format_option(http-detect-range-support, 0)
ijkmp_set_format_option()=void
IjkMediaPlayer_setOverlayFormat
ijkmp_set_overlay_format(RV32(0x32335652))
ijkmp_set_overlay_format()=void
IjkMediaPlayer_setDataSourceAndHeaders
setDataSource: path /storage/emulated/0/blackberry.mp4
ijkmp_set_data_source(url="/storage/emulated/0/blackberry.mp4")
ijkmp_set_data_source(url="/storage/emulated/0/blackberry.mp4")=0
IjkMediaPlayer_setVideoSurface
ijkmp_set_android_surface(surface=0x1b90001d)
ijkmp_set_android_surface(surface=0x1b90001d)=void
IjkMediaPlayer_prepareAsync
ijkmp_prepare_async()
SDL_RunThread: [8602] ff_msg_loop
message_loop
FFP_MSG_FLUSH:
ijkmp_prepare_async()=0
IjkMediaPlayer_setVideoSurface
ijkmp_set_android_surface(surface=0x1ba0001d)
ijkmp_set_android_surface(surface=0x1ba0001d)=void
SDL_RunThread: [8604] ff_read
SDL_RunThread: [8603] ff_vout
Option http-detect-range-support not found.
max_frame_duration: 3600.000
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/blackberry.mp4':
  Metadata:
    major_brand    :
mp42

    minor_version  :
0

    compatible_brands:
mp42isom

    creation_time  :
2007-01-29 23:25:04

  Duration:
00:00:36.92
, start:
0.000000
, bitrate:
432 kb/s

    Stream #0:0
(und)
: Audio: aac (mp4a / 0x6134706D), 32000 Hz, mono, fltp, 80 kb/s
(default)

    Metadata:
      creation_time  :
2007-01-29 23:25:04

      handler_name    :
soun

    Stream #0:1
(und)
: Video: mpeg4 (mp4v / 0x7634706D), 320x180, 348 kb/s
, 24 fps
, 24 tbr
, 600 tbn
, 600 tbc
(default)

    Metadata:
      creation_time  :
2007-01-29 23:25:04

      handler_name    :
vide

    Stream #0:2
(und)
: Data: none (mp4s / 0x7334706D), 0 kb/s
(default)

    Metadata:
      creation_time  :
2007-01-29 23:25:31

      handler_name    :
sdsm

    Stream #0:3
(und)
: Data: none (mp4s / 0x7334706D), 0 kb/s
(default)

    Metadata:
      creation_time  :
2007-01-29 23:25:31

      handler_name    :
odsm

SDL_AndroidAudioTrack: CHANNEL_OUT_MONO
SDL_AndroidAudioTrack: ENCODING_PCM_16BIT
sdl_audiotrack_new: init volume as 1.000000/(0.000000,1.000000)
SDL_RunThread: [8606] ff_aout_android


No codec could be found with id 13
ijkmp_get_msg: FFP_MSG_PREPARED
FFP_MSG_PREPARED:
unknown FFP_MSG_xxx(700)
Fatal signal 11 (SIGSEGV) at 0x0000002c (code=1), thread 8604 (b4a.example)
 

moster67

Expert
Licensed User
Longtime User
Unfortunately, I get the same error on the backberry.mp4 file:.....

The FFmpeg-library is the same as the first beta-libraries I posted earlier. The only difference is that there is now a single library and not 3 different ones. Other changes have not been done to it since I want to stick with the original FFmpeg-configuration implemented by the author of the library.

If you would have read the updated information in the first post, you would have seen how you could track down your error and how to conclude that your error is due to a missing codec. In order to fix it, you will need to compile a new FFmpeg-library and include the missing codec. I cannot provide a library which is working for all available codecs out there. If I would, the library would be huge while I want it rather small and optimized.

I believe that I have provided a wrapper which is helpful and useful for the B4A-community and it will (probably) work with any FFmpeg-library created according to the instructions of IJKPlayer's author. The creation of the FFmpeg-library does not require any programming knowledge and can be done by anyone who has the spirit to learn something new and to spend some time on it. That said, I may help out if I am contacted by PM.
 

wimpie3

Well-Known Member
Licensed User
Longtime User
Ok, fair enough, but can you please provide a list of the included codecs?
 

moster67

Expert
Licensed User
Longtime User
Ok, fair enough, but can you please provide a list of the included codecs?

Sure: take a look here

Support for the mp4-container is already there. You will need to add the mpeg4-codec in order to decode the Blackberry.mp4 file. Should be sufficient by adding the following line in the decoder-section:
B4X:
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-decoder=mpeg4"

However, mp4 is a container (containing audio/video and meta-data) and sometimes the codecs involved may be different and mpeg4 may not always work if another codec was used in mp4-containers. If you have the luxury to encode the video-file yourself, you can use one of the already supported codecs and you should be good.
 

wimpie3

Well-Known Member
Licensed User
Longtime User
@moster67 I have the "luxury" to encode the file I need to show in any format I want... so I'd prefer to go that way. The page you pointed me to has "h264" in the list, so I'll try with that one... thanks for all the trouble!
 

wimpie3

Well-Known Member
Licensed User
Longtime User
@moster67 I'm about to give up.... I've been re-encoding my movie in over 10 formats (mpeg4, mp4, flv, f4v, avi, in fact every export format supported by my video editor). Some of them crash (due to a codec missing, I can understand that), but those that don't crash show a black video... In fact, the ONLY movie I ever got playing is the demo movie included... So I need some help here... can someone send me a file that is actually WORKING with this library so I can see what format is accepted?
 

moster67

Expert
Licensed User
Longtime User

Could be that if you encode a video, you gotta make sure that the audio-codec is supported too as well as the container. Maybe some containers accepts only certain video/audio codecs? The tests I have done are all in streaming except for the Blackberry.mp4 file you linked (which I tried in local) and they all work fine as long as the codec(s) is/are supported. If you upload your actual video-file somewhere so I can download it, then I can test it at my end. If you prefer, you can send the link by PM.
 

GabrielM

Member
Licensed User
Longtime User

Hi moster67

I have a video stream that currently I am accessing it in win32 with a videolan/vlc plugin.
The stream address I am using is:
B4X:
 rtsp://192.168.1.104:556/multicast/
Would it be possible to access this video stream with your library, please?

Btw, here is a working sample of a simple html code I am using now too get the above stream:
B4X:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<HTML>
  <BODY marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
  <OBJECT classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921"
  codebase="http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab"
  width="480" height="360" id="vlc" events="True">
  <param name="Src" value="rtsp://192.168.1.104:556/multicast/" />
  <param name="ShowDisplay" value="True" />
  <param name="AutoLoop" value="False" />
  <param name="AutoPlay" value="True" />
  <embed id="vlcEmb"  type="application/x-google-vlc-plugin" version="VideoLAN.VLCPlugin.2" autoplay="yes" loop="no" width="480" height="360"
  target="rtsp://192.168.1.104:556/multicast/" ></embed>
  </OBJECT>
  </BODY>
</HTML>


Regards,
Gabi.
 

moster67

Expert
Licensed User
Longtime User
@GabrielM

FFmpeg seems to support rtsp (see here). If this library does, I cannot say since I have never tried it with rtsp so you will need to test it yourself unless someone else can confirm if it works or not.

Generally speaking, if it works with Vitamio, then it should work fine with this wrapper too. If it does not, then you probably need to "play around" with the config-file and compile new so-files.
 

GabrielM

Member
Licensed User
Longtime User
Hi moster67

have tried few with this lib but no luck so far. I will try to compile new so-files.
thank you.

Regards,
Gabi.
 

wimpie3

Well-Known Member
Licensed User
Longtime User
After several days of testing, I'm still unable to stretch my video to fill the whole screen... no matter what I do, no matter what XML file I use as layout, the video is ALWAYS shown to fit horizontally (with black borders on the top and on the bottom). I'm afraid I need some help here...
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…