├── README.md
├── android
├── .gitignore
├── app
│ ├── .gitignore
│ ├── CMakeLists.txt
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── tuesda
│ │ │ └── gouzi
│ │ │ └── ExampleInstrumentedTest.kt
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── cpp
│ │ │ └── native-lib.cpp
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── tuesda
│ │ │ │ └── gouzi
│ │ │ │ ├── GLog.kt
│ │ │ │ ├── MainActivity.kt
│ │ │ │ ├── PickVideoActivity.kt
│ │ │ │ ├── Util.kt
│ │ │ │ └── VideoInfo.kt
│ │ └── res
│ │ │ ├── drawable-v24
│ │ │ └── ic_launcher_foreground.xml
│ │ │ ├── drawable
│ │ │ └── ic_launcher_background.xml
│ │ │ ├── layout
│ │ │ ├── activity_main.xml
│ │ │ └── activity_pick_video.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ ├── ic_launcher.xml
│ │ │ └── ic_launcher_round.xml
│ │ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ └── values
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── tuesda
│ │ └── gouzi
│ │ └── ExampleUnitTest.kt
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
└── doc
├── h264
└── concept.md
├── issues
└── 20181113_部分机型硬压视频和IOS播放器不兼容的问题
│ ├── 20181113_部分机型硬压视频和IOS播放器不兼容的问题.md
│ └── imgs
│ ├── issue_video.jpg
│ ├── issue_video_nal_log.jpg
│ ├── mp4_sps_pps_location.jpg
│ ├── normal_video_nal_log_1.jpg
│ └── normal_video_nal_log_2.jpg
└── plan.md
/README.md:
--------------------------------------------------------------------------------
1 | * 目的: 一个基于FFmpeg视频转码 App 1.0 版本,名字叫【狗子】,英文名【Gouzi】。
2 | * 时间: 2018.11.8 ~ 2019.2.8 / 3 months / 12 weeks
3 | * 节奏: 每周一个小版本 version 0.1 0.2 0.3 ... 0.11 1.0,每周四发版本。
4 | * ver 0.4: 基本款:能用
5 | * ver 0.1 选视频
6 | * ver 0.2 整个集成 FFmpeg
7 | * ver 0.3 转码
8 | * ver 0.4 视频输出/Log展示
9 | * ver 0.8: FFmpeg 瘦身
10 | * ver 0.5 本地编译 FFmpeg 去掉不必要模块
11 | * ver 0.6 尝试直接调用 FFmpeg 库代码并适配 Android 端代码
12 | * ver 0.7 继续精简 FFmpeg 代码
13 | * ver 0.8 继续精简 Ffmpeg 代码
14 | * ver 1.0: 终极款:轻量
15 | * ver 0.9 - ver 1.0 继续精简 FFmpeg 代码
16 |
17 |
18 | 这个项目的难点不在于 Android 端,而在于 FFmpeg 的适配。由于 FFmpeg 没有 Android 版本,所以必须通过 JNI 方式配合 FFmpeg 编译的 so 包去配合使用。问题在于 FFmpeg 编译的 so 包体积非常大,全量编译包有将近 20M,这对于目前安装包只有 13M 的即刻来说是不可接受的。所以这个项目的大部分精力是用来精简 FFmpeg,计划从小版本 0.5 开始就做这部分。
19 |
20 | 精简的方式主要是自定义编译 FFmpeg 和代码层面对 FFmpeg 进行剪裁。第一部分相对简单,网上也有很多教程。难的是第二种方式,因为这里需要阅读 FFmpeg 源码,而 FFmpeg 几乎都是 c/c++ 写的,我上一次看 c 代码还是在大学时候。但第一种的精简大小很有限,必须尝试第二种。写这个开发计划的目的就是为了督促我知难而上,这部分代码也会放在我 github 的公开库上面,这么做的目的也是为了防止我半途而废,希望最后不要打脸🙏🙏🙏。
--------------------------------------------------------------------------------
/android/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | **/.idea
3 | .gradle
4 | /local.properties
5 | .DS_Store
6 | /build
7 | /captures
8 | .externalNativeBuild
--------------------------------------------------------------------------------
/android/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/android/app/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # For more information about using CMake with Android Studio, read the
2 | # documentation: https://d.android.com/studio/projects/add-native-code.html
3 |
4 | # Sets the minimum version of CMake required to build the native library.
5 |
6 | cmake_minimum_required(VERSION 3.4.1)
7 |
8 | # Creates and names a library, sets it as either STATIC
9 | # or SHARED, and provides the relative paths to its source code.
10 | # You can define multiple libraries, and CMake builds them for you.
11 | # Gradle automatically packages shared libraries with your APK.
12 |
13 | add_library( # Sets the name of the library.
14 | native-lib
15 |
16 | # Sets the library as a shared library.
17 | SHARED
18 |
19 | # Provides a relative path to your source file(s).
20 | src/main/cpp/native-lib.cpp)
21 |
22 | # Searches for a specified prebuilt library and stores the path as a
23 | # variable. Because CMake includes system libraries in the search path by
24 | # default, you only need to specify the name of the public NDK library
25 | # you want to add. CMake verifies that the library exists before
26 | # completing its build.
27 |
28 | find_library( # Sets the name of the path variable.
29 | log-lib
30 |
31 | # Specifies the name of the NDK library that
32 | # you want CMake to locate.
33 | log)
34 |
35 | # Specifies libraries CMake should link to your target library. You
36 | # can link multiple libraries, such as libraries you define in this
37 | # build script, prebuilt third-party libraries, or system libraries.
38 |
39 | target_link_libraries( # Specifies the target library.
40 | native-lib
41 |
42 | # Links the target library to the log library
43 | # included in the NDK.
44 | ${log-lib})
--------------------------------------------------------------------------------
/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | apply plugin: 'kotlin-android'
4 |
5 | apply plugin: 'kotlin-android-extensions'
6 |
7 | android {
8 | compileSdkVersion 28
9 | defaultConfig {
10 | applicationId "com.tuesda.gouzi"
11 | minSdkVersion 21
12 | targetSdkVersion 28
13 | versionCode 1
14 | versionName "1.0"
15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16 | externalNativeBuild {
17 | cmake {
18 | cppFlags ""
19 | }
20 | }
21 | }
22 | buildTypes {
23 | release {
24 | minifyEnabled false
25 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
26 | }
27 | }
28 | externalNativeBuild {
29 | cmake {
30 | path "CMakeLists.txt"
31 | }
32 | }
33 | }
34 |
35 | dependencies {
36 | implementation fileTree(dir: 'libs', include: ['*.jar'])
37 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
38 | testImplementation 'junit:junit:4.12'
39 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
40 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
41 |
42 | implementation "androidx.core:core-ktx:1.0.1"
43 | implementation "com.google.android.material:material:1.0.0"
44 | implementation "androidx.constraintlayout:constraintlayout:1.1.3"
45 | }
46 |
--------------------------------------------------------------------------------
/android/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/android/app/src/androidTest/java/com/tuesda/gouzi/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.tuesda.gouzi
2 |
3 | import android.support.test.InstrumentationRegistry
4 | import android.support.test.runner.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getTargetContext()
22 | assertEquals("com.tuesda.gouzi", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/android/app/src/main/cpp/native-lib.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | extern "C" JNIEXPORT jstring JNICALL
5 | Java_com_tuesda_gouzi_MainActivity_stringFromJNI(
6 | JNIEnv *env,
7 | jobject /* this */) {
8 | std::string hello = "Hello from C++";
9 | return env->NewStringUTF(hello.c_str());
10 | }
11 |
--------------------------------------------------------------------------------
/android/app/src/main/java/com/tuesda/gouzi/GLog.kt:
--------------------------------------------------------------------------------
1 | package com.tuesda.gouzi
2 |
3 | import android.util.Log
4 |
5 | object GLog {
6 |
7 | private const val TAG = "GLog"
8 |
9 | fun i(tag: String, info: String) {
10 | Log.i(tag, info)
11 | }
12 |
13 | fun e(t: Throwable) {
14 | Log.e(TAG, t.toString())
15 | }
16 | }
--------------------------------------------------------------------------------
/android/app/src/main/java/com/tuesda/gouzi/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.tuesda.gouzi
2 |
3 | import android.content.Intent
4 | import android.os.Bundle
5 | import androidx.appcompat.app.AppCompatActivity
6 | import kotlinx.android.synthetic.main.activity_main.*
7 |
8 | class MainActivity : AppCompatActivity() {
9 |
10 | override fun onCreate(savedInstanceState: Bundle?) {
11 | super.onCreate(savedInstanceState)
12 | setContentView(R.layout.activity_main)
13 |
14 | // Example of a call to a native method
15 | sample_text.text = stringFromJNI()
16 | startActivity(Intent(this, PickVideoActivity::class.java))
17 | }
18 |
19 | /**
20 | * A native method that is implemented by the 'native-lib' native library,
21 | * which is packaged with this application.
22 | */
23 | external fun stringFromJNI(): String
24 |
25 | companion object {
26 |
27 | // Used to load the 'native-lib' library on application startup.
28 | init {
29 | System.loadLibrary("native-lib")
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/android/app/src/main/java/com/tuesda/gouzi/PickVideoActivity.kt:
--------------------------------------------------------------------------------
1 | package com.tuesda.gouzi
2 |
3 | import android.app.Activity
4 | import android.content.Intent
5 | import android.os.Bundle
6 | import android.view.View
7 | import androidx.appcompat.app.AppCompatActivity
8 |
9 |
10 | class PickVideoActivity : AppCompatActivity() {
11 | override fun onCreate(savedInstanceState: Bundle?) {
12 | super.onCreate(savedInstanceState)
13 | setContentView(R.layout.activity_pick_video)
14 | val btnPickVideo = findViewById(R.id.btn_pick_video)
15 | btnPickVideo.setOnClickListener {
16 | val i = Intent(Intent.ACTION_GET_CONTENT)
17 | i.type = "video/*"
18 | startActivityForResult(Intent.createChooser(i, "Select Video"), PICK_VIDEO_REQUEST_CODE)
19 | }
20 | }
21 |
22 | override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
23 | super.onActivityResult(requestCode, resultCode, data)
24 | if (resultCode == Activity.RESULT_OK && requestCode == PICK_VIDEO_REQUEST_CODE && data != null) {
25 | data.data?.let { Util.videoInfoOfUri(this, it) }.also {
26 | GLog.i(TAG, "picked video info: $it")
27 | }
28 | }
29 | }
30 |
31 | companion object {
32 | const val TAG = "PickVideoActivity"
33 | const val PICK_VIDEO_REQUEST_CODE = 0
34 | }
35 | }
--------------------------------------------------------------------------------
/android/app/src/main/java/com/tuesda/gouzi/Util.kt:
--------------------------------------------------------------------------------
1 | package com.tuesda.gouzi
2 |
3 | import android.content.Context
4 | import android.database.Cursor
5 | import android.net.Uri
6 | import android.provider.DocumentsContract
7 | import android.provider.MediaStore
8 | import androidx.core.database.getIntOrNull
9 | import androidx.core.database.getLongOrNull
10 | import androidx.core.database.getStringOrNull
11 |
12 | object Util {
13 | fun videoInfoOfUri(context: Context, uri: Uri): VideoInfo? {
14 | if (isMediaDocument(uri)) {
15 | val docId = DocumentsContract.getDocumentId(uri)
16 | val split = docId.split(":".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
17 | val selection = "_id=?"
18 | val selectionArgs = arrayOf(split[1])
19 |
20 | val projection = arrayOf(
21 | MediaStore.Video.Media.DATA,
22 | MediaStore.Video.Media.WIDTH,
23 | MediaStore.Video.Media.HEIGHT,
24 | MediaStore.Video.Media.DURATION
25 | )
26 | var cursor: Cursor? = null
27 | try {
28 | cursor = context.contentResolver.query(
29 | MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
30 | projection, selection, selectionArgs, null
31 | )
32 | cursor?.apply {
33 | if (moveToFirst()) {
34 | val path = getStringOrNull(getColumnIndexOrThrow(MediaStore.Video.Media.DATA))
35 | val width = getIntOrNull(getColumnIndexOrThrow(MediaStore.Video.Media.WIDTH)) ?: 1920
36 | val height = getIntOrNull(getColumnIndexOrThrow(MediaStore.Video.Media.HEIGHT)) ?: 1080
37 | val durationUs =
38 | getLongOrNull(getColumnIndexOrThrow(MediaStore.Video.Media.DURATION))?.let { it * 1000 }
39 | if (path != null && durationUs != null) {
40 | return VideoInfo(path, width, height, durationUs)
41 | }
42 | }
43 | }
44 | } catch (e: Exception) {
45 | GLog.e(e)
46 | } finally {
47 | cursor?.close()
48 | }
49 | }
50 | return null
51 | }
52 |
53 | private fun isMediaDocument(uri: Uri): Boolean {
54 | return "com.android.providers.media.documents" == uri.authority
55 | }
56 | }
--------------------------------------------------------------------------------
/android/app/src/main/java/com/tuesda/gouzi/VideoInfo.kt:
--------------------------------------------------------------------------------
1 | package com.tuesda.gouzi
2 |
3 | class VideoInfo(
4 | private val path: String,
5 | private val width: Int,
6 | private val height: Int,
7 | private val durationUs: Long
8 | ) {
9 | override fun toString(): String {
10 | return "VideoInfo(path='$path', width=$width, height=$height, durationUs=$durationUs)"
11 | }
12 | }
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
10 |
12 |
14 |
16 |
18 |
20 |
22 |
24 |
26 |
28 |
30 |
32 |
34 |
36 |
38 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
56 |
58 |
60 |
62 |
64 |
66 |
68 |
70 |
72 |
74 |
75 |
--------------------------------------------------------------------------------
/android/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
--------------------------------------------------------------------------------
/android/app/src/main/res/layout/activity_pick_video.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
12 |
13 |
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuesda/Gouzi/a5e6b64c583cef48ec5a23be30155216303410b1/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuesda/Gouzi/a5e6b64c583cef48ec5a23be30155216303410b1/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuesda/Gouzi/a5e6b64c583cef48ec5a23be30155216303410b1/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuesda/Gouzi/a5e6b64c583cef48ec5a23be30155216303410b1/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuesda/Gouzi/a5e6b64c583cef48ec5a23be30155216303410b1/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuesda/Gouzi/a5e6b64c583cef48ec5a23be30155216303410b1/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuesda/Gouzi/a5e6b64c583cef48ec5a23be30155216303410b1/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuesda/Gouzi/a5e6b64c583cef48ec5a23be30155216303410b1/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuesda/Gouzi/a5e6b64c583cef48ec5a23be30155216303410b1/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuesda/Gouzi/a5e6b64c583cef48ec5a23be30155216303410b1/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/android/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 |
7 |
--------------------------------------------------------------------------------
/android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Gouzi
3 |
4 |
--------------------------------------------------------------------------------
/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/android/app/src/test/java/com/tuesda/gouzi/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.tuesda.gouzi
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.3.0'
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.2.1'
11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | jcenter()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # Kotlin code style for this project: "official" or "obsolete":
15 | kotlin.code.style=official
16 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuesda/Gouzi/a5e6b64c583cef48ec5a23be30155216303410b1/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/android/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/doc/h264/concept.md:
--------------------------------------------------------------------------------
1 | ### H264 存储传输格式: Annex B / AVCC
2 |
3 | ```
4 | NALU is basic unit.
5 |
6 | Then,
7 |
8 | annexb format:
9 |
10 | ([start code] NALU) | ( [start code] NALU) |
11 |
12 | avcc format:
13 |
14 | ([extradata]) | ([length] NALU) | ([length] NALU) |
15 | ```
16 |
17 | In annexb, [start code] may be 0x000001 or 0x00000001.
18 |
19 | In avcc, the bytes of [length] depends on NALULengthSizeMinusOne in avcc extradata, the value of [length] depends on the size of following NALU and in both annexb and avcc format, the NALUs are no different.
20 |
21 | ### Annex B
22 |
23 | NALU/NAL: Network Abstraction Layer Units
24 | 开始码 00 00 00 01 / 00 00 01
25 | Nalu 第一个字节:
26 | bit0 通常为0
27 | bit1-bit2 为0表示没有被别的 nalu 引用,否则被别的 nalu 引用,值越大越重要
28 | bit3-bit7 表示 nalu type:
29 |
30 | | 0 | Unspecified | non-VCL |
31 | |---|---|---|
32 | |1|Coded slice of a non-IDR picture|VCL|
33 | |2|Coded slice data partition A|VCL|
34 | |3|Coded slice data partition B|VCL|
35 | |4|Coded slice data partition C|VCL|
36 | |5|Coded slice of an IDR picture|VCL|
37 | |6|Supplemental enhancement information (SEI)|non-VCL|
38 | |7|Sequence parameter set|non-VCL|
39 | |8|Picture parameter set|non-VCL|
40 | |9|Access unit delimiter|non-VCL|
41 | |10|End of sequence|non-VCL|
42 | |11|End of stream|non-VCL|
43 | |12|Filler data|non-VCL|
44 | |13|Sequence parameter set extension|non-VCL|
45 | |14|Prefix NAL unit|non-VCL|
46 | |15|Subset sequence parameter set|non-VCL|
47 | |16|Depth parameter set|non-VCL|
48 | |17..18|Reserved|non-VCL|
49 | |19|Coded slice of an auxiliary coded picture without partitioning|non-VCL|
50 | |20|Coded slice extension|non-VCL|
51 | |21|Coded slice extension for depth view components|non-VCL|
52 | |22..23|Reserved|non-VCL|
53 | |24..31|Unspecified|non-VCL|
54 |
--------------------------------------------------------------------------------
/doc/issues/20181113_部分机型硬压视频和IOS播放器不兼容的问题/20181113_部分机型硬压视频和IOS播放器不兼容的问题.md:
--------------------------------------------------------------------------------
1 | ### 部分 Android 手机硬压视频和 IOS 播放器不兼容的问题
2 | ---
3 |
4 | #### Android 硬压视频
5 | 通过 MediaExtractor 将 mp4 文件分解成 h264 码流文件和 aac 音频文件,再使用 MediaCodec 解码 h264 得到像素数据。降低画面分辨率、设置码率和关键帧间隔后通过 MediaCodec 重新编码得到 h264 文件,然后通过 mp4parser 将压缩后的 h264 码流和前面的 aac 音频文件重新合成 mp4 文件。因为音频数据占极少一部分,所以只对码流文件进行压缩。
6 |
7 | #### 遇到的问题
8 | 一加 5T、小米手机压缩得到的视频在 IOS 系统上播放时刚开始几秒出现绿屏。
9 | 
10 |
11 | #### 问题分析
12 | 通过调整关键帧间隔发现出问题的帧都位于第一个关键帧之后第二个关键帧之前,加上出问题的播放器都是苹果系的,猜测共用一块核心代码。所以怀疑是因为播放器没有正确读取到第一个关键帧信息,导致依赖它的帧都不能正常显示。
13 |
14 | 首先怀疑可能是第一个关键帧不存在,通过下面这条命令检查。
15 |
16 | ```
17 | ffprobe -i issue_video.mp4 -select_streams v -show_frames -show_entries frame=pkt_dts_time,pict_type -v error -of csv | grep -n I
18 | ```
19 |
20 | 输出结果如下:
21 |
22 | ```
23 | 1:frame,0.000000,I
24 | 301:frame,10.003756,I
25 | 601:frame,20.007633,I
26 | 901:frame,30.011556,I
27 | ```
28 |
29 | 可以看到关键帧分别位于第 1、301、601、901 帧,对应的时间点分别是第 0、10、20、30 秒,说明第一个关键帧是存在的,看来这个怀疑是错的。
30 |
31 | 接下来从 mp4 文件中分离出 h264 码流数据分析它的 nal 是否正常,分离 h264 命令如下:
32 |
33 | ```
34 | ffmpeg -i issue_video.mp4 -vcodec copy -vbsf h264_mp4toannexb -an issue_video.h264
35 | ```
36 |
37 | 分析 nal 我这里用的是 这里的 h264 分析器,输出的结果如下:
38 |
39 | 
40 |
41 | 从上面的截图中可以看到三个 nal,type 分别为 6、5、1,指的是 SEI、IDR、non-IDR,这里的 IDR 就是第一个关键帧。
42 |
43 | 一个正常视频的 nal log 如下,作为对比
44 |
45 | 
46 |
47 | 
48 |
49 | 可以看到前三个 nal type 分别是 7、8、5,分别指的是 SPS PPS IDR。sps/pps 一般包含了初始化 H264 解码器所需要的信息参数,包含编码所用的 profile,level,图像的宽高等信息,所以在将图像数据送入解码器之前必须先将 sps/pps 送入解码器。问题视频除第一个关键帧外的剩余三个关键帧之前都有 sps/pps,而这三个关键帧后的视频都能正常播放,更加证明了问题出在第一个关键帧之前没有 sps/pps。
50 |
51 | 分析到这一步只能说明问题视频 mp4 文件转成得到的 h264 文件有问题,但 mp4 文件中 sps/pps 是作为 meta 数据全局存在 avcC box 中的,如下图:
52 |
53 | 
54 |
55 | 所以应该是在 mp4 文件转成 h264 过程中出问题了。通过再次对比问题视频和正常视频的 nal log 发现除了没有 sps/pps 之外还有一处不相同,问题视频在最开始的地方多了一个 SEI nal。SEI 全称 Supplemental enhancement information 即补充增强信息,可以理解为补充信息,一般用于存放用户自定义数据,如果和视频解码没关系时可直接忽略。它在 H264 码流中的位置需要满足下面条件:
56 |
57 | > 如果存在SEI(补充增强信息) 单元的话,它必须在它所对应的基本编码图像的片段(slice)单元和数据划分片段(data partition)单元之前,并同时必须紧接在上一个基本编码图像的所有片段(slice)单元和数据划分片段(data partition)单元后边。假如SEI属于多个基本编码图像,其顺序仅以第一个基本编码图像为参照。[Reference](http://blog.sina.com.cn/s/blog_b849fc610101a50u.html)
58 |
59 | 怀疑问题视频的 SEI nal 不应该放在最开始,尝试在压缩后的 h264 码流中将 SEI nal 拿掉,视频可以正常播放了。所以问题出在苹果系播放器不能正常解析或者过滤掉位于文件开始的 SEI nal。
60 |
61 | #### 解决方案
62 |
63 | MediaCodec 编码后的数据中将 SEI nal 过滤掉。有的人可能会问直接拿掉这段数据会不会引起播放错误,nal 数据的第一个字节中: bit0 通常为 0,bit1-2 表示是否被别的 nal 数据引用,0 表示没被引用,非 0 表示被引用,值越大表示越重要,bit3-7 表示 nal type。而 SEI nal 的第一个字节的 bit1-2 一般都是0 表示没有被引用,所以直接过滤掉不会引起错误。过滤代码如下:
64 |
65 | ``` kotlin
66 | private fun ByteBuffer.filterSEINalu(info: MediaCodec.BufferInfo): ByteBuffer {
67 | var seiFound = false
68 | var start = -1
69 | var totalByteArray = ByteArray(0)
70 | for (i in position()..limit()) {
71 | getStartCodeLength(i).takeIf { it > 0 && limit() > it + 1 }?.also {
72 | if (start >= 0) {
73 | totalByteArray += getArray(start, i)
74 | }
75 | val firstByte = get(i + it)
76 | if ((firstByte and 0x60) == 0.toByte() && (firstByte and 0x1F) == 6.toByte()) {
77 | if (seiFound.not()) {
78 | seiFound = true
79 | totalByteArray += getArray(position(), i)
80 | }
81 | start = -1
82 | RgLog.i("Found sei nalu index $i")
83 | } else if (seiFound) {
84 | start = i
85 | }
86 | }
87 | if (i == limit() && start >= 0) {
88 | totalByteArray += getArray(start, i)
89 | }
90 | }
91 | return if (seiFound) {
92 | info.size -= remaining() - totalByteArray.size
93 | ByteBuffer.wrap(totalByteArray)
94 | } else this
95 | }
96 |
97 | private fun ByteBuffer.getStartCodeLength(index: Int): Int {
98 | if (index < position() || index >= limit()) {
99 | return 0
100 | }
101 | if (this.limit() > index + 2
102 | && (index == position() || this[index - 1] != 0.toByte())
103 | && this[index] == 0.toByte()
104 | && this[index + 1] == 0.toByte()
105 | && this[index + 2] == 1.toByte()) {
106 | // 000001
107 | return 3
108 | } else if (this.limit() > index + 3
109 | && this[index] == 0.toByte()
110 | && this[index + 1] == 0.toByte()
111 | && this[index + 2] == 0.toByte()
112 | && this[index + 3] == 1.toByte()) {
113 | // 00000001
114 | return 4
115 | }
116 | return 0
117 | }
118 |
119 | private fun ByteBuffer.getArray(start: Int, end: Int): ByteArray {
120 | val byteArray = ByteArray(end - start)
121 | val oldPos = position()
122 | position(start)
123 | get(byteArray, 0, byteArray.size)
124 | position(oldPos)
125 | return byteArray
126 | }
127 | ```
128 | 这段代码是用 kotlin 写的,主要是 ByteBuffer.filterSEINalu 这个方法,因为 nal 没有字段来表示数据的 length,而是通过 000001 或者 00000001 作为开始码来标记每个 nal,这里的 ByteBuffer.getStartCodeLength 就是用来判断是不是开始码。
129 |
130 | ```
131 | if ((firstByte and 0x60) == 0.toByte() && (firstByte and 0x1F) == 6.toByte())
132 | ```
133 |
134 | 核心代码是这行,用来判断这个 nal 是不是 SEI,并且 bit1-2 必须为0 确保没有被引用。
--------------------------------------------------------------------------------
/doc/issues/20181113_部分机型硬压视频和IOS播放器不兼容的问题/imgs/issue_video.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuesda/Gouzi/a5e6b64c583cef48ec5a23be30155216303410b1/doc/issues/20181113_部分机型硬压视频和IOS播放器不兼容的问题/imgs/issue_video.jpg
--------------------------------------------------------------------------------
/doc/issues/20181113_部分机型硬压视频和IOS播放器不兼容的问题/imgs/issue_video_nal_log.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuesda/Gouzi/a5e6b64c583cef48ec5a23be30155216303410b1/doc/issues/20181113_部分机型硬压视频和IOS播放器不兼容的问题/imgs/issue_video_nal_log.jpg
--------------------------------------------------------------------------------
/doc/issues/20181113_部分机型硬压视频和IOS播放器不兼容的问题/imgs/mp4_sps_pps_location.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuesda/Gouzi/a5e6b64c583cef48ec5a23be30155216303410b1/doc/issues/20181113_部分机型硬压视频和IOS播放器不兼容的问题/imgs/mp4_sps_pps_location.jpg
--------------------------------------------------------------------------------
/doc/issues/20181113_部分机型硬压视频和IOS播放器不兼容的问题/imgs/normal_video_nal_log_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuesda/Gouzi/a5e6b64c583cef48ec5a23be30155216303410b1/doc/issues/20181113_部分机型硬压视频和IOS播放器不兼容的问题/imgs/normal_video_nal_log_1.jpg
--------------------------------------------------------------------------------
/doc/issues/20181113_部分机型硬压视频和IOS播放器不兼容的问题/imgs/normal_video_nal_log_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tuesda/Gouzi/a5e6b64c583cef48ec5a23be30155216303410b1/doc/issues/20181113_部分机型硬压视频和IOS播放器不兼容的问题/imgs/normal_video_nal_log_2.jpg
--------------------------------------------------------------------------------
/doc/plan.md:
--------------------------------------------------------------------------------
1 | * 目的: 一个基于FFmpeg视频转码 App 1.0 版本,名字叫【狗子】,英文名【Gouzi】。
2 | * 时间: 2018.11.8 ~ 2019.2.8 / 3 months / 12 weeks
3 | * 节奏: 每周一个小版本 version 0.1 0.2 0.3 ... 0.11 1.0,每周四发版本。
4 | * ver 0.4: 基本款:能用
5 | * ver 0.1 选视频
6 | * ver 0.2 整个集成 FFmpeg
7 | * ver 0.3 转码
8 | * ver 0.4 视频输出/Log展示
9 | * ver 0.8: FFmpeg 瘦身
10 | * ver 0.5 本地编译 FFmpeg 去掉不必要模块
11 | * ver 0.6 尝试直接调用 FFmpeg 库代码并适配 Android 端代码
12 | * ver 0.7 继续精简 FFmpeg 代码
13 | * ver 0.8 继续精简 Ffmpeg 代码
14 | * ver 1.0: 终极款:轻量
15 | * ver 0.9 - ver 1.0 继续精简 FFmpeg 代码
16 |
17 |
18 | 这个项目的难点不在于 Android 端,而在于 FFmpeg 的适配。由于 FFmpeg 没有 Android 版本,所以必须通过 JNI 方式配合 FFmpeg 编译的 so 包去配合使用。问题在于 FFmpeg 编译的 so 包体积非常大,全量编译包有将近 20M,这对于目前安装包只有 13M 的即刻来说是不可接受的。所以这个项目的大部分精力是用来精简 FFmpeg,计划从小版本 0.5 开始就做这部分。
19 |
20 | 精简的方式主要是自定义编译 FFmpeg 和代码层面对 FFmpeg 进行剪裁。第一部分相对简单,网上也有很多教程。难的是第二种方式,因为这里需要阅读 FFmpeg 源码,而 FFmpeg 几乎都是 c/c++ 写的,我上一次看 c 代码还是在大学时候。但第一种的精简大小很有限,必须尝试第二种。写这个开发计划的目的就是为了督促我知难而上,这部分代码也会放在我 github 的公开库上面,这么做的目的也是为了防止我半途而废,希望最后不要打脸🙏🙏🙏。
--------------------------------------------------------------------------------