translate the note of LiveActivity into English

translate the note of LiveActivity into English
pull/166/head
xufulong 5 years ago
parent 143b465f79
commit ef988b0d86
  1. 35
      app/src/main/java/com/frank/ffmpeg/activity/AudioHandleActivity.java
  2. 18
      app/src/main/java/com/frank/ffmpeg/activity/LiveActivity.java
  3. 2
      app/src/main/java/com/frank/ffmpeg/activity/MediaHandleActivity.java
  4. 2
      app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.java

@ -24,7 +24,7 @@ import static com.frank.ffmpeg.handler.FFmpegHandler.MSG_BEGIN;
import static com.frank.ffmpeg.handler.FFmpegHandler.MSG_FINISH;
/**
* 使用ffmpeg处理音频
* Using ffmpeg command to handle audio
* Created by frank on 2018/1/23.
*/
@ -101,7 +101,7 @@ public class AudioHandleActivity extends BaseActivity {
}
/**
* 调用ffmpeg处理音频
* Using ffmpeg cmd to handle audio
*
* @param srcFile srcFile
*/
@ -115,11 +115,11 @@ public class AudioHandleActivity extends BaseActivity {
return;
}
switch (viewId) {
case R.id.btn_transform://转码
if (useFFmpeg) { //使用FFmpeg转码
case R.id.btn_transform:
if (useFFmpeg) { //use FFmpeg to transform
String transformFile = PATH + File.separator + "transformAudio.mp3";
commandLine = FFmpegUtil.transformAudio(srcFile, transformFile);
} else { //使用MediaCodec与mp3lame转mp3
} else { //use MediaCodec and libmp3lame to transform
new Thread(new Runnable() {
@Override
public void run() {
@ -130,7 +130,7 @@ public class AudioHandleActivity extends BaseActivity {
}).start();
}
break;
case R.id.btn_cut://剪切(注意原文件与剪切文件格式一致,文件绝对路径最好不包含中文、特殊字符)
case R.id.btn_cut://cut audio, it's best not include special characters
String suffix = FileUtil.getFileSuffix(srcFile);
if (suffix == null || suffix.isEmpty()) {
return;
@ -138,7 +138,7 @@ public class AudioHandleActivity extends BaseActivity {
String cutFile = PATH + File.separator + "cutAudio" + suffix;
commandLine = FFmpegUtil.cutAudio(srcFile, 10, 15, cutFile);
break;
case R.id.btn_concat://合并,支持MP3、AAC、AMR等,不支持PCM裸流,不支持WAV(PCM裸流加音频头)
case R.id.btn_concat://concat audio
if (!FileUtil.checkFileExist(appendFile)) {
return;
}
@ -148,7 +148,7 @@ public class AudioHandleActivity extends BaseActivity {
String concatFile = PATH + File.separator + "concat.mp3";
commandLine = FFmpegUtil.concatAudio(fileList, concatFile);
break;
case R.id.btn_mix://混音
case R.id.btn_mix://mix audio
if (!FileUtil.checkFileExist(appendFile)) {
return;
}
@ -159,7 +159,7 @@ public class AudioHandleActivity extends BaseActivity {
String mixFile = PATH + File.separator + "mix" + mixSuffix;
commandLine = FFmpegUtil.mixAudio(srcFile, appendFile, mixFile);
break;
case R.id.btn_play_audio://解码播放(AudioTrack)
case R.id.btn_play_audio://use AudioTrack to play audio
new Thread(new Runnable() {
@Override
public void run() {
@ -167,7 +167,7 @@ public class AudioHandleActivity extends BaseActivity {
}
}).start();
return;
case R.id.btn_play_opensl://解码播放(OpenSL ES)
case R.id.btn_play_opensl://use OpenSL ES to play audio
new Thread(new Runnable() {
@Override
public void run() {
@ -175,20 +175,19 @@ public class AudioHandleActivity extends BaseActivity {
}
}).start();
return;
case R.id.btn_audio_encode://音频编码
//可编码成WAV、AAC。如果需要编码成MP3,ffmpeg需要重新编译,把MP3库enable
case R.id.btn_audio_encode://audio encode
String pcmFile = PATH + File.separator + "concat.pcm";
String wavFile = PATH + File.separator + "new.wav";
//pcm数据的采样率,一般采样率为8000、16000、44100
//sample rate, normal is 8000/16000/44100
int sampleRate = 8000;
//pcm数据的声道,单声道为1,立体声道为2
//channel num of pcm
int channel = 1;
commandLine = FFmpegUtil.encodeAudio(pcmFile, wavFile, sampleRate, channel);
break;
case R.id.btn_pcm_concat://PCM裸流音频文件合并
String srcPCM = PATH + File.separator + "audio.pcm";//第一个pcm文件
String appendPCM = PATH + File.separator + "audio.pcm";//第二个pcm文件
String concatPCM = PATH + File.separator + "concat.pcm";//合并后的文件
case R.id.btn_pcm_concat://concat PCM streams
String srcPCM = PATH + File.separator + "audio.pcm";
String appendPCM = PATH + File.separator + "audio.pcm";
String concatPCM = PATH + File.separator + "concat.pcm";
if (!FileUtil.checkFileExist(srcPCM) || !FileUtil.checkFileExist(appendPCM)) {
return;
}

@ -21,7 +21,7 @@ import com.frank.live.param.VideoParam;
import com.frank.live.LivePusherNew;
/**
* h264与rtmp实时推流直播
* Realtime living with rtmp stream
* Created by frank on 2018/1/28.
*/
@ -68,16 +68,16 @@ public class LiveActivity extends BaseActivity implements CompoundButton.OnCheck
}
private void initPusher() {
int width = 640;//分辨率设置
int width = 640;//resolution
int height = 480;
int videoBitRate = 800_000;//kb/s
int videoFrameRate = 10;//fps
VideoParam videoParam = new VideoParam(width, height,
Integer.valueOf(Camera2Helper.CAMERA_ID_BACK), videoBitRate, videoFrameRate);
int sampleRate = 44100;//采样率:Hz
int channelConfig = AudioFormat.CHANNEL_IN_STEREO;//立体声道
int audioFormat = AudioFormat.ENCODING_PCM_16BIT;//pcm16位
int numChannels = 2;//声道数
int sampleRate = 44100;//sample rate: Hz
int channelConfig = AudioFormat.CHANNEL_IN_STEREO;
int audioFormat = AudioFormat.ENCODING_PCM_16BIT;
int numChannels = 2;//channel number
AudioParam audioParam = new AudioParam(sampleRate, channelConfig, audioFormat, numChannels);
livePusher = new LivePusherNew(this, videoParam, audioParam);
livePusher.setPreviewDisplay(textureView.getHolder());
@ -86,14 +86,14 @@ public class LiveActivity extends BaseActivity implements CompoundButton.OnCheck
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
switch (buttonView.getId()) {
case R.id.btn_live://开始/停止直播
case R.id.btn_live://start or stop living
if (isChecked) {
livePusher.startPush(LIVE_URL, this);
} else {
livePusher.stopPush();
}
break;
case R.id.btn_mute://设置静音
case R.id.btn_mute://mute or not
Log.i(TAG, "isChecked=" + isChecked);
livePusher.setMute(isChecked);
break;
@ -118,7 +118,7 @@ public class LiveActivity extends BaseActivity implements CompoundButton.OnCheck
@Override
void onViewClick(View view) {
if (view.getId() == R.id.btn_swap) {//切换摄像头
if (view.getId() == R.id.btn_swap) {//switch camera
livePusher.switchCamera();
}
}

@ -124,7 +124,7 @@ public class MediaHandleActivity extends BaseActivity {
}
/**
* execute ffmpeg cmd to handle media
* Using ffmpeg cmd to handle media
*
* @param srcFile srcFile
*/

@ -108,7 +108,7 @@ public class VideoHandleActivity extends BaseActivity {
}
/**
* call FFmpeg cmd to process video
* Using FFmpeg cmd to handle video
*
* @param srcFile srcFile
*/

Loading…
Cancel
Save