Skip to content
  • 0 Votes
    2 Posts
    693 Views
    SGaistS

    Hi,

    That's rather a question you should bring to the GStreamer folks. For the Qt side you can then use QMediaPlayer as shown here with a custom pipeline.

  • 0 Votes
    3 Posts
    879 Views
    C

    Thank you for your answer! I've yet to find a good introduction into QML for C++ developers, but I was a little put off by the somewhat convoluted approach as different tutorials either don't show any QML or only use it soley to develop a very simple application.

    The main problem I'm struggling is with QML is the ability to generate a GUI based on some set preferences. In my case the amount of e.g tabs in the "Options" pane should be defined by the amount of video files which are currently loaded. Is this easily possible to programatically extend QML GUIs?

  • 0 Votes
    6 Posts
    5k Views
    SkroopaS

    @SGaist
    Thanks for you reply. The only way to create what I need - using Android functions directly and I must forgot about crossplatform for my app (if you want to use, for example, hardware acceleration or something).
    The code bellow is the main class (java, for use with QAndroidJniObject), that draws camera preview, using hardware:

    import org.qtproject.qt5.android.bindings.QtApplication; import org.qtproject.qt5.android.bindings.QtActivity; import android.hardware.Camera; import android.media.MediaCodec; import android.media.MediaCodecInfo; import android.media.MediaFormat; import android.media.MediaMuxer; import android.app.Notification; import android.app.NotificationManager; import android.content.Context; import android.graphics.SurfaceTexture; import android.view.TextureView.SurfaceTextureListener; import android.view.TextureView; import android.view.Gravity; import android.widget.FrameLayout; import android.os.Bundle; import java.io.File; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; public class CameraAndroid extends QtActivity implements SurfaceTextureListener { private static NotificationManager notificationManager; private static Notification.Builder notificationBuilder; private static CameraAndroid cameraAndroid; public CameraAndroid() { cameraAndroid = this; } private static MediaCodec mediaCodec; private static TextureView textureView; private static Camera camera; static int encWidth = 640, encHeight = 480; public static int start() { // Camera not started yet if(camera == null) { Camera.CameraInfo info = new Camera.CameraInfo(); // Set front facing camera by default int numCameras = Camera.getNumberOfCameras(); for (int i = 0; i < numCameras; i++) { Camera.getCameraInfo(i, info); if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { camera = Camera.open(i); break; } } if (camera == null) { camera = Camera.open(); } if (camera == null) return 9001; Camera.Parameters params = camera.getParameters(); Camera.Size cameraSize = params.getPreferredPreviewSizeForVideo(); for (Camera.Size size : params.getSupportedPreviewSizes()) { if (size.width == encWidth && size.height == encHeight) { params.setPreviewSize(encWidth, encHeight); break; } } // New camera preview size if (cameraSize != null) { params.setPreviewSize(cameraSize.width, cameraSize.height); } camera.setParameters(params); textureView.setLayoutParams(new FrameLayout.LayoutParams(camera.getParameters().getPreviewSize().width, camera.getParameters().getPreviewSize().height, Gravity.CENTER)); } return 0; } public static int stop() { if (camera != null) { camera.stopPreview(); camera.release(); camera = null; } return 0; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); textureView = new TextureView(this); textureView.setSurfaceTextureListener(this); setContentView(textureView); // <------------------------- Draws on all entire screen :(((( } @Override public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { try { if(start() == 0) { camera.setPreviewTexture(surface); camera.startPreview(); } } catch (IOException ioe) { return 9002; } } @Override public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) { } @Override public void onSurfaceTextureUpdated(SurfaceTexture surface) {} @Override public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) { stop(); return true; } }

    But now, I can't see QML elements of my app! :(( Is it possible to draw QML elements over/above TextureView, change draw order or something? What I must to do?
    Many thanks!

  • 1 Votes
    9 Posts
    9k Views
    N

    @Wieland

    These didn't help either:

    sudo apt-get install gstreamer1.0-* sudo apt-get install libav-tools ffmpeg vlc

    I submitted a question on Qt pipelining. The thing that bothers me is I cannot get QtMultimedia work on a clean installation.

    Nevertheless, I might abandon QtMultimedia and use some other library to embed the video in my Qt application (e.g. VLC-Qt).