当前位置: 首页>>代码示例>>Java>>正文


Java MediaMuxer.addTrack方法代码示例

本文整理汇总了Java中android.media.MediaMuxer.addTrack方法的典型用法代码示例。如果您正苦于以下问题:Java MediaMuxer.addTrack方法的具体用法?Java MediaMuxer.addTrack怎么用?Java MediaMuxer.addTrack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.media.MediaMuxer的用法示例。


在下文中一共展示了MediaMuxer.addTrack方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addTrack

import android.media.MediaMuxer; //导入方法依赖的package包/类
@Override
public int addTrack(MediaFormat mediaFormat) {
    int ret=-1;
    synchronized (Lock){
        if(!muxStarted){
            if(audioTrack==-1&&videoTrack==-1){
                try {
                    mMuxer=new MediaMuxer(path,MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
                } catch (IOException e) {
                    e.printStackTrace();
                    AvLog.e("create MediaMuxer failed:"+e.getMessage());
                }
            }
            String mime=mediaFormat.getString(MediaFormat.KEY_MIME);
            if(mime.startsWith("audio")){
                audioTrack=mMuxer.addTrack(mediaFormat);
                ret=audioTrack;
            }else if(mime.startsWith("video")){
                videoTrack=mMuxer.addTrack(mediaFormat);
                ret=videoTrack;
            }
            startMux();
        }
    }
    return ret;
}
 
开发者ID:aiyaapp,项目名称:AAVT,代码行数:27,代码来源:StrengthenMp4MuxStore.java

示例2: startRecord

import android.media.MediaMuxer; //导入方法依赖的package包/类
/**
 * Start record a MP4 video. Need be called while stream.
 *
 * @param path where file will be saved.
 * @throws IOException If you init it before start stream.
 */
public void startRecord(String path) throws IOException {
  if (streaming) {
    mediaMuxer = new MediaMuxer(path, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
    if (videoFormat != null) {
      videoTrack = mediaMuxer.addTrack(videoFormat);
    }
    if (audioFormat != null) {
      audioTrack = mediaMuxer.addTrack(audioFormat);
    }
    mediaMuxer.start();
    recording = true;
  } else {
    throw new IOException("Need be called while stream");
  }
}
 
开发者ID:pedroSG94,项目名称:rtmp-rtsp-stream-client-java,代码行数:22,代码来源:Camera2Base.java

示例3: startRecord

import android.media.MediaMuxer; //导入方法依赖的package包/类
/**
 * Start record a MP4 video. Need be called while stream.
 *
 * @param path where file will be saved.
 * @throws IOException If you init it before start stream.
 */
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
public void startRecord(String path) throws IOException {
  if (streaming) {
    mediaMuxer = new MediaMuxer(path, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
    if (videoFormat != null) {
      videoTrack = mediaMuxer.addTrack(videoFormat);
    }
    if (audioFormat != null) {
      audioTrack = mediaMuxer.addTrack(audioFormat);
    }
    mediaMuxer.start();
    recording = true;
  } else {
    throw new IOException("Need be called while stream");
  }
}
 
开发者ID:pedroSG94,项目名称:rtmp-rtsp-stream-client-java,代码行数:23,代码来源:Camera1Base.java

示例4: startRecord

import android.media.MediaMuxer; //导入方法依赖的package包/类
/**
 * Start record a MP4 video. Need be called while stream.
 *
 * @param path where file will be saved.
 * @throws IOException If you init it before start stream.
 */
public void startRecord(String path) throws IOException {
  if (streaming) {
    mediaMuxer = new MediaMuxer(path, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
    videoTrack = mediaMuxer.addTrack(videoFormat);
    audioTrack = mediaMuxer.addTrack(audioFormat);
    mediaMuxer.start();
    recording = true;
  } else {
    throw new IOException("Need be called while stream");
  }
}
 
开发者ID:pedroSG94,项目名称:rtmp-rtsp-stream-client-java,代码行数:18,代码来源:DisplayBase.java

示例5: startRecord

import android.media.MediaMuxer; //导入方法依赖的package包/类
/**
 * Start record a MP4 video. Need be called while stream.
 *
 * @param path where file will be saved.
 * @throws IOException If you init it before start stream.
 */
public void startRecord(String path) throws IOException {
  if (streaming) {
    mediaMuxer = new MediaMuxer(path, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
    videoTrack = mediaMuxer.addTrack(videoFormat);
    mediaMuxer.start();
    recording = true;
  } else {
    throw new IOException("Need be called while stream");
  }
}
 
开发者ID:pedroSG94,项目名称:rtmp-rtsp-stream-client-java,代码行数:17,代码来源:FromFileBase.java


注:本文中的android.media.MediaMuxer.addTrack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。