• 392阅读
  • 0回复

[讨论]qt6,qml中的MediaRecorder,pause后再record,duration变大很多 [复制链接]

上一主题 下一主题
离线1020219467
 

只看楼主 倒序阅读 楼主  发表于: 2023-12-01
代码:
import QtQuick
import QtQuick.Window
import QtCharts
import QtMultimedia
import QtQuick.Controls
Window {
    width: 640
    height: 480
    visible:true
    Row{
        Button{
            width: 100
            height: 100
            text:"pause"
            z: 1
            onClicked: {
                if (text == "pause") {
                    recorder.pause()
                    text = "continue"

                } else if(text == "continue"){
                    recorder.record()
                    text = "pause"
                }

            }
        }
        Button{
            width:100
            height:100
            text:"over"
            onClicked: {
                camera.stop()
                recorder.stop()
            }
        }
    }

    VideoOutput{
        id:videoOutput
        anchors.fill: parent
    }

    CaptureSession {
        id: captureSession
        camera: camera
        videoOutput: videoOutput
        recorder: recorder
    }
    Camera {
        id:camera
    }
    MediaRecorder {
        id: recorder
        outputLocation: "file:D:/code/Qt/test2/build-test2-Desktop_Qt_6_5_2_MSVC2019_64bit-Debug/Record"
        onRecorderStateChanged: {
            if(recorderState === MediaRecorder.StoppedState)
                console.log("state StoppedState")
            else if(recorderState === MediaRecorder.RecordingState)
                console.log("state RecordingState")
            else if(recorderState === MediaRecorder.PausedState)
                console.log("state PausedState")
        }

        onDurationChanged: {
            console.log("duration",duration)
        }
    }

    Component.onCompleted: {
        camera.start()
        recorder.record()
    }
    Component.onDestruction: {
        camera.stop()
        recorder.stop()
    }
}
输出:
qml: duration 992
qml: duration 1024
qml: duration 1072
qml: duration 1104
qml: duration 1136
qml: duration 1168
qml: duration 1200
qml: state PausedState
qml: state RecordingState
qml: duration 103017163
qml: duration 103017195
qml: duration 103017227
qml: duration 103017259
qml: duration 103017291
[mp4 @ 000001DC13A6E040] Packet duration: 3090478892 / dts: 3090514902 is out of range
[mp4 @ 000001DC13A6E040] pts has no value
qml: duration 103017323
[mp4 @ 000001DC13A6E040] Packet duration: 3090479849 / dts: 3090515860 is out of range
[mp4 @ 000001DC13A6E040] pts has no value
qml: duration 103017355
[mp4 @ 000001DC13A6E040] Packet duration: 3090480807 / dts: 3090516819 is out of range
[mp4 @ 000001DC13A6E040] pts has no value
qml: duration 103017387
[mp4 @ 000001DC13A6E040] Packet duration: 3090481764 / dts: 3090517777 is out of range
qml: duration 103017435
[mp4 @ 000001DC13A6E040] pts has no value
[mp4 @ 000001DC13A6E040] Packet duration: 3090482724 / dts: 3090518738 is out of range
[mp4 @ 000001DC13A6E040] pts has no value
qml: duration 103017467
快速回复
限100 字节
 
上一个 下一个