美文网首页
ffmpeg Android 端推流两种方式

ffmpeg Android 端推流两种方式

作者: 一号读者 | 来源:发表于2023-03-07 10:18 被阅读0次

安卓端推流直接引用 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"

相关文章

网友评论

      本文标题:ffmpeg Android 端推流两种方式

      本文链接:https://www.haomeiwen.com/subject/hxnvldtx.html