简体   繁体   English

如何停止使用FFMPEG在Android中保存rtsp流视频

[英]How to stop saving rtsp streaming video in android by using FFMPEG

I am saving a rtsp stream by using FFMPEG in android. 我通过在Android中使用FFMPEG保存rtsp流。 When i forcibly stop saving video the video file is corrupted. 当我强行停止保存视频时,视频文件已损坏。 Is there any command to stop saving rtsp stream video. 是否有任何命令停止保存rtsp流视频。 I am using ffmpeg library. 我正在使用ffmpeg库。

Here is the command which i use to save streaming video- 这是我用来保存流式视频的命令-

String path=Environment.getExternalStorageDirectory().getAbsolutePath();
SimpleDateFormat sdf = new SimpleDateFormat("ddMMyyyy-hhmmss");
String file_path = path + "/recording" + sdf.format(new Date()) + ".mp4";
String[] cmd = {"-y", "-i", "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov", "-c:v", "libx264", "-preset", "ultrafast", "-strict", "-2", "-s", "720*1280", "-aspect", "16:9", file_path };
execFFmpegBinary(cmd);

You can not interrupt mp4 format directly so you should change your format to mkv. 您不能直接中断mp4格式,因此应将格式更改为mkv。 so your file path should look like this: 因此您的文件路径应如下所示:

String file_path = path + "/recording" + sdf.format(new Date()) + ".mkv";

But if you really want to go with mp4 only in that case you should add this extra settings in your cmd: -movflags +empty_moov+separate_moof 但是,如果您真的只想在这种情况下使用mp4,则应在cmd中添加以下额外设置: -movflags +empty_moov+separate_moof

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM