安卓端推流直接引用 implementation 'com.arthenica:mobile-ffmpeg-full:4.4' 包
基本方法:
···
public static long executionId;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.takePicture).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
long executionId = FFmpeg.executeAsync("-i rtsp://admin:yoseen2018@192.168.1.202/h264/ch1/main/av_stream -acodec copy -f rtsp -rtsp_transport tcp rtsp://123.55.106.133:554/client/02/cam_1", new ExecuteCallback() {
// long executionId = FFmpeg.executeAsync("-i file1.mp4 -c:v mpeg4 file2.mp4", new ExecuteCallback() {
@Override
public void apply(final long executionId, final int returnCode) {
if (returnCode == RETURN_CODE_SUCCESS) {
Log.i(Config.TAG, "Async command execution completed successfully.");
} else if (returnCode == RETURN_CODE_CANCEL) {
Log.i(Config.TAG, "Async command execution cancelled by user.");
} else {
Log.i(Config.TAG, String.format("Async command execution failed with returnCode=%d.", returnCode));
}
}
});
}
});
findViewById(R.id.takeStop).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FFmpeg.cancel(executionId);
}
});
}
···
注意:
1贤惯、 本地rtsp 轉碼 rtmp 推流命令:
"-i rtsp://admin:yoseen2018@192.168.1.202/h264/ch1/main/av_stream -acodec copy -f flv rtmp://192.168.1.155:1935/live/01"
2走贪、 本地rtsp 推流 rtsp的udp 推流命令:
"-i rtsp://admin:yoseen2018@192.168.1.202/h264/ch1/main/av_stream -acodec copy f rtsp rtsp://192.168.1.155:1935/live/01"
3、本地rtsp 推流 rtsp的TCP推流命令:
"-i rtsp://admin:yoseen2018@192.168.1.202/h264/ch1/main/av_stream -acodec copy -f rtsp -rtsp_transport tcp rtsp://192.168.1.155:1935/live/01"