├── app ├── .gitignore ├── libs │ ├── armeabi-v7a │ │ └── libmp4v2.so │ └── include │ │ ├── com_seuic_jni_Mp4v2Helper.h │ │ └── mp4v2 │ │ ├── project.h │ │ ├── project.h.in │ │ ├── platform.h │ │ ├── mp4v2.h │ │ ├── isma.h │ │ ├── file_prop.h │ │ ├── streaming.h │ │ ├── chapter.h │ │ ├── itmf_generic.h │ │ ├── track_prop.h │ │ ├── itmf_tags.h │ │ ├── track.h │ │ ├── file.h │ │ ├── general.h │ │ └── sample.h ├── src │ ├── main │ │ ├── res │ │ │ ├── drawable-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── styles.xml │ │ │ │ ├── dimens.xml │ │ │ │ └── colors.xml │ │ │ └── layout │ │ │ │ └── main_layout.xml │ │ ├── java │ │ │ └── com │ │ │ │ ├── seuic │ │ │ │ └── jni │ │ │ │ │ └── Mp4v2Helper.java │ │ │ │ └── me │ │ │ │ └── archko │ │ │ │ └── mp4 │ │ │ │ ├── TestMp4Activity.java │ │ │ │ └── SLApolloUtils.java │ │ ├── cpp │ │ │ ├── mp4record.h │ │ │ ├── Mp4v2Helper.c │ │ │ └── mp4record.c │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── chezi008 │ │ │ └── mp4v2demo │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── chezi008 │ │ └── mp4v2demo │ │ └── ExampleInstrumentedTest.java ├── CMakeLists.txt ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── mtv.h264 ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── README.md ├── local.properties └── gradle.properties /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /mtv.h264: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chezi008/Mp4v2Demo/HEAD/mtv.h264 -------------------------------------------------------------------------------- /app/libs/armeabi-v7a/libmp4v2.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chezi008/Mp4v2Demo/HEAD/app/libs/armeabi-v7a/libmp4v2.so -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chezi008/Mp4v2Demo/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chezi008/Mp4v2Demo/HEAD/app/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chezi008/Mp4v2Demo/HEAD/app/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chezi008/Mp4v2Demo/HEAD/app/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chezi008/Mp4v2Demo/HEAD/app/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Mp4v2 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Mp4v2Demo 2 | Android使用Mp4v2用h264流和acc流合成mp4 3 | 使用mp4v2源码在linux系统下生成对应的so包,AndroidStudio用最新的cmake利用mp4v2库生成mp4文件,用h264流生成mp4文件同一个套路,android进行h264的解码,将生成的每一帧喂入mp4b2库。(目前只做了视频写入,没有进行音频写入) 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 21 10:39:42 CST 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/test/java/com/chezi008/mp4v2demo/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.chezi008.mp4v2demo; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /local.properties: -------------------------------------------------------------------------------- 1 | ## This file is automatically generated by Android Studio. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must *NOT* be checked into Version Control Systems, 5 | # as it contains information specific to your local configuration. 6 | # 7 | # Location of the SDK. This is only used by Gradle. 8 | # For customization when using a Version Control System, please read the 9 | # header note. 10 | #Sat Apr 15 16:52:37 CST 2017 11 | ndk.dir=E\:\\AndroidSDK\\ndk-bundle 12 | sdk.dir=E\:\\AndroidSDK 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/seuic/jni/Mp4v2Helper.java: -------------------------------------------------------------------------------- 1 | package com.seuic.jni; 2 | 3 | import android.util.Log; 4 | 5 | /** 6 | * 描述: 7 | * 作者:chezi008 on 2017/4/12 16:14 8 | * 邮箱:chezi008@163.com 9 | */ 10 | 11 | public class Mp4v2Helper { 12 | 13 | public static native int initMp4Encoder(String outputFilePath,int width,int height); 14 | 15 | public static native int mp4VEncode(byte[] data, int size); 16 | 17 | public static native int mp4AEncode(byte[] data, int size); 18 | 19 | public static native void closeMp4Encoder(); 20 | 21 | static { 22 | Log.i("NativeClass", "before load library"); 23 | System.loadLibrary("Mp4v2Helper");//注意这里为自己指定的.so文件,无lib前缀,亦无后缀 24 | Log.i("NativeClass", "after load library"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /app/src/main/cpp/mp4record.h: -------------------------------------------------------------------------------- 1 | // 2 | // mp4record.h 3 | // 4 | 5 | #ifndef __RTSP_Player__mp4record__ 6 | #define __RTSP_Player__mp4record__ 7 | 8 | #import "mp4v2/mp4v2.h" 9 | 10 | #define _NALU_SPS_ 0 11 | #define _NALU_PPS_ 1 12 | #define _NALU_I_ 2 13 | #define _NALU_P_ 3 14 | 15 | typedef struct MP4V2_CONTEXT{ 16 | int m_vWidth,m_vHeight,m_vFrateR,m_vTimeScale; 17 | MP4FileHandle m_mp4FHandle; 18 | MP4TrackId m_vTrackId,m_aTrackId; 19 | double m_vFrameDur; 20 | } MP4V2_CONTEXT; 21 | 22 | MP4V2_CONTEXT * initMp4Encoder(const char * filename,int width,int height); 23 | int mp4VEncode(MP4V2_CONTEXT * recordCtx, uint8_t * data, int len); 24 | int mp4AEncode(MP4V2_CONTEXT * recordCtx, uint8_t * data, int len); 25 | void closeMp4Encoder(MP4V2_CONTEXT * recordCtx); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | #CMake版本信息 3 | cmake_minimum_required(VERSION 3.4.1) 4 | 5 | set(distribution_DIR ${CMAKE_SOURCE_DIR}/../../../../libs) 6 | #支持-std=gnu++11 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") 8 | 9 | 10 | add_library( mp4v2 11 | SHARED 12 | IMPORTED ) 13 | set_target_properties( mp4v2 14 | PROPERTIES IMPORTED_LOCATION 15 | ../../../../libs/armeabi-v7a/libmp4v2.so ) 16 | include_directories(libs/include) 17 | 18 | 19 | 20 | add_library(Mp4v2Helper SHARED 21 | src/main/cpp/Mp4v2Helper.c 22 | ) 23 | 24 | 25 | find_library( # Sets the name of the path variable. 26 | log-lib 27 | 28 | # Specifies the name of the NDK library that 29 | # you want CMake to locate. 30 | log ) 31 | 32 | target_link_libraries( Mp4v2Helper mp4v2 ${log-lib} ) 33 | 34 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/chezi008/mp4v2demo/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.chezi008.mp4v2demo; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.chezi008.mp4v2demo", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/res/layout/main_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 14 |