ffmpeg综合应用示例(三)——安卓手机摄像头编码
本文的示例将实现:读取安卓手机摄像头数据并使用H.264编码格式实时编码保存为flv文件。示例包含了
1、编译适用于安卓平台的ffmpeg库
2、在java中通过JNI使用ffmpeg
3、读取安卓摄像头数据并在后台线程中使用ffmpeg进行编码的基本流程
具有较强的综合性。
编译适用于安卓平台的ffmpeg库
- SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
- LIB_INSTALL_EXTRA_CMD='$$(RANLIB)"$(LIBDIR)/$(LIBNAME)"'
- SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
- SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR)$(SLIBNAME)'
修改为
- SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
- LIB_INSTALL_EXTRA_CMD='$$(RANLIB)"$(LIBDIR)/$(LIBNAME)"'
- SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
- SLIB_INSTALL_LINKS='$(SLIBNAME)'
之后进行常规的configure配置,make, make install步骤即可,下面给出一个常规的脚本示例
- make clean
- export NDK=xxxx/android-ndk-r10e
- export PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt
- export PLATFORM=$NDK/platforms/android-8/arch-arm
- export PREFIX=../android_ffmpeglib
- ./configure --target-os=linux --prefix=$PREFIX \
- --enable-cross-compile \
- --enable-runtime-cpudetect \
- --disable-asm \
- --arch=arm \
- --cc=$PREBUILT/windows/bin/arm-linux-androideabi-gcc \
- --cross-prefix=$PREBUILT/windows/bin/arm-linux-androideabi- \
- --disable-stripping \
- --nm=$PREBUILT/windows/bin/arm-linux-androideabi-nm \
- --sysroot=$PLATFORM \
- --enable-gpl --enable-shared --disable-static --enable-small \
- --disable-ffprobe --disable-ffplay --disable-ffmpeg --disable-ffserver --disable-debug \
- --extra-cflags="-fPIC -DANDROID -D__thumb__ -mthumb -Wfatal-errors -Wno-deprecated -mfloat-abi=softfp -marm -march=armv7-a"
- make
- make install
成功编译后,可以看到如下类库
在java中通过JNI使用ffmpeg
该协议用来沟通Java代码和外部的本地C/C++代码, 通过该协议 Java代码可以调用外部的本地代码, 外部的C/C++
代码可以调用Java代码。简单来说,就是将一个C语言的方法映射到Java的某个方法上;
-- native : Java语言中修饰本地方法的修饰符, 被该修饰符修饰的方法没有方法体;
-- Native方法 : 在Java语言中被native关键字修饰的方法是Native方法;
-- JNI层 : Java声明Native方法的部分;
-- JNI函数 : JNIEnv提供的函数, 这些函数在jni.h中进行定义;
-- JNI方法 : Native方法对应的JNI层实现的 C/C++方法, 即在jni目录中实现的那些C语言代码;
具体流程可以参照ndk的sample目录下的hellojni项目,总结起来有如下几个步骤
- jstring
- Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env,
- jobject thiz )
jstring 是 Java语言中的String类型, 方法名格式为 : Java_完整包名类名_方法名();
-- JNIEnv参数 : 代表的是Java环境, 通过这个环境可以调用Java里面的方法;
-- jobject参数 : 调用C语言方法的对象, thiz对象表示当前的对象, 即调用JNI方法所在的类;
- LOCAL_PATH := $(call my-dir)
- include $(CLEAR_VARS)
- LOCAL_MODULE := hello-jni
- LOCAL_SRC_FILES := hello-jni.c
- include $(BUILD_SHARED_LIBRARY)
-- LOCAL_PATH : 代表mk文件所在的目录;
-- include $(CLEAR_VARS) : 编译工具函数, 通过该函数可以进行一些初始化操作;
-- LOCAL_MODULE : 编译后的 .so 后缀文件叫什么名字;
-- LOCAL_SRC_FILES: 指定编译的源文件名称;
-- include $(BUILD_SHARED_LIBRARY) : 告诉编译器需要生成动态库;
- static {
- System.loadLibrary("hello-jni");
- }
参照上面的基本流程,具体到利用ffmpeg实现安卓摄像头数据的编码
- //JNI
- //初始化,读取待编码数据的宽和高
- public native int initial(int width,int height);
- //读取yuv数据进行编码
- public native int encode(byte[] yuvimage);
- //清空缓存的帧
- public native int flush();
- //清理
- public native int close();
第二步:对应的c文件内容如下,基本就是一个将yuv数据编码为H.264的flv文件的流程,唯一需要注意的就是安卓摄像头拍摄数据的像素格式为NV21,需要转换为YUV420P才能进行编码
- /**
- * 基于FFmpeg安卓摄像头编码
- * FFmpeg Android Camera Encoder
- *
- * 张晖 Hui Zhang
- * zhanghuicuc@gmail.com
- * 中国传媒大学/数字电视技术
- * Communication University of China / Digital TV Technology
- *
- *
- */
- #include <stdio.h>
- #include <time.h>
- #include "libavcodec/avcodec.h"
- #include "libavformat/avformat.h"
- #include "libswscale/swscale.h"
- #include "libavutil/log.h"
- #ifdef ANDROID
- #include <jni.h>
- #include <android/log.h>
- #define LOGE(format, ...) __android_log_print(ANDROID_LOG_ERROR, "(>_<)", format, ##__VA_ARGS__)
- #define LOGI(format, ...) __android_log_print(ANDROID_LOG_INFO, "(=_=)", format, ##__VA_ARGS__)
- #else
- #define LOGE(format, ...) printf("(>_<) " format "\n", ##__VA_ARGS__)
- #define LOGI(format, ...) printf("(^_^) " format "\n", ##__VA_ARGS__)
- #endif
- AVFormatContext *ofmt_ctx;
- AVStream* video_st;
- AVCodecContext* pCodecCtx;
- AVCodec* pCodec;
- AVPacket enc_pkt;
- AVFrame *pFrameYUV;
- int framecnt = 0;
- int yuv_width;
- int yuv_height;
- int y_length;
- int uv_length;
- int64_t start_time;
- //Output FFmpeg's av_log()
- void custom_log(void *ptr, int level, const char* fmt, va_list vl){
- FILE *fp=fopen("/storage/emulated/0/av_log.txt","a+");
- if(fp){
- vfprintf(fp,fmt,vl);
- fflush(fp);
- fclose(fp);
- }
- }
- JNIEXPORT jint JNICALL Java_com_zhanghui_test_MainActivity_initial
- (JNIEnv *env, jobject obj,jint width,jint height)
- {
- const char* out_path = "/sdcard/zhanghui/testffmpeg.flv";
- yuv_width=width;
- yuv_height=height;
- y_length=width*height;
- uv_length=width*height/4;
- //FFmpeg av_log() callback
- av_log_set_callback(custom_log);
- av_register_all();
- //output initialize
- avformat_alloc_output_context2(&ofmt_ctx, NULL, "flv", out_path);
- //output encoder initialize
- pCodec = avcodec_find_encoder(AV_CODEC_ID_H264);
- if (!pCodec){
- LOGE("Can not find encoder!\n");
- return -1;
- }
- pCodecCtx = avcodec_alloc_context3(pCodec);
- pCodecCtx->pix_fmt = PIX_FMT_YUV420P;
- pCodecCtx->width = width;
- pCodecCtx->height = height;
- pCodecCtx->time_base.num = 1;
- pCodecCtx->time_base.den = 30;
- pCodecCtx->bit_rate = 800000;
- pCodecCtx->gop_size = 300;
- /* Some formats want stream headers to be separate. */
- if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER)
- pCodecCtx->flags |= CODEC_FLAG_GLOBAL_HEADER;
- //H264 codec param
- //pCodecCtx->me_range = 16;
- //pCodecCtx->max_qdiff = 4;
- //pCodecCtx->qcompress = 0.6;
- pCodecCtx->qmin = 10;
- pCodecCtx->qmax = 51;
- //Optional Param
- pCodecCtx->max_b_frames = 3;
- // Set H264 preset and tune
- AVDictionary *param = 0;
- av_dict_set(¶m, "preset", "ultrafast", 0);
- av_dict_set(¶m, "tune", "zerolatency", 0);
- if (avcodec_open2(pCodecCtx, pCodec, ¶m) < 0){
- LOGE("Failed to open encoder!\n");
- return -1;
- }
- //Add a new stream to output,should be called by the user before avformat_write_header() for muxing
- video_st = avformat_new_stream(ofmt_ctx, pCodec);
- if (video_st == NULL){
- return -1;
- }
- video_st->time_base.num = 1;
- video_st->time_base.den = 30;
- video_st->codec = pCodecCtx;
- //Open output URL,set before avformat_write_header() for muxing
- if (avio_open(&ofmt_ctx->pb, out_path, AVIO_FLAG_READ_WRITE) < 0){
- LOGE("Failed to open output file!\n");
- return -1;
- }
- //Write File Header
- avformat_write_header(ofmt_ctx, NULL);
- start_time = av_gettime();
- return 0;
- }
- JNIEXPORT jint JNICALL Java_com_zhanghui_test_MainActivity_encode
- (JNIEnv *env, jobject obj, jbyteArray yuv)
- {
- int ret;
- int enc_got_frame=0;
- int i=0;
- pFrameYUV = avcodec_alloc_frame();
- uint8_t *out_buffer = (uint8_t *)av_malloc(avpicture_get_size(PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height));
- avpicture_fill((AVPicture *)pFrameYUV, out_buffer, PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height);
- //安卓摄像头数据为NV21格式,此处将其转换为YUV420P格式
- jbyte* in= (jbyte*)(*env)->GetByteArrayElements(env,yuv,0);
- memcpy(pFrameYUV->data[0],in,y_length);
- for(i=0;i<uv_length;i++)
- {
- *(pFrameYUV->data[2]+i)=*(in+y_length+i*2);
- *(pFrameYUV->data[1]+i)=*(in+y_length+i*2+1);
- }
- pFrameYUV->format = AV_PIX_FMT_YUV420P;
- pFrameYUV->width = yuv_width;
- pFrameYUV->height = yuv_height;
- enc_pkt.data = NULL;
- enc_pkt.size = 0;
- av_init_packet(&enc_pkt);
- ret = avcodec_encode_video2(pCodecCtx, &enc_pkt, pFrameYUV, &enc_got_frame);
- av_frame_free(&pFrameYUV);
- if (enc_got_frame == 1){
- LOGI("Succeed to encode frame: %5d\tsize:%5d\n", framecnt, enc_pkt.size);
- framecnt++;
- enc_pkt.stream_index = video_st->index;
- //Write PTS
- AVRational time_base = ofmt_ctx->streams[0]->time_base;//{ 1, 1000 };
- AVRational r_framerate1 = {60, 2 };//{ 50, 2 };
- AVRational time_base_q = { 1, AV_TIME_BASE };
- //Duration between 2 frames (us)
- int64_t calc_duration = (double)(AV_TIME_BASE)*(1 / av_q2d(r_framerate1)); //内部时间戳
- //Parameters
- //enc_pkt.pts = (double)(framecnt*calc_duration)*(double)(av_q2d(time_base_q)) / (double)(av_q2d(time_base));
- enc_pkt.pts = av_rescale_q(framecnt*calc_duration, time_base_q, time_base);
- enc_pkt.dts = enc_pkt.pts;
- enc_pkt.duration = av_rescale_q(calc_duration, time_base_q, time_base); //(double)(calc_duration)*(double)(av_q2d(time_base_q)) / (double)(av_q2d(time_base));
- enc_pkt.pos = -1;
- //Delay
- int64_t pts_time = av_rescale_q(enc_pkt.dts, time_base, time_base_q);
- int64_t now_time = av_gettime() - start_time;
- if (pts_time > now_time)
- av_usleep(pts_time - now_time);
- ret = av_interleaved_write_frame(ofmt_ctx, &enc_pkt);
- av_free_packet(&enc_pkt);
- }
- return 0;
- }
- JNIEXPORT jint JNICALL Java_com_zhanghui_test_MainActivity_flush
- (JNIEnv *env, jobject obj)
- {
- int ret;
- int got_frame;
- AVPacket enc_pkt;
- if (!(ofmt_ctx->streams[0]->codec->codec->capabilities &
- CODEC_CAP_DELAY))
- return 0;
- while (1) {
- enc_pkt.data = NULL;
- enc_pkt.size = 0;
- av_init_packet(&enc_pkt);
- ret = avcodec_encode_video2(ofmt_ctx->streams[0]->codec, &enc_pkt,
- NULL, &got_frame);
- if (ret < 0)
- break;
- if (!got_frame){
- ret = 0;
- break;
- }
- LOGI("Flush Encoder: Succeed to encode 1 frame!\tsize:%5d\n", enc_pkt.size);
- //Write PTS
- AVRational time_base = ofmt_ctx->streams[0]->time_base;//{ 1, 1000 };
- AVRational r_framerate1 = { 60, 2 };
- AVRational time_base_q = { 1, AV_TIME_BASE };
- //Duration between 2 frames (us)
- int64_t calc_duration = (double)(AV_TIME_BASE)*(1 / av_q2d(r_framerate1)); //内部时间戳
- //Parameters
- enc_pkt.pts = av_rescale_q(framecnt*calc_duration, time_base_q, time_base);
- enc_pkt.dts = enc_pkt.pts;
- enc_pkt.duration = av_rescale_q(calc_duration, time_base_q, time_base);
- //转换PTS/DTS(Convert PTS/DTS)
- enc_pkt.pos = -1;
- framecnt++;
- ofmt_ctx->duration = enc_pkt.duration * framecnt;
- /* mux encoded frame */
- ret = av_interleaved_write_frame(ofmt_ctx, &enc_pkt);
- if (ret < 0)
- break;
- }
- //Write file trailer
- av_write_trailer(ofmt_ctx);
- return 0;
- }
- JNIEXPORT jint JNICALL Java_com_zhanghui_test_MainActivity_close
- (JNIEnv *env, jobject obj)
- {
- if (video_st)
- avcodec_close(video_st->codec);
- avio_close(ofmt_ctx->pb);
- avformat_free_context(ofmt_ctx);
- return 0;
- }
第三步:编写Android.mk如下,这里要在jni目录下放入ffmpeg的头文件,就跟平时的调用方法一样
- LOCAL_PATH := $(call my-dir)
- # FFmpeg library
- include $(CLEAR_VARS)
- LOCAL_MODULE := avcodec
- LOCAL_SRC_FILES := libavcodec-56.so
- include $(PREBUILT_SHARED_LIBRARY)
- include $(CLEAR_VARS)
- LOCAL_MODULE := avdevice
- LOCAL_SRC_FILES := libavdevice-56.so
- include $(PREBUILT_SHARED_LIBRARY)
- include $(CLEAR_VARS)
- LOCAL_MODULE := avfilter
- LOCAL_SRC_FILES := libavfilter-5.so
- include $(PREBUILT_SHARED_LIBRARY)
- include $(CLEAR_VARS)
- LOCAL_MODULE := avformat
- LOCAL_SRC_FILES := libavformat-56.so
- include $(PREBUILT_SHARED_LIBRARY)
- include $(CLEAR_VARS)
- LOCAL_MODULE := avutil
- LOCAL_SRC_FILES := libavutil-54.so
- include $(PREBUILT_SHARED_LIBRARY)
- include $(CLEAR_VARS)
- LOCAL_MODULE := postproc
- LOCAL_SRC_FILES := libpostproc-53.so
- include $(PREBUILT_SHARED_LIBRARY)
- include $(CLEAR_VARS)
- LOCAL_MODULE := swresample
- LOCAL_SRC_FILES := libswresample-1.so
- include $(PREBUILT_SHARED_LIBRARY)
- include $(CLEAR_VARS)
- LOCAL_MODULE := swscale
- LOCAL_SRC_FILES := libswscale-3.so
- include $(PREBUILT_SHARED_LIBRARY)
- # Program
- include $(CLEAR_VARS)
- LOCAL_MODULE := encode
- LOCAL_SRC_FILES :=encode.c
- LOCAL_C_INCLUDES += $(LOCAL_PATH)/include
- LOCAL_LDLIBS := -llog -lz
- LOCAL_SHARED_LIBRARIES := avcodec avdevice avfilter avformat avutil postproc swresample swscale
- include $(BUILD_SHARED_LIBRARY)
第四步:使用cygwin切换到当前项目的jni目录下,输入ndk-build进行编译即可,如下
- static{
- System.loadLibrary("avutil-54");
- System.loadLibrary("swresample-1");
- System.loadLibrary("avcodec-56");
- System.loadLibrary("avformat-56");
- System.loadLibrary("swscale-3");
- System.loadLibrary("postproc-53");
- System.loadLibrary("avfilter-5");
- System.loadLibrary("avdevice-56");
- System.loadLibrary("encode");
- }
至此,就可以在java中调用我们声明的四个方法了。
java部分获取摄像头数据并编码的流程
- package com.zhanghui.test;
- import java.io.IOException;
- import android.annotation.TargetApi;
- import android.app.Activity;
- import android.content.pm.PackageManager;
- import android.hardware.Camera;
- import android.os.AsyncTask;
- import android.os.Build;
- import android.os.Bundle;
- import android.util.Log;
- import android.view.Menu;
- import android.view.MenuItem;
- import android.view.SurfaceHolder;
- import android.view.SurfaceView;
- import android.view.View;
- import android.widget.Button;
- import android.widget.Toast;
- @SuppressWarnings("deprecation")
- public class MainActivity extends Activity {
- private static final String TAG= "MainActivity";
- private Button mTakeButton;
- private Camera mCamera;
- private SurfaceView mSurfaceView;
- private SurfaceHolder mSurfaceHolder;
- private boolean isRecording = false;
- private class StreamTask extends AsyncTask<Void, Void, Void>{
- private byte[] mData;
- //构造函数
- StreamTask(byte[] data){
- this.mData = data;
- }
- @Override
- protected Void doInBackground(Void... params) {
- // TODO Auto-generated method stub
- if(mData!=null){
- Log.i(TAG, "fps: " + mCamera.getParameters().getPreviewFrameRate());
- encode(mData);
- }
- return null;
- }
- }
- private StreamTask mStreamTask;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- final Camera.PreviewCallback mPreviewCallbacx=new Camera.PreviewCallback() {
- @Override
- public void onPreviewFrame(byte[] arg0, Camera arg1) {
- // TODO Auto-generated method stub
- if(null != mStreamTask){
- switch(mStreamTask.getStatus()){
- case RUNNING:
- return;
- case PENDING:
- mStreamTask.cancel(false);
- break;
- }
- }
- mStreamTask = new StreamTask(arg0);
- mStreamTask.execute((Void)null);
- }
- };
- mTakeButton=(Button)findViewById(R.id.take_button);
- PackageManager pm=this.getPackageManager();
- boolean hasCamera=pm.hasSystemFeature(PackageManager.FEATURE_CAMERA) ||
- pm.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT) ||
- Build.VERSION.SDK_INT<Build.VERSION_CODES.GINGERBREAD;
- if(!hasCamera)
- mTakeButton.setEnabled(false);
- mTakeButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View arg0) {
- // TODO Auto-generated method stub
- if(mCamera!=null)
- {
- if (isRecording) {
- mTakeButton.setText("Start");
- mCamera.setPreviewCallback(null);
- Toast.makeText(MainActivity.this, "encode done", Toast.LENGTH_SHORT).show();
- isRecording = false;
- }else {
- mTakeButton.setText("Stop");
- initial(mCamera.getParameters().getPreviewSize().width,mCamera.getParameters().getPreviewSize().height);
- mCamera.setPreviewCallback(mPreviewCallbacx);
- isRecording = true;
- }
- }
- }
- });
- mSurfaceView=(SurfaceView)findViewById(R.id.surfaceView1);
- SurfaceHolder holder=mSurfaceView.getHolder();
- holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
- holder.addCallback(new SurfaceHolder.Callback() {
- @Override
- public void surfaceDestroyed(SurfaceHolder arg0) {
- // TODO Auto-generated method stub
- if(mCamera!=null)
- {
- mCamera.stopPreview();
- mSurfaceView = null;
- mSurfaceHolder = null;
- }
- }
- @Override
- public void surfaceCreated(SurfaceHolder arg0) {
- // TODO Auto-generated method stub
- try{
- if(mCamera!=null){
- mCamera.setPreviewDisplay(arg0);
- mSurfaceHolder=arg0;
- }
- }catch(IOException exception){
- Log.e(TAG, "Error setting up preview display", exception);
- }
- }
- @Override
- public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
- // TODO Auto-generated method stub
- if(mCamera==null) return;
- Camera.Parameters parameters=mCamera.getParameters();
- parameters.setPreviewSize(640,480);
- parameters.setPictureSize(640,480);
- mCamera.setParameters(parameters);
- try{
- mCamera.startPreview();
- mSurfaceHolder=arg0;
- }catch(Exception e){
- Log.e(TAG, "could not start preview", e);
- mCamera.release();
- mCamera=null;
- }
- }
- });
- }
- @TargetApi(9)
- @Override
- protected void onResume(){
- super.onResume();
- if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.GINGERBREAD){
- mCamera=Camera.open(0);
- }else
- {
- mCamera=Camera.open();
- }
- }
- @Override
- protected void onPause(){
- super.onPause();
- flush();
- close();
- if(mCamera!=null){
- mCamera.release();
- mCamera=null;
- }
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.main, menu);
- return true;
- }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
- int id = item.getItemId();
- if (id == R.id.action_settings) {
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
- //JNI
- public native int initial(int width,int height);
- public native int encode(byte[] yuvimage);
- public native int flush();
- public native int close();
- static{
- System.loadLibrary("avutil-54");
- System.loadLibrary("swresample-1");
- System.loadLibrary("avcodec-56");
- System.loadLibrary("avformat-56");
- System.loadLibrary("swscale-3");
- System.loadLibrary("postproc-53");
- System.loadLibrary("avfilter-5");
- System.loadLibrary("avdevice-56");
- System.loadLibrary("encode");
- }
- }
至此,就完成了全部功能的开发,程序截图如下
转自: http://blog.csdn.net/nonmarking/article/details/48601317
ffmpeg综合应用示例(三)——安卓手机摄像头编码的更多相关文章
- ffmpeg综合应用示例(一)——摄像头直播
本文的示例将实现:读取PC摄像头视频数据并以RTMP协议发送为直播流.示例包含了 1.ffmpeg的libavdevice的使用 2.视频解码.编码.推流的基本流程 具有较强的综合性. 要使用liba ...
- input type = file 在部分安卓手机上无法调起摄像头和相册
移动端H5web 用input type = file 在部分安卓手机上无法调起摄像头拍照,有的也无法访问相册而是直接访问了文档,解决办法是: 加上 accept = "image/*&qu ...
- EasyRTMP Android安卓手机直播推流摄像头偏暗的问题解决
在我们测试EasyRTMP Android安卓手机推流的过程中发现有些设备预览时,明显偏暗!在稍微暗点的环境中几乎很难看清东西-额,这是怎么回事呢?又是安卓设备的兼容性问题,头疼! !!!好吧,停止抱 ...
- WebRTC VideoEngine综合应用示例(一)——视频通话的基本流程(转)
本系列目前共三篇文章,后续还会更新 WebRTC VideoEngine综合应用示例(一)——视频通话的基本流程 WebRTC VideoEngine综合应用示例(二)——集成OPENH264编解码器 ...
- 利用ffmpeg一步一步编程实现摄像头采集编码推流直播系统
了解过ffmpeg的人都知道,利用ffmpeg命令即可实现将电脑中摄像头的画面发布出去,例如发布为UDP,RTP,RTMP等,甚至可以发布为HLS,将m3u8文件和视频ts片段保存至Web服务器,普通 ...
- 部分安卓手机微信浏览器中使用XMLHttpRequest 2上传图片显示字节数为0的解决办法
前端JS中使用XMLHttpRequest 2上传图片到服务器,PC端和大部分手机上都正常,但在少部分安卓手机上上传失败,服务器上查看图片,显示字节数为0.下面是上传图片的核心代码: HTML < ...
- 安卓手机APP压力monkey测试
一.Monkey概述 Monkey是Android中的一个命令行工具,可以运行在模拟器里或实际设备中.它向系统发送伪随机的用户事件流(如按键输入.触摸屏输入.手势输入等),实现对正在开发的应用程序进行 ...
- html5调取手机摄像头或相册
html5调用手机摄像头或者相册 由于input的type=file 格式的文件的界面并不是我们所希望的界面,所以在此我隐藏input,自定义样式,这个样式就在<a>中自己定义,这里我就不 ...
- 安卓手机已保存WiFi密码查看助手(开源)
一.需求分析 最近电脑需要连接WiFi,却发现WiFi密码给忘记了.而手机里有保存过的WiFi密码,但是在手机的设置界面看不到. 虽然已经有一些可以查看WiFi密码的app,但是主要还是担心密码被那些 ...
随机推荐
- Java中有几种线程池?
缓存,修正,计划,单一 newCachedThreadPool newFixedThreadPool newScheduleThreadPool newSingleThreadExecutor
- linux个性化定制登录信息
1./etc/motd /etc/motd即messageoftoday(布告栏信息),每次用户登录时,/etc/motd文件的内容会显示在用户的终端.系统管理员可以在文件中编辑系统活动消息,例如:管 ...
- 老徐FrankXuLei 受邀为花旗银行讲授《微软WCF服务分布式开发与SOA架构设计课程》
老徐FrankXuLei 受邀为花旗银行上海研发中心讲授<微软WCF服务分布式开发与SOA架构设计课程> 受邀为花旗银行上海研发中心讲授<微软WCF服务分布式开发与SOA架构设计课程 ...
- 删除RHSA文件方法
DEL /F /A /Q \\?\%1RD /S /Q \\?\%1新建一个批处理文件,包含上面两行代码,然后将要删除的文件拖放进里面就OK!
- AD采样模块采集带模拟量真空表值的实验
实验采用带模拟量,分辨率为1-5V,量程为0--101kpa的真空表 数据采集模块采用DAM-8021, 16位模块 算法描述如下: 真空表读数范围: 0到-101kpa 模拟量输出: 1-5V 一 ...
- 异构GoldenGate 12c 双向复制配置
1.配置window,添加checkpoint表(本文windows和linux互为source和target) GGSCI (WIN-GM5PVS1CILH) 1> view param ./ ...
- sencha touch 在线实战培训 第一期 第五节
2014.1.6晚上8点准时开的课 本期培训一共八节,前三堂免费,后面的课程需要付费才可以观看. 本节内容: 实现皮肤自定义样式的修改 css相关理论: 重写官方样式,美化ap ...
- sencha touch datepicker/datepickerfield(时间选择控件)扩展(废弃 仅参考)
参考资料:https://market.sencha.com/extensions/datetimepicker 上面的扩展在2.2有些问题,参考源码重新写了一个 TimePicker: Ext.de ...
- sencha touch 在视图中显示一个html页面
Ext.define('app.view.about.About', { alternateClassName: 'about', extend: 'Ext.Container', xtype: 'a ...
- vue 项目里正确地引用 jquery
一.NPM安装的jQuery 使用vue-cli构建的vue项目,需要修改的是build/webpack.base.conf.js 1.添加引入webpack,后面的plugins那里需要 const ...