Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Able to rotate a rectangle but not a video (solved)

    QML and Qt Quick
    5
    7
    1137
    Loading More Posts
    • 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.
    • H
      houmingc last edited by

      I am able to rotate a rectangle but i am not able to rotate a video
      Below is my code. Can explain what is wrong with my code.
      @.....................................................................................................
      import QtQuick 2.2
      import QtQuick.Window 2.1

      Window {
      visible:true
      width:760
      height:700
      Item {
      width 300; height:300
      Rectangle{
      id: rect
      width:150;height:100;anchors.centerln:parent
      color:"red"
      smooth:true
      states:State{
      name:"rotated"
      PropertyChanges{target:rect; rotation:180}
      }
      transitions:Transition{
      RotationAnimation{duration:3000; direction:RotationAnimation.Numerical}
      }
      }
      MouseArea {anchors.fill:parent; onClicked: rect.state="rotated"}
      }
      }

      Below is the code i use to rotate video

      import QtQuick 2.2
      import QtQuick.Window 2.2
      import QtMultimedia 5.0

      Window {
      visible:true
      width:760
      height:700

        Item {
           width:300; height:300
            MediaPlayer{
             id:player_1
             source:"file:///xxx.mp4"
             autoPlay:true
             autoLoad:true
             muted:false
         }
         VideoOutput{
          id:voutput_1
          source:player_1
          fillMode:VideoOutput.PreserveAspectFit
          x:0
          y:0
          height: parent.height
          width:parent.width/2
       }
          states:State{
                     name: "rotated"
                     PropertyChanges{ target:player_1;rotation:180)
                    }
               transitions:Transition{
                      RotationAnimation{duration:3000; direction:RotationAnimation.Numerical}
                      }
            }  MouseArea {anchors.fill:parent; onClicked:player_1.state="rotated"}
      

      }

      @

      P 1 Reply Last reply Reply Quote 0
      • M
        mcm_qt last edited by

        Rect and Item will behave different as I know. Try a video item in a Rect with anchor.fillparent(), and then rotate the Rect?

        1 Reply Last reply Reply Quote 0
        • Gianluca
          Gianluca last edited by

          Your are rotating the wrong Item.

          player_1 is a MediaPlayer, a non visual item that just decode the video and audio from a source.
          While, voutput_1 is a real visual item that render the decoded frames and audio into the screen.
          So, you should rotate the voutput_1, while in your code your are trying to rotate the player_1

          P.S.: Pay attention, on some platform the VideoOutput has strong limitation (on iOS for example)

          1 Reply Last reply Reply Quote 0
          • T
            timday last edited by

            Interesting; are limitations on VideoOutput on iOS documented anywhere? (Anywhere friendly to people bringing Qt apps to iOS who don't know a whole lot about iOS and just expect stuff that works in Qt on desktop platforms to work on iOS too that is). Or just a matter of prodding it and seeing what works?

            1 Reply Last reply Reply Quote 0
            • Gianluca
              Gianluca last edited by

              The limitation is written into the documentation ... but they don't explicit tell on which platform:
              [quote]
              The VideoOutput item works with backends that support either QVideoRendererControl or QVideoWindowControl. If the backend only supports QVideoWindowControl, the video is rendered onto an overlay window that is layered on top of the QtQuick window. Due to the nature of the video overlays, certain features are not available for these kind of backends:

              Some transformations like rotations
              Having other QtQuick items on top of the VideoOutput item
              Most backends however do support QVideoRendererControl and therefore don't have the limitations listed above.[/quote]

              Actually, it seems that only iOS had this limitation.

              1 Reply Last reply Reply Quote 0
              • T
                timday last edited by

                Ah thanks that's good to know; I was toying with taking my app down a route where I wanted to do clever stuff with texture mapping video, using it as shader sources etc. Some of the behaviour I was seeing with ordinary VideoOutput on iOS was already making me think it was probably an overlay rather than anything more integrated though.

                1 Reply Last reply Reply Quote 0
                • P
                  pressurehold @houmingc last edited by

                  This post is deleted!
                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post