Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

iOS saves Video mp4 as zero KB



  • Hello,

    I have a qml that has a videoRecorder .. Application saves mp4 fine in Android.
    The mp4 does saves in iOS .. BUT file size is zero KB

    Camera {
        id: camera
        viewfinder.resolution: "1080x1920"
        // "640x480"
        viewfinder.minimumFrameRate: 30
        viewfinder.maximumFrameRate: 30
        position: Camera.FrontFace
        imageProcessing.whiteBalanceMode: CameraImageProcessing.WhiteBalanceAuto
        focus.focusPointMode: CameraFocus.FocusPointFaceDetection
        focus.focusMode: CameraFocus.FocusContinuous
        exposure {
            exposureMode: Camera.ExposureAuto
        }
        imageProcessing {
            denoisingLevel: 1.0
            }
    
        videoRecorder {
            resolution: "640x480"
            frameRate: 30
            videoBitRate: 15000000
            audioChannels: 1
            audioBitRate: 8000
            mediaContainer: "mp4"
        }
    }
    

    I bind the location as follows

      QString theDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
      QUrl q = QUrl::fromLocalFile(theDir);
      result->m_videoPath = q.toString();
    

    The in QML

                var path = filter.videoPath + "/" + filter.PID + ".MP4";
                videoRecorderPathName.pathName = path;
                var outResult = camera.videoRecorder.setOutputLocation(path);
                if (outResult)
                {
                    console.debug("setOutputLocation success");
                    console.debug("OutputLocation " + path);
                }
                else {
                     console.debug("setOutputLocation fail");
                     console.debug("OutputLocation " + path);
                }
    

    The setOutputLocation returns false

    However; Upon stop .. the file is created in the anticipated directory on the iPhone .. But the file size is zero KB



  • I resolved the issue..

    I will share in the event someone else experiences the same pain as I have today..

    The problem was the videoBitRate & audioBitRate .. after removing these ... the mp4 files saved in iOS correctly .. and by the way I found the correct codec

        videoRecorder {
                resolution: "640x480"
                frameRate: 30
                //videoBitRate: 15000000
                audioChannels: 1
                //audioBitRate: 8000
                mediaContainer: "mp4"
                videoCodec: "avc1"
            }
    

    As a post note ... I want to thank you for providing excellent examples.. I was able to look at your camera-Widget & camera-QML examples and they were valuable.

    The camera-Widget was great because it has a setup dialog that runs all the 'supported' methods so I was able to see the supported Codec and Container option that exist on my iPhone.

    Thanks


  • Lifetime Qt Champion

    Hi and welcome to devnet

    Just an intuition but I would try with mov as media container.



  • Thank you for the rapid reply.. Unfortunately that did resolve the issue.
    Any other ideas?



  • More info ..

    I am getting Unsupported codec messages as well..

    I have tried 'h264' 'mpeg4' 'mp4'

    Would anyone have an idea as to which codec you would use on iOS for mp4 or mov files?

    Are there any libraries or framework LIBS I need to include in the pro file?

    Thank you

    UPDATE: .. current LIBS in pro file
    LIBS += -framework Foundation
    LIBS += -framework AVFoundation
    LIBS += -framework CoreFoundation
    LIBS += -framework MessageUI
    LIBS += -framework Photos



  • I resolved the issue..

    I will share in the event someone else experiences the same pain as I have today..

    The problem was the videoBitRate & audioBitRate .. after removing these ... the mp4 files saved in iOS correctly .. and by the way I found the correct codec

        videoRecorder {
                resolution: "640x480"
                frameRate: 30
                //videoBitRate: 15000000
                audioChannels: 1
                //audioBitRate: 8000
                mediaContainer: "mp4"
                videoCodec: "avc1"
            }
    

    As a post note ... I want to thank you for providing excellent examples.. I was able to look at your camera-Widget & camera-QML examples and they were valuable.

    The camera-Widget was great because it has a setup dialog that runs all the 'supported' methods so I was able to see the supported Codec and Container option that exist on my iPhone.

    Thanks


Log in to reply