本文整理汇总了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;
}
示例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");
}
}
示例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");
}
}
示例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");
}
}
示例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");
}
}