English 中文(简体)
Decode android s soil encoded H264 UK food using ffmpeg in real time
原标题:Decode android s hardware encoded H264 camera feed using ffmpeg in real time

I m 试图使用硬件(H264 encoder on Anders )制造摄像机的录像,并使用FFmpeg tox(所有内容都放在Anderson)

我迄今为止所完成的工作是将<代码>H264的录像带上rtsp 包装,并用VLC(超过UDP)加以编码,因此我知道该录像至少是正确的格式。 然而,我很难以能够理解的格式将视频数据带至ffmpeg

I ve试图将同样的<代码>rtsp包装箱送至当地东道方的5006港(UDP),然后提供ffmpeg with sdp 如果我理解<代码>rt正确流出,则记录显示当地哪一个港口正在进入视频流,以及录像如何编码。 然而,这只字不提工作,而I m则难以诊断为什么,作为<条码>ffmpeg。 坐在那里等待投入。

出于相对性和可扩展性的原因,我只能把视频和录音带给服务器和 mu,必须以尽可能轻重的方式在电话上播放。

我对我所期望的是关于如何做到这一点的建议。 最好的解决办法是将包装代码的录像带至ffmpeg。 可在管道上发送<条码>ffmpeg。 <代码>dp 存档参数,需要编码视频。

I can provide more information on request, like how ffmpeg is compiled for Android but I doubt that s necessary.

奥赫,以及我开始的<条码>ffmpeg的方式,都是通过指挥线进行的,如果尽可能的话,我会避免与jni混在一起。

And help would be much appreciated, thanks.

问题回答

你们是否尝试使用java.lang。 运行时间?

String[] parameters = {"ffmpeg", "other", "args"};
Program program Runtime.getRuntime().exec(parameters);

InputStream in = program.getInputStream();
OutputStream out = program.getOutputStream();
InputStream err = program.getErrorStream();

然后,你写下字,从 st和 st子读。 它不是一个管道,但应当比使用网络接口更好。

很晚,但我认为这是一个很好的问题,它还没有一个很好的答案。

如果你想把照相机和从roid子装置中分离出来,你有两个主要选择: Java或NDK执行。

  1. Java implementation.

I m only going to mention the idea but basically it is implement an RTSP Server and RTP Protocol in java based on these standards Real-Time Streaming Protocol Version 2.0 and RTP Payload Format for H.264 Video. This task will be very long and hard. But if you are doing your PhP it could be nice to have a nice RTSP Java lib for Android.

  1. NDK implementation.

This is alternative include various solutions. The main idea is to use a power C or C++ library in our Android application. For this instance, FFmpeg. This library can be compiled for Android and may support various architectures. The problem of this approach is that you may need to learn about the Android NDK, C and C++ to accomplish this.

But there is an alternative. You can wrap the c library and use the FFmpeg. But how?

例如,使用FFmpeg Anders/a, 编集了x264, libass, fontconfig, freetype and fribidi,并支持各种建筑。 但是,如果你想要实时上流,你需要处理文件说明和在/外流。

The best alternative, from a Java programming point of view, is to use JavaCV. JavaCV uses wrappers from commonly used libraries of computer vision that includes: (OpenCV, FFmpeg, etc, and provides utility classes to make their functionality easier to use on the Java platform, including (of course) Android.

JavaCV also comes with hardware accelerated full-screen image display (CanvasFrame and GLCanvasFrame), easy-to-use methods to execute code in parallel on multiple cores (Parallel), user-friendly geometric and color calibration of cameras and projectors (GeometricCalibrator, ProCamGeometricCalibrator, ProCamColorCalibrator), detection and matching of feature points (ObjectFinder), a set of classes that implement direct image alignment of projector-camera systems (mainly GNImageAligner, ProjectiveTransformer, ProjectiveColorTransformer, ProCamTransformer, and ReflectanceInitializer), a blob analysis package (Blobs), as well as miscellaneous functionality in the JavaCV class. Some of these classes also have an OpenCL and OpenGL counterpart, their names ending with CL or starting with GL, i.e.: JavaCVCL, GLCanvasFrame, etc.

但我们如何利用这一解决办法?

在这方面,我们有利用民主力量联盟的基本执行情况。

String streamURL = "udp://ip_destination:port";
recorder = new FFmpegFrameRecorder(streamURL, frameWidth, frameHeight, 1);
recorder.setInterleaved(false);
// video options //
recorder.setFormat("mpegts");
recorder.setVideoOption("tune", "zerolatency");
recorder.setVideoOption("preset", "ultrafast");
recorder.setVideoBitrate(5 * 1024 * 1024);
recorder.setFrameRate(30);
recorder.setSampleRate(AUDIO_SAMPLE_RATE);
recorder.setVideoCodec(AV_CODEC_ID_H264);
recorder.setAudioCodec(AV_CODEC_ID_AAC);

该守则的这一部分表明,如何启动称为记录器的FFmpegFrameRecorder物体。 该物体将捕获和编码从摄像机和从麦克风获得的样本中获取的框架。

如果你想在同一个安乐器中捕获一个预览器,我们就需要实施一个照相机级,这一级将转换从照相机中获取的原始数据,并将为FFmpegFrameRecorder创建笔试和框架。

将ip子替换为你希望寄出的 p子或装置。 例如,港口可以是8080个。

@Override
public Mat onCameraFrame(Mat mat)
{
    if (audioRecordRunnable == null) {
        startTime = System.currentTimeMillis();
        return mat;
    }
    if (recording && mat != null) {
        synchronized (semaphore) {
            try {
                Frame frame = converterToMat.convert(mat);
                long t = 1000 * (System.currentTimeMillis() - startTime);
                if (t > recorder.getTimestamp()) {
                    recorder.setTimestamp(t);
                }
                recorder.record(frame);
            } catch (FFmpegFrameRecorder.Exception e) {
                LogHelper.i(TAG, e.getMessage());
                e.printStackTrace();
            }
        }
    }
    return mat;
}

这种方法显示,从摄像机中获取Mat(图像)的<代码>-onCameraFrame方法的实施,该方法被转换成碎片,由FFmpegFrameRecorder物体记录。

@Override
public void onSampleReady(ShortBuffer audioData)
{
    if (recorder == null) return;
    if (recording && audioData == null) return;

    try {
        long t = 1000 * (System.currentTimeMillis() - startTime);
        if (t > recorder.getTimestamp()) {
            recorder.setTimestamp(t);
        }
        LogHelper.e(TAG, "audioData: " + audioData);
        recorder.recordSamples(audioData);
    } catch (FFmpegFrameRecorder.Exception e) {
        LogHelper.v(TAG, e.getMessage());
        e.printStackTrace();
    }
}

带有<代码>audioData的样子是ShortBuffer的标的,由FFmpegFrameRecorder公司登记。

In the PC or device destination you can run the following command to get the stream.

ffplay udp://ip_source:port

The ip_source is the ip of the smartphone that is streaming the UK and mic stream. 港口必须是8080。

I created a solution in my github repository here: UDPAVStreamer.

Good luck





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签