當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。