Convert Figma logo to code with AI

bilibili logoijkplayer

Android/iOS video player based on FFmpeg n3.4, with MediaCodec, VideoToolbox support.

32,414
8,105
32,414
2,874

Top Related Projects

21,700

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media

VLC for Android, Android TV and ChromeOS

JavaScript player library / DASH & HLS client / MSE-EME player

18,228

Kodi is an award-winning free and open source home theater/media center software and entertainment hub for digital media. With its beautiful interface and powerful skinning engine, it's available for Android, BSD, Linux, macOS, iOS, tvOS and Windows.

44,846

Mirror of https://git.ffmpeg.org/ffmpeg.git

Quick Overview

ijkplayer is a multimedia framework based on FFmpeg, which can be used to play various media formats on Android and iOS platforms. It provides a set of APIs for developers to easily integrate video playback functionality into their applications.

Pros

  • Cross-platform: ijkplayer supports both Android and iOS platforms, allowing developers to build consistent media playback experiences across different devices.
  • Extensive codec support: The project is based on FFmpeg, which provides support for a wide range of audio and video codecs, enabling playback of various media formats.
  • Customizable: ijkplayer offers a flexible and extensible architecture, allowing developers to customize the player's behavior and integrate it into their specific use cases.
  • Active community: The project has an active community of contributors and users, providing ongoing support, bug fixes, and feature enhancements.

Cons

  • Complexity: The project's extensive feature set and integration with FFmpeg can make the initial setup and configuration more complex, especially for developers new to the project.
  • Performance overhead: Depending on the device and media being played, the FFmpeg-based implementation may introduce some performance overhead compared to platform-specific media players.
  • Dependency on FFmpeg: The project's reliance on FFmpeg means that developers need to be aware of the potential licensing and legal implications of using FFmpeg in their applications.
  • Limited documentation: While the project has good documentation, some areas may be less comprehensive, making it challenging for new users to get started quickly.

Code Examples

Initializing the Player

// Create a new IjkMediaPlayer instance
IjkMediaPlayer mediaPlayer = new IjkMediaPlayer();

// Set the data source for the player
mediaPlayer.setDataSource(videoUrl);

// Prepare the player for playback
mediaPlayer.prepareAsync();

Controlling Playback

// Start playing the media
mediaPlayer.start();

// Pause the playback
mediaPlayer.pause();

// Stop the playback
mediaPlayer.stop();

Handling Playback Events

// Register a listener for playback events
mediaPlayer.setOnPreparedListener(new IMediaPlayer.OnPreparedListener() {
    @Override
    public void onPrepared(IMediaPlayer mp) {
        // Media is ready to play
        mediaPlayer.start();
    }
});

mediaPlayer.setOnCompletionListener(new IMediaPlayer.OnCompletionListener() {
    @Override
    public void onCompletion(IMediaPlayer mp) {
        // Playback has completed
    }
});

Customizing the Player

// Set the video scaling mode
mediaPlayer.setVideoScalingMode(IjkMediaPlayer.SDL_AVCTX_FLAG_CROPPED);

// Enable hardware acceleration
mediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec", 1);

Getting Started

To get started with ijkplayer, follow these steps:

  1. Clone the repository:

    git clone https://github.com/bilibili/ijkplayer.git
    
  2. Build the native libraries:

    cd ijkplayer
    ./init-android.sh
    ./compile-ffmpeg.sh
    ./compile-ijk.sh
    
  3. Integrate the library into your Android project:

    • Copy the generated .so files from the android/libs directory to your project's jniLibs directory.

    • Add the following dependencies to your project's build.gradle file:

      dependencies {
          implementation 'tv.danmaku.ijk.media:ijkplayer-java:0.8.8'
          implementation 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8'
          // Add other ABI-specific dependencies as needed
      }
      
  4. Initialize and use the player:

    Refer to the code examples provided earlier to learn how to initialize, control, and customize the ijkplayer in your Android application.

Competitor Comparisons

21,700

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media

Pros of ExoPlayer

  • Native Android implementation, better integration with Android ecosystem
  • More frequent updates and active development from Google
  • Extensive documentation and community support

Cons of ExoPlayer

  • Limited to Android platform only
  • Steeper learning curve for developers new to Android

Code Comparison

ExoPlayer

SimpleExoPlayer player = new SimpleExoPlayer.Builder(context).build();
MediaItem mediaItem = MediaItem.fromUri(videoUri);
player.setMediaItem(mediaItem);
player.prepare();
player.play();

ijkplayer

IjkMediaPlayer player = new IjkMediaPlayer();
player.setDataSource(videoUri);
player.prepareAsync();
player.start();

