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. QImage list to MP4
Qt 6.11 is out! See what's new in the release blog

QImage list to MP4

Scheduled Pinned Locked Moved Solved General and Desktop
16 Posts 5 Posters 9.7k Views 2 Watching
  • 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.
  • A Offline
    A Offline
    ArsenArsen
    wrote on last edited by
    #1

    Hello! I have a program that saves a few QImages into memory and needs to convert them to a few formats. I am wondering how would I implement H264 wrapped in MP4 using eg. libavformat + libavcodec.

    Has anyone tried this before and how hard should it be and should I keep using libavformat and libavcodec?
    Thanks in advance,

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Using the libs directly is a bit more involved.
      You need to understand/read the documentation and
      it takes some effort to set up correctly.
      Its much faster just calling ffmpeg via QProcess
      https://trac.ffmpeg.org/wiki/Encode/H.264
      https://en.wikibooks.org/wiki/FFMPEG_An_Intermediate_Guide/h.264
      but if you must have in memory , there is no way. around it.
      However, since ffmpeg uses libavformat and libavcodec it seems perfectly valid
      to use them.

      1 Reply Last reply
      2
      • A Offline
        A Offline
        ArsenArsen
        wrote on last edited by
        #3

        @mrjj, thanks for answering.
        While it is not necessary for them to be in memory I would've preferred that. I can do anything to the images in my setup.

        I wanted to do this first, but my issue was packing the binary with my application, for multiple reasons.
        One of them is that I deploy for Windows, Linux and Mac. And One of my issues would be correctly obtaining the binary for the OS and architecture.
        Second issue is choosing the format with the least waste and overhead which is going to be joined later.

        I have been looking through examples but as I have little to no experience with media I basically have no clue what the examples are doing.
        Thanks,

        mrjjM 1 Reply Last reply
        1
        • A ArsenArsen

          @mrjj, thanks for answering.
          While it is not necessary for them to be in memory I would've preferred that. I can do anything to the images in my setup.

          I wanted to do this first, but my issue was packing the binary with my application, for multiple reasons.
          One of them is that I deploy for Windows, Linux and Mac. And One of my issues would be correctly obtaining the binary for the OS and architecture.
          Second issue is choosing the format with the least waste and overhead which is going to be joined later.

          I have been looking through examples but as I have little to no experience with media I basically have no clue what the examples are doing.
          Thanks,

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @ArsenArsen
          Well for the mentioned platform, there are installers available so it seem not huge
          issue to bundle it. But I agree, there might be details with it.
          https://ffmpeg.org/download.html

          On the other hand, having the right libs for each platform and linking it will not be
          super trivial either.

          I would fool around with the samples
          https://ffmpeg.org/doxygen/3.2/examples.html
          and see how it felt before deciding which route would be best.

          A 1 Reply Last reply
          2
          • mrjjM mrjj

            @ArsenArsen
            Well for the mentioned platform, there are installers available so it seem not huge
            issue to bundle it. But I agree, there might be details with it.
            https://ffmpeg.org/download.html

            On the other hand, having the right libs for each platform and linking it will not be
            super trivial either.

            I would fool around with the samples
            https://ffmpeg.org/doxygen/3.2/examples.html
            and see how it felt before deciding which route would be best.

            A Offline
            A Offline
            ArsenArsen
            wrote on last edited by ArsenArsen
            #5

            @mrjj
            I'll try and report back here if I succeed (for further reference and other people which may experience the same issue)

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

              Hi and welcome to devnet,

              IIRC H.264 is a licensed codec so you have to take that into account.

              Otherwise, it's completely doable to use ffmpeg with Qt.

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

              A 1 Reply Last reply
              1
              • SGaistS SGaist

                Hi and welcome to devnet,

                IIRC H.264 is a licensed codec so you have to take that into account.

                Otherwise, it's completely doable to use ffmpeg with Qt.

                A Offline
                A Offline
                ArsenArsen
                wrote on last edited by
                #7

                @SGaist said in QImage list to MP4:

                H.264 is a licensed codec

                Oh yep it is. Hrm. What should I do about that..

                I guess contacting their licensing?

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

                  AFAIK, yes, at least to know the conditions required to use the encoder.

                  Otherwise you have free formats like webm that you can use.

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

                  A 1 Reply Last reply
                  1
                  • SGaistS SGaist

                    AFAIK, yes, at least to know the conditions required to use the encoder.

                    Otherwise you have free formats like webm that you can use.

                    A Offline
                    A Offline
                    ArsenArsen
                    wrote on last edited by
                    #9

                    @SGaist I think I'll do that instead. I've been looking around and seems like getting licensed is a hellish process. I'll use WebM. Thanks for letting me know before I made the mistake :)

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      ArsenArsen
                      wrote on last edited by
                      #10

                      Turns out this is a lot easier than I first expected. Files are here. The link will soon be dead as I am merging that branch with master. Thanks for your support!

                      1 Reply Last reply
                      0
                      • VRoninV Offline
                        VRoninV Offline
                        VRonin
                        wrote on last edited by VRonin
                        #11

                        @ArsenArsen said in QImage list to MP4:

                        Files are here.

                        goto

                        My eyes are burning

                        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                        ~Napoleon Bonaparte

                        On a crusade to banish setIndexWidget() from the holy land of Qt

                        A J.HilkJ 2 Replies Last reply
                        3
                        • VRoninV VRonin

                          @ArsenArsen said in QImage list to MP4:

                          Files are here.

                          goto

                          My eyes are burning

                          A Offline
                          A Offline
                          ArsenArsen
                          wrote on last edited by
                          #12

                          @VRonin Seems like the best choice there honestly, because the .... and this can be done without it. I see now.

                          Meh. It works.

                          inb4 dead

                          1 Reply Last reply
                          0
                          • VRoninV VRonin

                            @ArsenArsen said in QImage list to MP4:

                            Files are here.

                            goto

                            My eyes are burning

                            J.HilkJ Offline
                            J.HilkJ Offline
                            J.Hilk
                            Moderators
                            wrote on last edited by
                            #13

                            @VRonin hey don't just goto to harshly, its still the best way to break out of nested loops...

                            ...
                            Except mabye making the nested loop a function and using return....


                            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                            Q: What's that?
                            A: It's blue light.
                            Q: What does it do?
                            A: It turns blue.

                            VRoninV 1 Reply Last reply
                            0
                            • J.HilkJ J.Hilk

                              @VRonin hey don't just goto to harshly, its still the best way to break out of nested loops...

                              ...
                              Except mabye making the nested loop a function and using return....

                              VRoninV Offline
                              VRoninV Offline
                              VRonin
                              wrote on last edited by
                              #14

                              @J.Hilk said in QImage list to MP4:

                              its still the best way to break out of nested loops

                              bool breakAll=false;
                              for(int i=0;i<1000 && !breakAll;++i){
                              for(int j=0;j<1000 && !breakAll;++j){
                              if(shouldIStopEverything())
                              breakAll=true;
                              }
                              }
                              

                              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                              ~Napoleon Bonaparte

                              On a crusade to banish setIndexWidget() from the holy land of Qt

                              1 Reply Last reply
                              3
                              • A Offline
                                A Offline
                                ArsenArsen
                                wrote on last edited by
                                #15

                                I wasn't wrong. The link is dead. New one

                                1 Reply Last reply
                                0
                                • VRoninV Offline
                                  VRoninV Offline
                                  VRonin
                                  wrote on last edited by
                                  #16

                                  We are going WAY off topic

                                  bool Encoder::end() {
                                      if (success)
                                          av_write_trailer(fc);
                                      avcodec_free_context(&out->enc);
                                      av_frame_free(&out->frame);
                                      sws_freeContext(out->sws);
                                      delete out;
                                      if (!(fc->oformat->flags & AVFMT_NOFILE)) //
                                          avio_closep(&fc->pb);
                                      avformat_free_context(fc);
                                      return success;
                                  }
                                  

                                  "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                                  ~Napoleon Bonaparte

                                  On a crusade to banish setIndexWidget() from the holy land of Qt

                                  1 Reply Last reply
                                  1

                                  • Login

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