Android:我想录制尽可能低质量的视频源并以离散数据包发送。是否可以?你会如何处理它?

发布于 2025-01-06 01:49:57 字数 474 浏览 0 评论 0原文

基本上我希望能够在小于 3g 的情况下发送几秒延迟的“实时”提要。如果质量非常低也没关系。如有必要,我什至可以使用 4 位灰度(尽管 128-256 色更好)。如有必要,我愿意将分辨率设置为低至 160x120、>1fps。在这种最糟糕的设置下完全未压缩意味着低带宽连接过饱和。

我应该考虑简单地将快照作为图像吗?有人熟悉 Bitmapfactory 在处理最低质量 JPEG 方面的功能吗?

我应该研究 PNG 或 GIF 吗?我的理解是,固体字段最适合这些。我不确定除了大部分天空之外我还可以依赖固体领域,因为我希望控制一架发回“视频”的无人机。具有几秒延迟的人造视频很好,甚至更好,因为我预计经常会丢失和重新获得服务器连接。

我在“3g”上得到了大约 128k 的信号,信号不错,但我不能完全依赖于此。我可以在服务器端进行任何必要的解码 - 这应该不是问题。

所以我问你,Stack,你想通过互联网从智能手机上查看内容,而不能依赖于良好的连接。你如何处理它?

Basically I want to be able to send a few second delayed "live" feed over less than 3g. It's ok if it very low quality. I could even go with like 4 bit grayscale if necessary (though 128-256 colors would be preferable). I'd be willing to go as low as 160x120 at >1fps if necessary. Fully uncompressed at this crummiest of settings means an over-saturated low bandwidth connection.

Should I look into simply snapshotting as images? Is anyone familiar with the capabilities of Bitmapfactory with regard to the lowest quality JPEGs possible?

Should I look into PNGs or GIFs? My understanding is that solid fields work best with these. I'm not sure I can depend a lot on solid fields other than a good portion of sky, as I'm looking to have control over a drone that sends back "video." Faux video with a several second delay is fine and even preferable as I expect losing and regaining server connection often.

I get like 128k up on "3g" with a decent signal, but i can't exactly depend on that. I can do any necessary decoding server side - that shouldn't be a problem.

So I ask you, Stack, you want to see from your smartphone over the internet and cannot depend on a good connection. How do you approach it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雨落星ぅ辰 2025-01-13 01:49:57

我认为最简单的方法是抓取预览图像并发送它们。

这是我发现的一段很好的代码,用于将预览图像抓取为 JPEG。它又好又快,应该能满足您的需求。我也用它来上传,所以我想要非常小的文件大小。

输出 1920x1080 图像时,文件大小在 150-300KB 之间。

    camera.setOneShotPreviewCallback(new PreviewCallback() {
            @Override
            public void onPreviewFrame(byte[] data, Camera camera) {
                try {
                    Camera.Parameters parameters = camera.getParameters();
                    Size size = parameters.getPreviewSize();
                    YuvImage image = new YuvImage(data, parameters.getPreviewFormat(),
                            size.width, size.height, null);
                    File file = new File(getCacheDir().getPath() + "/out.jpg");
                    FileOutputStream filecon = new FileOutputStream(file);
                    image.compressToJpeg(
                            new Rect(0, 0, image.getWidth(), image.getHeight()), 90,
                            filecon);
                } catch (FileNotFoundException e) {
                }
            }
        });

以下是我将预览尺寸设置为最大设置的方法,但您可以将其设置为较小的尺寸以加快速度。

Camera.Parameters parameters = camera.getParameters();
List<Camera.Size> previewSizes = parameters.getSupportedPreviewSizes();
imageWidth = previewSizes.get(0).width;
imageHeight = previewSizes.get(0).height;
parameters.setPreviewSize(imageWidth, imageHeight);
camera.setParameters(parameters);

I think the most simple approach will be grabbing the preview images and sending those.

Here's a nice piece of code I found for grabbing the preview image as a JPEG. It's nice and fast and should suit your needs. I was also using it for uploading, so I was after very small file size.

When outputting 1920x1080 images the file size was anywhere between 150-300KB.

    camera.setOneShotPreviewCallback(new PreviewCallback() {
            @Override
            public void onPreviewFrame(byte[] data, Camera camera) {
                try {
                    Camera.Parameters parameters = camera.getParameters();
                    Size size = parameters.getPreviewSize();
                    YuvImage image = new YuvImage(data, parameters.getPreviewFormat(),
                            size.width, size.height, null);
                    File file = new File(getCacheDir().getPath() + "/out.jpg");
                    FileOutputStream filecon = new FileOutputStream(file);
                    image.compressToJpeg(
                            new Rect(0, 0, image.getWidth(), image.getHeight()), 90,
                            filecon);
                } catch (FileNotFoundException e) {
                }
            }
        });

Here's how I just set the preview size to the maximum setting, but you can set it to a lower one to speed things up.

Camera.Parameters parameters = camera.getParameters();
List<Camera.Size> previewSizes = parameters.getSupportedPreviewSizes();
imageWidth = previewSizes.get(0).width;
imageHeight = previewSizes.get(0).height;
parameters.setPreviewSize(imageWidth, imageHeight);
camera.setParameters(parameters);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文