简体   繁体   English

使用qml对象(ubuntu)播放MJPG视频

[英]Play MJPG video using qml object (ubuntu)

I have this application where I display content together with a video file. 我有这个应用程序,可以在其中显示内容以及视频文件。 The video files are either in image/jpeg (MJPG format according to vlc) or video/x-h264 format. 视频文件为image / jpeg(根据vlc为MJPG格式)或video / x-h264格式。

To do this, I use a mediasource combined with a video output element to display the video. 为此,我结合使用mediasource和视频输出元素来显示视频。 This is working perfectly when using h264. 使用h264时,这可以完美地工作。 However, this is not working at all with the mjpg video files. 但是,这对于mjpg视频文件根本不起作用。

But I have no idea how to do this. 但是我不知道该怎么做。 I have read up on libraries using either ffmpeg or vlc, but I can't seem to find libraries to use in combination with QML elements, only with regular QWidgets. 我已经阅读了使用ffmpeg或vlc编写的库,但是似乎找不到与QML元素结合使用的库,仅与常规QWidgets结合使用。

Here is some (stripped down) relevant code, it is really simple and I would prefer to keep it simple. 这是一些(精简的)相关代码,它确实很简单,我希望保持简单。 So ideally I am just looking for a way to get a codec into the project or something like that. 因此,理想情况下,我只是在寻找一种将编解码器引入项目或类似项目的方法。

property string videoLocation

FileDialog {
    id: videoFileDialog
    onAccepted: {
        videoLocation = fileUrl
    }
}

MediaPlayer {
    id: mediaplayer
    source: videoLocation
    autoPlay: false
}

 VideoOutput {
     id: videoOutput
     source: mediaplayer
}

Maybe relevant: my system is ubuntu 13.04 and I use qt 5.3. 可能相关:我的系统是ubuntu 13.04,我使用的是qt 5.3。 Thx in advance 提前Thx

EDIT: I have figured out the problem I think: The stream is recorded using gstreamer > 1.0. 编辑:我已经解决了我认为的问题:使用gstreamer> 1.0记录流。 For some reason it won't play back in 0.10. 由于某种原因,它将无法以0.10播放。 If I record using the same settings, but with gstreamer 0.10, everything is fine and my application works (though this option is not feasible, I really need to capture using > 1) 如果我使用相同的设置进行录制,但使用gstreamer 0.10,一切正常,我的应用程序可以正常工作(尽管此选项不可行,我确实需要使用> 1进行捕获)

Here is the code I am using to capture the stream to a file: 这是我用来捕获流到文件的代码:

gst-launch-0.10 v4l2src device=/dev/cam1 ! image/jpeg,width=320,height=240,framerate=30/1 ! matroskamux ! filesink location=videotest.mkv

Any suggestions for a setting that is compatible between new and old gstreamer? 对新旧gstreamer之间兼容的设置有何建议?

On *nix platforms, QtMultimedia uses GStreamer as its backend . 在* nix平台上,QtMultimedia 使用GStreamer作为其后端 On GStreamer's website it appears that JPEG is a supported format (and one would assume that includes motion jpeg.) 在GStreamer的网站上,似乎JPEG是一种受支持的格式 (并且可以假定其中包括动态jpeg。)

Check your package manager to make sure you have all of GStreamer's plugins installed. 检查软件包管理器,以确保您已安装所有GStreamer的插件。 There's at least three different packages of GStreamer plugins on Ubuntu. Ubuntu上至少有三个不同的GStreamer插件包。

So I fixed it by using an avi container instead of a matroska container. 所以我通过使用avi容器而不是matroska容器来修复它。 No idea why it works now and not with matroska. 不知道为什么现在可以使用,而不是与matroska一起使用。 I can honestly only think this has to be a bug somewhere. 老实说,我只能认为这一定是某个地方的错误。

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

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