How to escape curly brackets ('{}') in a Video 'source' property ?



  • Hello,
    I understand that this might be a trivial question, but I wasn't able to find a solution online.

    I have a 'Video' component that plays videos from the local file system. It works fine but when the path to the video contains curly brackets it fails with the following error:

    DirectShowPlayerService::doSetUrlSource: Unresolved error code 0x80004005 (Unspecified error)

    and the 'status' of Video is MediaPlayer.InvalidMedia

    I tried to escape them using \ like so:

    popupVideo.source = source.replace(/\{/g,'\\{').replace(/\}/g,'\\}');
    
    

    I also tried:

    popupVideo.source = encodeURI(source);
    
    

    but it didn't work, and I get the same error.

    I must reiterate, files without curly brackets in their path play completely fine.

    Again, I apologize if my question is trivial.


  • Lifetime Qt Champion

    Hi,

    What is the exact path that is failing ?



  • @SGaist

    qml: Source:D:/kodi/movies/test/I'm_Sorry_For_What_I_Said_When_I_Was_Hungry_WEBRip_Crushdawg {fluffy}.mkv
    qml: Status changed triggered in popupVideo, Status is 2
    DirectShowPlayerService::doSetUrlSource: Unresolved error code 0x80004005 (Unspecified error)
    qml: Status changed triggered in popupVideo, Status is 8

    In this specific case this is the path that doesn't work D:/kodi/movies/test/I'm_Sorry_For_What_I_Said_When_I_Was_Hungry_WEBRip_Crushdawg {fluffy}.mkv however I tried it with 5 or 6 other path that contain curly braces and the result is the same. (As I said before, paths without braces work fine)

    This is the function that sets the path for the video:

    function setupVideo(source) {
                sceneViewPopup.open()
    //          console.log("Source:" + source.replace(/\{/g,'\\{').replace(/\}/g,'\\}'))
                console.log("Source:" + source)
    //          popupVideo.source = source.replace(/\{/g,'\\{').replace(/\}/g,'\\}');
                popupVideo.source = source ;
                
            }
    

  • Lifetime Qt Champion

    Might be a silly question but are you using different video containers or is it only the Matroska based that are not working ?



  • @SGaist I've tested .mp4, .avi, .m4v, .flv with and without braces in the path the the results are consistent. No braces works fine, with braces does not work.

    Furthermore, I've tested the same file with and without braces in the path, with braces does not work, without braces it does.


  • Lifetime Qt Champion

    Ok, then you should check the bug report system to see if it's something known. If not please consider opening a new report providing a minimal compilable example as well as your system setup.

    Don't forget to mention that you tested that with different file format/container.



  • @SGaist
    Oh, you think it's a bug in QT?
    I thought it was a simple case of adding an escape sequence before the braces.

    I've made this example, which tries to play the same video file (copy pasted and renamed) one with braces and other without braces, I've add it to the bug report.

    import QtQuick 2.8
    import QtQuick.Controls 2.1
    import QtMultimedia 5.5
    
    ApplicationWindow {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        Rectangle{
            id:mainRect
            anchors.fill: parent
            color:"grey"
    
    
    
            Video{
                id:noBraces
                property bool isPlaying: false
                anchors.top: rowLayout.bottom
                width: 100
                height: 100
                fillMode: VideoOutput.PreserveAspectFit
                source: "D:/kodi/movies/test/fluffy no braces.mkv"
    
                onStatusChanged: {
                    console.log("noBraces status changed: Status is " + status)
                }
            }
    
            Button{
                id:noBracesPlay
                anchors.top: noBraces.bottom
                anchors.horizontalCenter: noBraces.horizontalCenter
                text:"Play No Braces"
                onClicked: {
                    if (!noBraces.isPlaying){
                        noBraces.play()
                        noBraces.isPlaying = true;
                    }else{
                        noBraces.stop()
                        noBraces.isPlaying = false;
                    }
    
    
                }
            }
    
    
            Video{
                id:braces
                property bool isPlaying: false
                anchors.left: noBraces.right
                anchors.verticalCenter: noBraces.verticalCenter
                width: 100
                height: 100
                fillMode: VideoOutput.PreserveAspectFit
                source: "D:/kodi/movies/test/{fluffy braces}.mkv"
    
                onStatusChanged: {
                    console.log("braces status changed: Status is " + status)
                }
            }
    
            Button{
                id:bracesPlay
                anchors.top: braces.bottom
                anchors.horizontalCenter: braces.horizontalCenter
                text:"Play Braces"
                onClicked: {
                    if (!braces.isPlaying){
                        braces.play()
                        braces.isPlaying = true;
                    }else{
                        braces.stop()
                        braces.isPlaying = false;
                    }
    
    
                }
            }
        }
    }
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.