Key Differences

  • ExoPlayer is specifically designed for Android, while ijkplayer is cross-platform
  • ijkplayer is based on FFmpeg, offering broader codec support
  • ExoPlayer has a more modular architecture, allowing for easier customization
  • ijkplayer may have better performance for certain video formats due to its FFmpeg base

Use Cases

  • Choose ExoPlayer for Android-specific projects with standard video formats
  • Opt for ijkplayer when cross-platform compatibility or extensive codec support is required

Community and Support

  • ExoPlayer has larger community and official Google support
  • ijkplayer has a dedicated following, especially in Asian markets

VLC for Android, Android TV and ChromeOS

Pros of VLC-Android

  • More comprehensive media player with a wider range of supported formats and codecs
  • Larger and more active community, resulting in frequent updates and improvements
  • Built-in streaming capabilities and network playback support

Cons of VLC-Android

  • Larger app size due to its comprehensive feature set
  • May be more complex for developers to customize or integrate into their own projects
  • Potentially higher resource usage on mobile devices

Code Comparison

VLC-Android (Java):

@Override
public void onPlaybackStateChanged(int state) {
    switch (state) {
        case PlaybackStateCompat.STATE_PLAYING:
            mHandler.sendEmptyMessage(SHOW_PROGRESS);
            break;
        case PlaybackStateCompat.STATE_PAUSED:
            mHandler.removeMessages(SHOW_PROGRESS);
            break;
    }
}

IJKPlayer (Java):

@Override
public void onInfo(IMediaPlayer mp, int what, int extra) {
    switch (what) {
        case IMediaPlayer.MEDIA_INFO_BUFFERING_START:
            if (mBufferingIndicator != null)
                mBufferingIndicator.setVisibility(View.VISIBLE);
            break;
        case IMediaPlayer.MEDIA_INFO_BUFFERING_END:
            if (mBufferingIndicator != null)
                mBufferingIndicator.setVisibility(View.GONE);
            break;
    }
}

JavaScript player library / DASH & HLS client / MSE-EME player

Pros of Shaka Player

  • Web-based player with broad browser compatibility
  • Supports adaptive streaming protocols like DASH and HLS
  • Extensive documentation and active community support

Cons of Shaka Player

  • Limited to web environments, not suitable for native mobile apps
  • May have higher resource usage compared to native players

Code Comparison

Shaka Player (JavaScript):

const player = new shaka.Player(videoElement);
player.load('https://example.com/video.mpd').then(() => {
  console.log('The video has been loaded');
});

IJKPlayer (Java):

IjkMediaPlayer player = new IjkMediaPlayer();
player.setDataSource("https://example.com/video.mp4");
player.prepareAsync();
player.start();

Key Differences

  • IJKPlayer is a native player for Android and iOS, while Shaka Player is web-based
  • Shaka Player focuses on adaptive streaming, while IJKPlayer supports a wider range of formats
  • IJKPlayer offers lower-level control, suitable for custom implementations
  • Shaka Player provides built-in DRM support and extensive streaming features

Use Cases

  • Choose Shaka Player for web applications requiring adaptive streaming
  • Opt for IJKPlayer when developing native mobile apps or need custom video playback solutions

Community and Support

  • Both projects have active communities and regular updates
  • Shaka Player has more extensive documentation and examples
  • IJKPlayer benefits from Bilibili's large user base and real-world testing
18,228

Kodi is an award-winning free and open source home theater/media center software and entertainment hub for digital media. With its beautiful interface and powerful skinning engine, it's available for Android, BSD, Linux, macOS, iOS, tvOS and Windows.

Pros of XBMC

  • Comprehensive media center solution with a wide range of features
  • Large and active community, providing extensive support and add-ons
  • Cross-platform compatibility (Windows, Linux, macOS, Android, iOS)

Cons of XBMC

  • Larger codebase and more complex architecture
  • Steeper learning curve for developers and users
  • Higher resource consumption due to its full-featured nature

Code Comparison

XBMC (C++):

bool CVideoPlayer::OpenDemuxStream()
{
  if (m_pDemuxer)
  {
    m_pDemuxer->Open(m_item.GetDynPath(), m_pInputStream, m_pDvdDemux);
    return true;
  }
  return false;
}

IJKPlayer (C):

int ijkmp_prepare_async(IjkMediaPlayer *mp)
{
    assert(mp);
    MPTRACE("ijkmp_prepare_async()\n");
    pthread_mutex_lock(&mp->mutex);
    int retval = ijkmp_prepare_async_l(mp);
    pthread_mutex_unlock(&mp->mutex);
    MPTRACE("ijkmp_prepare_async()=%d\n", retval);
    return retval;
}

While XBMC offers a more comprehensive media center solution with cross-platform support and a large community, IJKPlayer focuses on providing a lightweight, high-performance video player specifically for mobile platforms. XBMC's codebase is more complex, while IJKPlayer's is more streamlined for its specific purpose.

44,846

Mirror of https://git.ffmpeg.org/ffmpeg.git

Pros of FFmpeg

  • More comprehensive and feature-rich multimedia framework
  • Wider community support and active development
  • Extensive documentation and resources available

Cons of FFmpeg

  • Steeper learning curve for beginners
  • Larger codebase and potentially higher resource usage
  • May require more configuration for specific use cases

Code Comparison

FFmpeg:

AVFormatContext *fmt_ctx = NULL;
if (avformat_open_input(&fmt_ctx, filename, NULL, NULL) < 0) {
    fprintf(stderr, "Could not open source file %s\n", filename);
    exit(1);
}

ijkplayer:

IJKFFOptions *options = ijkplayer_create_ffmpeg_options();
ijkplayer_set_option(options, "mediacodec", 1);
ijkplayer_set_option(options, "opensles", 1);
ijkplayer_set_data_source(player, url);
ijkplayer_prepare_async(player);

Key Differences

  • FFmpeg is a general-purpose multimedia framework, while ijkplayer is specifically designed for Android and iOS video playback
  • ijkplayer is built on top of FFmpeg, providing a higher-level API for mobile development
  • FFmpeg offers more flexibility and control, while ijkplayer simplifies integration for mobile apps

Use Cases

  • FFmpeg: Ideal for complex multimedia processing tasks, server-side operations, and cross-platform desktop applications
  • ijkplayer: Better suited for mobile app developers looking for an easy-to-use video player solution with hardware acceleration support

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

ijkplayer

PlatformBuild Status
AndroidBuild Status
iOSBuild Status

Video player based on ffplay

Download

  • Android:
  • Gradle
# required
allprojects {
    repositories {
        jcenter()
    }
}

dependencies {
    # required, enough for most devices.
    compile 'tv.danmaku.ijk.media:ijkplayer-java:0.8.8'
    compile 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8'

    # Other ABIs: optional
    compile 'tv.danmaku.ijk.media:ijkplayer-armv5:0.8.8'
    compile 'tv.danmaku.ijk.media:ijkplayer-arm64:0.8.8'
    compile 'tv.danmaku.ijk.media:ijkplayer-x86:0.8.8'
    compile 'tv.danmaku.ijk.media:ijkplayer-x86_64:0.8.8'

    # ExoPlayer as IMediaPlayer: optional, experimental
    compile 'tv.danmaku.ijk.media:ijkplayer-exo:0.8.8'
}
  • iOS
  • in coming...

My Build Environment

Latest Changes

Features

  • Common
  • remove rarely used ffmpeg components to reduce binary size config/module-lite.sh
  • workaround for some buggy online video.
  • Android
  • platform: API 9~23
  • cpu: ARMv7a, ARM64v8a, x86 (ARMv5 is not tested on real devices)
  • api: MediaPlayer-like
  • video-output: NativeWindow, OpenGL ES 2.0
  • audio-output: AudioTrack, OpenSL ES
  • hw-decoder: MediaCodec (API 16+, Android 4.1+)
  • alternative-backend: android.media.MediaPlayer, ExoPlayer
  • iOS
  • platform: iOS 7.0~10.2.x
  • cpu: armv7, arm64, i386, x86_64, (armv7s is obselete)
  • api: MediaPlayer.framework-like
  • video-output: OpenGL ES 2.0
  • audio-output: AudioQueue, AudioUnit
  • hw-decoder: VideoToolbox (iOS 8+)
  • alternative-backend: AVFoundation.Framework.AVPlayer, MediaPlayer.Framework.MPMoviePlayerControlelr (obselete since iOS 8)

NOT-ON-PLAN

  • obsolete platforms (Android: API-8 and below; iOS: pre-6.0)
  • obsolete cpu: ARMv5, ARMv6, MIPS (I don't even have these types of devices…)
  • native subtitle render
  • avfilter support

Before Build

# install homebrew, git, yasm
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install git
brew install yasm

# add these lines to your ~/.bash_profile or ~/.profile
# export ANDROID_SDK=<your sdk path>
# export ANDROID_NDK=<your ndk path>

# on Cygwin (unmaintained)
# install git, make, yasm
  • If you prefer more codec/format
cd config
rm module.sh
ln -s module-default.sh module.sh
cd android/contrib
# cd ios
sh compile-ffmpeg.sh clean
  • If you prefer less codec/format for smaller binary size (include hevc function)
cd config
rm module.sh
ln -s module-lite-hevc.sh module.sh
cd android/contrib
# cd ios
sh compile-ffmpeg.sh clean
  • If you prefer less codec/format for smaller binary size (by default)
cd config
rm module.sh
ln -s module-lite.sh module.sh
cd android/contrib
# cd ios
sh compile-ffmpeg.sh clean
  • For Ubuntu/Debian users.
# choose [No] to use bash
sudo dpkg-reconfigure dash
  • If you'd like to share your config, pull request is welcome.

Build Android

git clone https://github.com/Bilibili/ijkplayer.git ijkplayer-android
cd ijkplayer-android
git checkout -B latest k0.8.8

./init-android.sh

cd android/contrib
./compile-ffmpeg.sh clean
./compile-ffmpeg.sh all

cd ..
./compile-ijk.sh all

# Android Studio:
#     Open an existing Android Studio project
#     Select android/ijkplayer/ and import
#
#     define ext block in your root build.gradle
#     ext {
#       compileSdkVersion = 23       // depending on your sdk version
#       buildToolsVersion = "23.0.0" // depending on your build tools version
#
#       targetSdkVersion = 23        // depending on your sdk version
#     }
#
# If you want to enable debugging ijkplayer(native modules) on Android Studio 2.2+: (experimental)
#     sh android/patch-debugging-with-lldb.sh armv7a
#     Install Android Studio 2.2(+)
#     Preference -> Android SDK -> SDK Tools
#     Select (LLDB, NDK, Android SDK Build-tools,Cmake) and install
#     Open an existing Android Studio project
#     Select android/ijkplayer
#     Sync Project with Gradle Files
#     Run -> Edit Configurations -> Debugger -> Symbol Directories
#     Add "ijkplayer-armv7a/.externalNativeBuild/ndkBuild/release/obj/local/armeabi-v7a" to Symbol Directories
#     Run -> Debug 'ijkplayer-example'
#     if you want to reverse patches:
#     sh patch-debugging-with-lldb.sh reverse armv7a
#
# Eclipse: (obselete)
#     File -> New -> Project -> Android Project from Existing Code
#     Select android/ and import all project
#     Import appcompat-v7
#     Import preference-v7
#
# Gradle
#     cd ijkplayer
#     gradle

Build iOS

git clone https://github.com/Bilibili/ijkplayer.git ijkplayer-ios
cd ijkplayer-ios
git checkout -B latest k0.8.8

./init-ios.sh

cd ios
./compile-ffmpeg.sh clean
./compile-ffmpeg.sh all

# Demo
#     open ios/IJKMediaDemo/IJKMediaDemo.xcodeproj with Xcode
# 
# Import into Your own Application
#     Select your project in Xcode.
#     File -> Add Files to ... -> Select ios/IJKMediaPlayer/IJKMediaPlayer.xcodeproj
#     Select your Application's target.
#     Build Phases -> Target Dependencies -> Select IJKMediaFramework
#     Build Phases -> Link Binary with Libraries -> Add:
#         IJKMediaFramework.framework
#
#         AudioToolbox.framework
#         AVFoundation.framework
#         CoreGraphics.framework
#         CoreMedia.framework
#         CoreVideo.framework
#         libbz2.tbd
#         libz.tbd
#         MediaPlayer.framework
#         MobileCoreServices.framework
#         OpenGLES.framework
#         QuartzCore.framework
#         UIKit.framework
#         VideoToolbox.framework
#
#         ... (Maybe something else, if you get any link error)
# 

Support (支持)

  • Please do not send e-mail to me. Public technical discussion on github is preferred.
  • 请尽量在 github 上公开讨论技术问题,不要以邮件方式私下询问,恕不一一回复。

License

Copyright (c) 2017 Bilibili
Licensed under LGPLv2.1 or later

ijkplayer required features are based on or derives from projects below:

android/ijkplayer-exo is based on or derives from projects below:

android/example is based on or derives from projects below:

ios/IJKMediaDemo is based on or derives from projects below:

ijkplayer's build scripts are based on or derives from projects below:

Commercial Use

ijkplayer is licensed under LGPLv2.1 or later, so itself is free for commercial use under LGPLv2.1 or later

But ijkplayer is also based on other different projects under various licenses, which I have no idea whether they are compatible to each other or to your product.

IANAL, you should always ask your lawyer for these stuffs before use it in your product.