Wed, Mar 30, 22, qt movie qmovie phonon video player
This is a draft, the content is not complete and of poor quality!

introduction

Qt multimedia framework

QtAV is a multimedia playback library based on Qt and FFmpeg. It can help facilitate writing a player application. Features include: * Hardware decoding suppprt: DXVA2, VAAPI, VDA, CedarX, CUDA * OpenGL and ES2 support for Hi10P and other 16-bit YUV videos * Real time preview * Video capture in RGB and YUV format * OSD and custom filters * Subtitles * Transform video using GraphicsItemRenderer. (rotate, shear, etc) * Playing frame by frame (currently support forward playing) * Playback speed control * Variant streams: locale file, http, rtsp, etc. * Audio channel, tracks and external audio tracks * Dynamically change render engine when playing * Multiple video outputs for 1 player * Region of interest(ROI), i.e. video cropping * Video eq: brightness, contrast, saturation, hue * QML support as a plugin. Most playback APIs are compatible with QtMultiMedia module

이글은 제가 podovat.com의 blog 올린글(http://www.podovat.com/?p=182)에서 퍼온것입니다.

Qt에서 동영상을 처리하기 위해서는 QMovie를 이용하여 애니메이션 gif를 통해 처리를 하거나, Phonon::VideoPlayer을 이용하여야 합니다. Phonon::VideoPlayer의 경우 동영상을 처리하기 위해서 linux에서는 gstreamer, windows에서는 DirectShow, Mac OS X에서는 QuickTime을 이용하는데, 이러한 의존성 때문에 배포등에 문제가 발생되는 경우가 있습니다. 이러한 Phonon의 단점을 극복하기 위해서 QtAV라는 오픈소스 Qt 동영상 라이브러리가 있습니다.

QtAV는 FFmpeg을 이용해서 비디오를 디코딩하고, PortAudio를 이용해서 이미지, 오디오등을 재생합니다. 따라서 QtAV를 사용하기 위해서는 FFmpeg, Port Audio 라이브러리가 필요하고, 여기에 추가적으로 Ligav가 추가적으로 필요합니다.

QtAV 빌드 QtAV를 빌드하기 위해서는 FFmpeg, PortAudio, Libav등이 미리 설치되어 있어야 합니다. ubuntu의 경우 간단히 apt-get으로 설치를 하며 되고, 윈도우의 경우 https://github.com/wang-bin/QtAV/wiki/Compile-FFmpeg-and-PortAudio URL을 참고해서 빌드를 하면 됩니다. 추가 라이브러리가 정상적으로 잘 설치되었다면 다음과 같이 화경변수를 등록해 놓고, QtAV를 빌드할 수 있습니다.

windows [code] set INCLUDE=ffmpeg_path\include;portaudio_path\include;%INCLUDE% set LIB=ffmpeg_path\lib;portaudio_path\lib;%LIB% [/code]

Linux [code] export LD_LIBRARY_PATH=ffmpeg_path/lib:portaudio_path/lib:$LD_LIBRARY_PATH [/code]

Qt Creator에서 작업을 한다면, 위의 설정을 다음과 같은 프로젝트 설정화면의 Build Environment에 등록을 해 주시면 됩니다.

img

모든 설정이 완료되었다면 QtAV소스를 열어 다음과 같이 간단하게 build를 해주시면 됩니다.

[code] $ qmake $ make이글은 제가 podovat.com의 blog 올린글(http://www.podovat.com/?p=182)에서 퍼온것입니다.

Qt에서 동영상을 처리하기 위해서는 QMovie를 이용하여 애니메이션 gif를 통해 처리를 하거나, Phonon::VideoPlayer을 이용하여야 합니다. Phonon::VideoPlayer의 경우 동영상을 처리하기 위해서 linux에서는 gstreamer, windows에서는 DirectShow, Mac OS X에서는 QuickTime을 이용하는데, 이러한 의존성 때문에 배포등에 문제가 발생되는 경우가 있습니다. 이러한 Phonon의 단점을 극복하기 위해서 QtAV라는 오픈소스 Qt 동영상 라이브러리가 있습니다.

QtAV는 FFmpeg을 이용해서 비디오를 디코딩하고, PortAudio를 이용해서 이미지, 오디오등을 재생합니다. 따라서 QtAV를 사용하기 위해서는 FFmpeg, Port Audio 라이브러리가 필요하고, 여기에 추가적으로 Ligav가 추가적으로 필요합니다.

QtAV 빌드 QtAV를 빌드하기 위해서는 FFmpeg, PortAudio, Libav등이 미리 설치되어 있어야 합니다. ubuntu의 경우 간단히 apt-get으로 설치를 하며 되고, 윈도우의 경우 https://github.com/wang-bin/QtAV/wiki/Compile-FFmpeg-and-PortAudio URL을 참고해서 빌드를 하면 됩니다. 추가 라이브러리가 정상적으로 잘 설치되었다면 다음과 같이 화경변수를 등록해 놓고, QtAV를 빌드할 수 있습니다.

windows [code] set INCLUDE=ffmpeg_path\include;portaudio_path\include;%INCLUDE% set LIB=ffmpeg_path\lib;portaudio_path\lib;%LIB% [/code]

Linux [code] export LD_LIBRARY_PATH=ffmpeg_path/lib:portaudio_path/lib:$LD_LIBRARY_PATH [/code]

Qt Creator에서 작업을 한다면, 위의 설정을 다음과 같은 프로젝트 설정화면의 Build Environment에 등록을 해 주시면 됩니다.

img

모든 설정이 완료되었다면 QtAV소스를 열어 다음과 같이 간단하게 build를 해주시면 됩니다.

[code] $ qmake $ make [/code]

QtAV사용 QtAV를 내 프로젝트에서 사용하기 위해서는 QtAV 1.3.4이상에서는 다음과 같이 프로젝트에 추가를 해 줍니다. [code] CONFIG += av [/code]

Qt5에서는 [code] QT += av [/code]

만약 QtAV 1.3.4보다 아래 버전이라면, 다음의 myproject 예제와 같이 추가를 해 줍니다. myproject/myproject.pro [code] TEMPLATE = subdirs SUBDIRS += libQtAV myplayer myplayer.depends += libQtAV libQtAV.file = QtAV/QtAV.pro include(QtAV/root.pri) [/code]

위와같이 project 파일에서 QtAV라이브러리에 대한 설정을 모두 마쳤다면, 코드사용은 다음과 같이 아주 쉽게 처리가 됩니다. C++ [code=c] WidgetRenderer renderer; renderer.show(); AVPlayer player; player.setRenderer(&renderer); player.play(“test.avi”); [/code]

QML [code] import QtQuick 2.0 import QtAV 1.3 Rectangle { width: 640 height: 360 color: “black” VideoOut { id: vo anchors.fill: parent } AVPlayer { id: player videoOut: vo } MouseArea { anchors.fill: parent onClicked: { player.source = “test.mp4” player.play() } } } [/code]

QtAV를 이용한 예제 img

QtAV on Mac OS X img

img [/code]

QtAV사용 QtAV를 내 프로젝트에서 사용하기 위해서는 QtAV 1.3.4이상에서는 다음과 같이 프로젝트에 추가를 해 줍니다. [code] CONFIG += av [/code]

Qt5에서는 [code] QT += av [/code]

만약 QtAV 1.3.4보다 아래 버전이라면, 다음의 myproject 예제와 같이 추가를 해 줍니다. myproject/myproject.pro [code] TEMPLATE = subdirs SUBDIRS += libQtAV myplayer myplayer.depends += libQtAV libQtAV.file = QtAV/QtAV.pro include(QtAV/root.pri) [/code]

위와같이 project 파일에서 QtAV라이브러리에 대한 설정을 모두 마쳤다면, 코드사용은 다음과 같이 아주 쉽게 처리가 됩니다. C++ [code=c] WidgetRenderer renderer; renderer.show(); AVPlayer player; player.setRenderer(&renderer); player.play(“test.avi”); [/code]

QML [code] import QtQuick 2.0 import QtAV 1.3 Rectangle { width: 640 height: 360 color: “black” VideoOut { id: vo anchors.fill: parent } AVPlayer { id: player videoOut: vo } MouseArea { anchors.fill: parent onClicked: { player.source = “test.mp4” player.play() } } } [/code]

QtAV를 이용한 예제 img

QtAV on Mac OS X img

img

stackoom

I have a working streaming device (raspberry pi with camera module - it has a tool called “raspivid”), from which I am streaming live video using netcat

raspivid -t 999999 -w 300 -h 300 -hf -fps 20 -o - | nc -l 9999

In Ubuntu, after connecting to the device using netcat and streaming video to mplayer, everything works like a charm…

nc *ip* 9999 | mplayer -fps 200 -demuxer h264es -

Now, I want to make this video available for Windows users (with minimal setup required, possibly only an .exe). I decided to use Qt 5 - it has qTcpSocket and QMediaPlayer (according to doc, it supports stream-input). I already have some code which can read data from socket and also play local files.

But playing streams does not seem to work. Maybe it is because the video format and some codecs ? WMP also cant play the video I saved using raspivid, although vlc plays it perfectly. I also tested cat’ing a simple .avi file (which Qt plays successfully from local disc) in raspberry pi and playing the same TcpStream in Qt with no success.

Also, after netcat’ing from PI and running the compiled program in Windows, I can see that the LED on wifi dongle on raspberry pi starts flashing - so the stream arrives in the application.

Could you maybe give me some advice, what to do/try next?

I have not much previous experience with C++, so if I am asking something really wrong, please do not hit me too hard :)

Also, the “SimpleChatClient” comes from a random template I started working on..

SimpleChatClient::SimpleChatClient(QWidget* parent, Qt::WindowFlags flags)
: QWidget(parent, flags)
{
    QVBoxLayout* main   = new QVBoxLayout(this);
    player = new QMediaPlayer(this, QMediaPlayer::StreamPlayback);
    QVideoWidget* widget = new QVideoWidget;
    widget->show();
    player->setVideoOutput(widget);
    main->addWidget(widget);
    setLayout(main);
    socket = new QTcpSocket(this);
    connect(socket, SIGNAL(connected()), this, SLOT(playStream()));
    toggleConnection();
}

SimpleChatClient::~SimpleChatClient()
{
}

void SimpleChatClient::toggleConnection()
{
    if (socket->state() == QAbstractSocket::UnconnectedState)
    {
        socket->connectToHost(SERVER, PORT);
    }
    else
    {
        socket->disconnectFromHost();
    }
}

void SimpleChatClient::playStream()
{
    player->setMedia(QMediaContent(), socket);
    //player->setMedia(QUrl::fromLocalFile("C:\\Users\\m\\d.avi")); //This works for local files
    if (socket->canReadLine())
    {
        player->play();
    }
}

The following wiki, pages and posts are tagged with

TitleTypeExcerpt
gcs and cloud post Mon, Jan 31, 22, sample4 from sass2 product sample4
overview and initial powerup post Mon, Jan 31, 22, sample1.md of sass2 product2_sample files The most advanced hardware and software ecosystem for enterprise drones
smartAP post Mon, Jan 31, 22, sample5 from sass2 product2 sample5
smartAPLink and faq post Mon, Jan 31, 22, sample3 from sass2 product2 sample3
telemetry and advanced software post Mon, Jan 31, 22, sample2.md of sass2 product2 sample2 file
px4 docker image for jvsim simulation post 목, 2월 10, 22, docker image implmentation for docker px4 simuation
qtcreator wiki from drone guide dev-setup post 화, 2월 15, 22, planning phase research for dashboard elements using
offboard control using pixhawk raspi mavros post Wed, Feb 16, 22, hitl setup and configuraiton using pixhawk raspi mavros and px4
setup gazebo for simulation post Wed, Feb 16, 22, pixhawk ros gazebo gcs simulation
setup mavros and px4 post Wed, Feb 16, 22, setup mavros and px4
testing sitl drone post Wed, Feb 16, 22, process to launch sitl drone
ros and px4 architecture and data flow post Wed, Feb 16, 22, examine how data flows for user interface and drone control
setup ros indigo with tutlesim post Wed, Feb 16, 22, pixhawk gcs simulation series 2 with ros indigo
connecting raspi to matek f406 wing post Fri, Feb 18, 22, hardware setup with raspi 4 with matek f406 wing
px4 simulation for gazebo post Fri, Feb 18, 22, simulation instruciton from px4
Let's roll and conquer! post Monday, Third week with jdlab and first week probably for actual work
brainstorming session prior to setting out on gcs development post Mon, Feb 21, 22, pool resources and ideas into one single gcs you can develop
overview of epp and eps for airframes post Tue, Feb 22, 22, research before business call to manufactueres
connecting rpi to gcs with the use of uavmatrix on uavcast pro post Mon, Feb 28, 22, supported raspi board pinout maps and setup guide
creating custom mission points for fixed wings post Fri, Mar 18, 22, p-turn or turnaround insertion to the mission raw data for exit and entry for p-turnaround and side/front-lap coverage creation that willmod...
gStreamer vs qtAv post Wed, Mar 30, 22, qt movie qmovie phonon video player
realtime georeferencing plus imu overlay post Tue, Apr 05, 22, how to add vehicle status sensor data to georeferencing
rtk reach m2 receiver documentation post Wed, Apr 06, 22, rtk reach receiver wifi 5g lte
avionics on airfoil and frames post Thu, Apr 07, 22, airfoil materials, designs and innovations in the avionics
using openTX on radiomaster TX16s post Sun, Apr 10, 22, rc reciever transmitter opentx radiomaster configuration simulation
adding GPS and IMU data to photos post flight post Mon, Apr 11, 22, perform post processing of gps/imu data or develop camera firmware lib to infuse IMU from fc to exif metadata
BMU BMC BMS battery management post Thu, Apr 14, 22, to check the usage and health of batteries at all phases of flight cycle
viewpro custom pwm post Thu, Apr 14, 22, customize viewpro camera and gimball with mavlink
raspberrypi video streaming post Fri, Apr 22, 22, configure and setup raspi to enable streaming on mavlink and to advance to LTE transmission
lx network, airlink, gcs and data transmission on smart radio, rf mesh and quantum encryption post Tue, Apr 26, 22, all about setup and how it operates and managed