├── AndroidH264StreamDemo ├── ic_launcher-web.png ├── libs │ └── android-support-v4.jar ├── res │ ├── drawable-hdpi │ │ └── ic_launcher.png │ ├── drawable-mdpi │ │ └── ic_launcher.png │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ ├── drawable-xxhdpi │ │ └── ic_launcher.png │ ├── values │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ ├── values-v11 │ │ └── styles.xml │ ├── menu │ │ └── main.xml │ ├── values-w820dp │ │ └── dimens.xml │ ├── values-v14 │ │ └── styles.xml │ └── layout │ │ ├── stream_dlg_view.xml │ │ └── activity_main.xml ├── .settings │ └── org.eclipse.jdt.core.prefs ├── .classpath ├── project.properties ├── proguard-project.txt ├── .project ├── AndroidManifest.xml └── src │ └── com │ └── jemi │ └── androidh264streamdemo │ ├── AvcEncoder.java │ └── MainActivity.java ├── .gitignore └── README.md /AndroidH264StreamDemo/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytestar/android-h264-stream-demo/HEAD/AndroidH264StreamDemo/ic_launcher-web.png -------------------------------------------------------------------------------- /AndroidH264StreamDemo/libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytestar/android-h264-stream-demo/HEAD/AndroidH264StreamDemo/libs/android-support-v4.jar -------------------------------------------------------------------------------- /AndroidH264StreamDemo/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytestar/android-h264-stream-demo/HEAD/AndroidH264StreamDemo/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /AndroidH264StreamDemo/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytestar/android-h264-stream-demo/HEAD/AndroidH264StreamDemo/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /AndroidH264StreamDemo/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytestar/android-h264-stream-demo/HEAD/AndroidH264StreamDemo/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /AndroidH264StreamDemo/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytestar/android-h264-stream-demo/HEAD/AndroidH264StreamDemo/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /AndroidH264StreamDemo/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 3 | org.eclipse.jdt.core.compiler.compliance=1.6 4 | org.eclipse.jdt.core.compiler.source=1.6 5 | -------------------------------------------------------------------------------- /AndroidH264StreamDemo/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16dp 5 | 16dp 6 | 7 | 8 | -------------------------------------------------------------------------------- /AndroidH264StreamDemo/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AndroidH264StreamDemo 5 | Hello world! 6 | Settings 7 | 8 | 9 | -------------------------------------------------------------------------------- /AndroidH264StreamDemo/res/values-v11/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /AndroidH264StreamDemo/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /AndroidH264StreamDemo/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 64dp 9 | 10 | 11 | -------------------------------------------------------------------------------- /AndroidH264StreamDemo/res/values-v14/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /AndroidH264StreamDemo/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /AndroidH264StreamDemo/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-21 15 | -------------------------------------------------------------------------------- /AndroidH264StreamDemo/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /AndroidH264StreamDemo/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /AndroidH264StreamDemo/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | AndroidH264StreamDemo 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /AndroidH264StreamDemo/res/layout/stream_dlg_view.xml: -------------------------------------------------------------------------------- 1 | 10 | 16 | 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear on external disk 35 | .Spotlight-V100 36 | .Trashes 37 | 38 | # Directories potentially created on remote AFP share 39 | .AppleDB 40 | .AppleDesktop 41 | Network Trash Folder 42 | Temporary Items 43 | .apdisk 44 | 45 | # generated files 46 | bin/ 47 | gen/ 48 | .metadata/ 49 | RemoteSystemsTempFiles/ 50 | .gitattributes 51 | 52 | # Built application files 53 | *.apk 54 | *.ap_ 55 | 56 | # Files for the Dalvik VM 57 | *.dex 58 | 59 | # Java class files 60 | *.class 61 | 62 | # Gradle files 63 | .gradle/ 64 | build/ 65 | 66 | # Local configuration file (sdk path, etc) 67 | local.properties 68 | 69 | # Proguard folder generated by Eclipse 70 | proguard/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # android-h264-stream-demo 2 | 3 | ## What it does 4 | This is an example project to show how to streaming from android camera to 5 | VLC or gstreamer. 6 | 7 | This demo project use MediaCodec API to encode H.264 data 8 | and simply wrap with UDP packet then send these packets to VLC or gstreamer. 9 | 10 | ## How does it work 11 | The working flow as below 12 | ``` 13 | camera preview data(YV12) -> YUV420sp -> MediaCodec -> H.264 data -> UDP 14 | ``` 15 | 16 | ## Media Server 17 | 18 | By using VLC and gstreamer, we can ensure that the H.264 video streaming is working fine. 19 | You can use the following command to start a media server. 20 | 21 | ### VLC 22 | ``` 23 | vlc -vvv udp://@: 24 | ``` 25 | 26 | ### gstreamer 27 | ``` 28 | gst-launch udpsrc port= ! video/x-h264,width=,height=,framerate=/1 ! ffdec_h264 ! autovideosink 29 | ``` 30 | 31 | ## Requirement 32 | - Minimal API requirement: 16 33 | 34 | ## License 35 | ``` 36 | Copyright (C) 2015 Ping-Chun Tseng 37 | Licensed under Apache 2.0 38 | ``` 39 | 40 | ## Notes 41 | - In some network environment, UDP packet may be cut by MTU limitation 42 | 43 | 44 | ## Future works 45 | - Support H.264 over RTP (RFC3984) 46 | - Support NV21 and YUV420p image format 47 | 48 | -------------------------------------------------------------------------------- /AndroidH264StreamDemo/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 13 | 14 | 15 |