赞
踩
安卓端推流直接引用 implementation 'com.arthenica:mobile-ffmpeg-full:4.4' 包
记得添加网络权限
<uses-permission android:name="android.permission.INTERNET" />
基本方法:
···
- 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"
作者:一号读者
链接:https://www.jianshu.com/p/bdbfe5290ae1
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。