Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Showing stream video
QtWS25 Last Chance

Showing stream video

Scheduled Pinned Locked Moved Solved General and Desktop
30 Posts 4 Posters 3.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B BrMisha

    Hi!
    I'm receiving the raw h.264 video stream from QUdpSocket. So, i need to display that on widget.
    I know that QMediaPlayer can't play stream. After googling i found some solutions but all those need external libs. I would like to use only Qt components and decode h.264 using system codecs (QMediaPlayer nice plays h.264 from file using k-like codecs).

    So, I have QByteArray received from camera, I need to decode h.264 frame and show that on widget. How can i do that?
    Thanks)))

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #2

    @BrMisha You could write your own QIODevice and use it with https://doc.qt.io/qt-5/qmediaplayer.html#setMedia

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    B 1 Reply Last reply
    0
    • jsulmJ jsulm

      @BrMisha You could write your own QIODevice and use it with https://doc.qt.io/qt-5/qmediaplayer.html#setMedia

      B Offline
      B Offline
      BrMisha
      wrote on last edited by
      #3

      @jsulm I know but QMediaPlayer uses QIODevice::seek, which isn't available in stream

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #4

        Hi,

        What OS are you on ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        B 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          What OS are you on ?

          B Offline
          B Offline
          BrMisha
          wrote on last edited by
          #5

          @SGaist Windows (10) and Linux (Ubuntu and other).

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #6

            In that case, I would rather consider using VLC and its Qt integration to handle the video stream.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            B 1 Reply Last reply
            0
            • SGaistS SGaist

              In that case, I would rather consider using VLC and its Qt integration to handle the video stream.

              B Offline
              B Offline
              BrMisha
              wrote on last edited by
              #7

              @SGaist but why this solution better of using system codecs?

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #8

                Because VLC is the Swiss Army Knife of vidéo decoding and supports a larger palette of codecs than most OSs provide out of the box.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                B 1 Reply Last reply
                0
                • SGaistS SGaist

                  Because VLC is the Swiss Army Knife of vidéo decoding and supports a larger palette of codecs than most OSs provide out of the box.

                  B Offline
                  B Offline
                  BrMisha
                  wrote on last edited by BrMisha
                  #9

                  @SGaist I would't like to use VLC but you have convinced me)))
                  Tomorrow i will try to build VLC for windows

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    There's likely already a prebuilt package.

                    See also VLC-Qt

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    B 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      There's likely already a prebuilt package.

                      See also VLC-Qt

                      B Offline
                      B Offline
                      BrMisha
                      wrote on last edited by
                      #11

                      @SGaist is VLC-Qt still actuality now? Last commit was in 2016 year and based on VLC 2.2.4

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #12

                        It does not mean it does not work anymore. I'd say it's worth a try.

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • B Offline
                          B Offline
                          BrMisha
                          wrote on last edited by
                          #13

                          Unfortunately, VLC doesn't provide prebuilt packages for my compiler (MinGW32-64 7.3.0).
                          After googling i decided to try ffmpeg. I build it following this manual https://ffmpeg.org/platform.html#Native-Windows-compilation-using-MinGW-or-MinGW_002dw64 , then add libs to *pro file:

                          LIBS += -LF:/FFmpeg/tempinstall/usr/local/lib/ -llibavcodec.dll -llibavformat.dll
                          INCLUDEPATH += F:/FFmpeg/tempinstall/usr/local/include
                          DEPENDPATH += F:/FFmpeg/tempinstall/usr/local/include
                          

                          and i called avformat_open_input(some args). But got error^

                          c:/qt/qt5.14.1/tools/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: main.o: in function `qMain(int, char**)':
                          D:\projects_test\qt\PlayerVideo\build-PlayerVideo-Desktop-Debug/../PlayerVideo/main.cpp:58: undefined reference to `avformat_open_input(AVFormatContext**, char const*, AVInputFormat*, AVDictionary**)'
                          

                          So, i'm searching my mistake... I compared compiler versions between msys2 and qt, booth have GNU Make 4.2.1, but msys2 has gcc 8.3.0 and qt has 7.3.0.
                          That is problem?

                          1 Reply Last reply
                          0
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by
                            #14

                            It's "-lavcodec"

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            B 1 Reply Last reply
                            0
                            • SGaistS SGaist

                              It's "-lavcodec"

                              B Offline
                              B Offline
                              BrMisha
                              wrote on last edited by
                              #15

                              @SGaist no, it isn't helpfull((

                              1 Reply Last reply
                              0
                              • SGaistS Offline
                                SGaistS Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on last edited by
                                #16

                                Did you fix all libraries name ?

                                Interested in AI ? www.idiap.ch
                                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                B 1 Reply Last reply
                                0
                                • SGaistS SGaist

                                  Did you fix all libraries name ?

                                  B Offline
                                  B Offline
                                  BrMisha
                                  wrote on last edited by BrMisha
                                  #17

                                  @SGaist this part of .pro

                                  LIBS += -LF:/Musor/FFmpeg_linbuild/ffmpeg/lib/ -lavformat
                                  
                                  INCLUDEPATH += F:/Musor/FFmpeg_linbuild/ffmpeg/include
                                  DEPENDPATH += F:/Musor/FFmpeg_linbuild/ffmpeg/include
                                  

                                  In code i'm calling only avformat_license(), which locates in avformat

                                  1 Reply Last reply
                                  0
                                  • SGaistS Offline
                                    SGaistS Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #18

                                    Do you have ffmpeg built for the same architecture as your Qt version ?

                                    Interested in AI ? www.idiap.ch
                                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    B 1 Reply Last reply
                                    0
                                    • SGaistS SGaist

                                      Do you have ffmpeg built for the same architecture as your Qt version ?

                                      B Offline
                                      B Offline
                                      BrMisha
                                      wrote on last edited by
                                      #19

                                      @SGaist yes, booth is x64

                                      1 Reply Last reply
                                      0
                                      • B Offline
                                        B Offline
                                        BrMisha
                                        wrote on last edited by
                                        #20

                                        Men, I really don't understand what is happening.
                                        I installed msys2, and some packages for that, then i copied *c:\Qt\Qt5.14.2\Tools\mingw730_64* to *c:\msys64\mingw64*.
                                        Then built libav (it is "small" version of FFmpeg) and got this files:

                                        build\usr\local\bin\avcodec.lib
                                        build\usr\local\bin\avcodec-58.dll
                                        build\usr\local\bin\avconv.exe
                                        build\usr\local\bin\avdevice.lib
                                        build\usr\local\bin\avdevice-57.dll
                                        build\usr\local\bin\avfilter.lib
                                        build\usr\local\bin\avfilter-7.dll
                                        build\usr\local\bin\avformat.lib
                                        build\usr\local\bin\avformat-58.dll
                                        build\usr\local\bin\avprobe.exe
                                        build\usr\local\bin\avresample.lib
                                        build\usr\local\bin\avresample-4.dll
                                        build\usr\local\bin\avutil.lib
                                        build\usr\local\bin\avutil-56.dll
                                        build\usr\local\bin\swscale.lib
                                        build\usr\local\bin\swscale-5.dll
                                        
                                        build\usr\local\include\libavcodec\	<< here is *.h
                                        build\usr\local\include\libavdevice\	<< here is *.h
                                        build\usr\local\include\libavfilter\	<< here is *.h
                                        build\usr\local\include\libavformat\	<< here is *.h
                                        build\usr\local\include\libavresample\	<< here is *.h
                                        build\usr\local\include\libavutil\	<< here is *.h
                                        build\usr\local\include\libswscale\	<< here is *.h
                                        
                                        build\usr\local\lib\pkgconfig\
                                        build\usr\local\lib\avcodec-58.def
                                        build\usr\local\lib\avdevice-57.def
                                        build\usr\local\lib\avfilter-7.def
                                        build\usr\local\lib\avformat-58.def
                                        build\usr\local\lib\avresample-4.def
                                        build\usr\local\lib\avutil-56.def
                                        build\usr\local\lib\libavcodec.dll.a
                                        build\usr\local\lib\libavdevice.dll.a
                                        build\usr\local\lib\libavfilter.dll.a
                                        build\usr\local\lib\libavformat.dll.a
                                        build\usr\local\lib\libavresample.dll.a
                                        build\usr\local\lib\libavutil.dll.a
                                        build\usr\local\lib\libswscale.dll.a
                                        build\usr\local\lib\swscale-5.def
                                        

                                        *c:\Qt\Qt5.14.2\Tools\mingw730_64* was added to PATH. When I start, for example, avconv.exe, it works ok, so definitely libav was built with true mingw (which uses qt).
                                        Next, i added to *.pro (using "Add library...") this:

                                        win32: LIBS += -LF:/Musor/libav/build/usr/local/lib/ -llibavformat.dll
                                        INCLUDEPATH += F:/Musor/libav/build/usr/local/include
                                        DEPENDPATH += F:/Musor/libav/build/usr/local/include
                                        

                                        main.c:

                                        #include <libavformat/avformat.h>
                                        int main(int argc, char *argv[]) {
                                        	avformat_license();
                                        	return 0;
                                        }
                                        

                                        After compilation i got:

                                        C:/Qt/Qt5.14.2/Tools/mingw730_64/bin/mingw32-make -f Makefile.Debug
                                        mingw32-make[1]: Entering directory 'D:/projects_test/qt/qt_test/build-qt_test-Desktop_Qt_5_14_2_MinGW_64_bit-Debug'
                                        g++ -c -fno-keep-inline-dllexport -g -std=gnu++11 -Wall -Wextra -Wextra -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_SERIALPORT_LIB -DQT_CORE_LIB -I..\qt_test -I. -IF:\Musor\libav\build\usr\local\include -IC:\Qt\Qt5.14.2\5.14.2\mingw73_64\include -IC:\Qt\Qt5.14.2\5.14.2\mingw73_64\include\QtSerialPort -IC:\Qt\Qt5.14.2\5.14.2\mingw73_64\include\QtCore -Idebug -IC:\Qt\Qt5.14.2\5.14.2\mingw73_64\mkspecs\win32-g++  -o debug\main.o ..\qt_test\main.cpp
                                        ..\qt_test\main.cpp: In function 'int main(int, char**)':
                                        ..\qt_test\main.cpp:4:14: warning: unused parameter 'argc' [-Wunused-parameter]
                                         int main(int argc, char *argv[])
                                                      ^~~~
                                        ..\qt_test\main.cpp:4:31: warning: unused parameter 'argv' [-Wunused-parameter]
                                         int main(int argc, char *argv[])
                                                                       ^
                                        g++ -Wl,-subsystem,console -mthreads -o debug\qt_test.exe debug/main.o  -LF:\Musor\libav\build\usr\local\lib F:\Musor\libav\build\usr\local\lib\libavformat.dll.a C:\Qt\Qt5.14.2\5.14.2\mingw73_64\lib\libQt5SerialPort.a C:\Qt\Qt5.14.2\5.14.2\mingw73_64\lib\libQt5Core.a   
                                        debug/main.o: In function `main':
                                        D:\projects_test\qt\qt_test\build-qt_test-Desktop_Qt_5_14_2_MinGW_64_bit-Debug/../qt_test/main.cpp:6: undefined reference to `avformat_license()'
                                        collect2.exe: error: ld returned 1 exit status
                                        mingw32-make[1]: *** [Makefile.Debug:68: debug/qt_test.exe] Error 1
                                        mingw32-make: *** [Makefile:45: debug] Error 2
                                        mingw32-make[1]: Leaving directory 'D:/projects_test/qt/qt_test/build-qt_test-Desktop_Qt_5_14_2_MinGW_64_bit-Debug'
                                        18:45:50: The process "C:\Qt\Qt5.14.2\Tools\mingw730_64\bin\mingw32-make.exe" exited with code 2.
                                        Error while building/deploying project qt_test (kit: Desktop Qt 5.14.2 MinGW 64-bit)
                                        When executing step "Make"
                                        

                                        Whyyyyyyy?????
                                        I have tried to change -llibavformat.dll to -lavformat, "-lavformat.dll" and "-lavformat" but i'm stil getting this error.

                                        Pablo J. RoginaP 1 Reply Last reply
                                        0
                                        • SGaistS Offline
                                          SGaistS Offline
                                          SGaist
                                          Lifetime Qt Champion
                                          wrote on last edited by
                                          #21

                                          Might be silly but try linking to all the ffmpeg libraries, just in case.

                                          Interested in AI ? www.idiap.ch
                                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                          B 1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved