gpt4 book ai didi

android - 无法使用FFMPEG在android中复制RTSP流视频

转载 作者:行者123 更新时间:2023-11-30 00:38:16 25 4
gpt4 key购买 nike

我正在开发一个安卓应用程序。在我的应用程序中,我想使用 ffmpeg录制直播视频。我编写了一段代码来录制直播视频,但它不起作用。它显示了一些错误。如果有人知道这一点,请帮助我。

这是我用来录制视频的代码

try {

fFmpeg.execute(new String[]{"ffmpeg -i rtsp://192.168.1.1:6667/streamhd -acodec copy -vcode c copy"+String.valueOf(getCacheDir())+"/MyVideo.mp4"}, new ExecuteBinaryResponseHandler() {

@Override
public void onSuccess(String message) {
Log.d("fffffff", "FFmpeg cmd success");
}

@Override
public void onFailure(String message) {
Log.d("ffffffffffff", message.toString());
}
});
}catch (FFmpegCommandAlreadyRunningException e) {
// Handle if FFmpeg is already running
e.printStackTrace();
Log.w(null,e.toString());}

当我执行此 block 时,我收到以下错误消息

03-27 12:48:47.109 2042-2042/com.steelmanpro.wifivideoscope D/ffffffffffff: ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.8 (GCC)


configuration: --target-os=linux --cross- prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/vagrant/SourceCode/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=

libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Output #0, mp4, to 'ffmpeg -i rtsp://192.168.1.1:6667/streamhd -acodec copy -vcode c copy/data/data/com.steelmanpro.wifivideoscope/cache/MyVideo.mp4':
Output file #0 does not contain any stream

最佳答案

最后我找到了解决方案。在 Android 中,您必须将 FFMpeg.execute() 方法的参数作为字符串数组传递。

使用下面的代码

 String[] cmd = {"-i" , "rtsp://192.168.1.1:6667/streamhd" , "-fs" , "25M" ,  "-b" , "900k" , "-vcodec" , "copy" , "-r" , "60" , "-y" ,"-movflags","+faststart",""+getNextFileName() } ;

try {

fFmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {


@Override
public void onSuccess(String message) {
Log.d("fffffff", "FFmpeg cmd success");
}

@Override
public void onFailure(String message) {
Log.d("ffffffffffff", message.toString());
}
@Override
public void onProgress(String message) {
}
@Override
public void onFinish() {
Log.d("finish",""+fFmpeg.isFFmpegCommandRunning());

}

});
}catch (FFmpegCommandAlreadyRunningException e) {
// Handle if FFmpeg is already running
e.printStackTrace();
Log.w(null,e.toString());}

关于android - 无法使用FFMPEG在android中复制RTSP流视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43040190/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com