The video download file of the National Standard Video Cloud Service EasyGBS National Standard Video Platform device is in ps format. How to change it to MP4 format?

EasyGBS is a video cloud service platform based on the national standard GB/T28181 protocol. It not only supports seamless and complete access to national standard devices on the intranet or public network, but also provides RTSP, RTMP, FLV, HLS, WebRTC and other video formats for output. Streaming distribution service enables full-platform and full-terminal output.

Some users reported that when using EasyGBS equipment to record videos, they found that PS files were downloaded, whereas MP4 files should normally be downloaded. In response to this feedback, we immediately conducted an investigation.

 

Because of the particularity of ps files, many players do not support them, so ps files need to be converted into mp4 files to facilitate users to play them.

You can add the following reference code to convert ps to mp4 using ffmpeg:

if len(filenamehz) == 2 && filenamehz[1] == "ps" {
        outFile := filepath.Join(utils.DataDir(), "downloads", fmt.Sprintf("%s.mp4", filenamehz[0]))
        inFile := filepath.Join(utils.DataDir(), "downloads", filename)
        if _, err := os.Stat(inFile); os.IsNotExist(err) {
            c.AbortWithStatusJSON(http.StatusBadRequest, "录像文件不存在或已过期")
            return
        }
        ff.H264ToMP4(inFile, outFile)
        header := c.Writer.Header()
        header["Content-type"] = []string{"application/octet-stream"}
        header["Content-Disposition"] = []string{"attachment; filename=" + strings.ReplaceAll(filename, ".ps", ".mp4")}
        if !utils.Exist(outFile) {
            c.AbortWithStatusJSON(404, "file not found")
            return
        }
        c.File(outFile)
        if err := os.Remove(outFile); err != nil {
            log.Println(err)
        }
        if err := os.Remove(inFile); err != nil {
            log.Println(err)
        }
}

 After adding it, the device recording page downloads normally, and ordinary players can also play recorded videos.

With its excellent video resource access and processing capabilities, EasyGBS can realize real-time video monitoring live broadcast, recording, retrieval and review, voice intercom, cloud storage, alarm, platform cascading and other functions. The platform can be used directly as a business platform or called as a video capability layer platform, and has been implemented in many project scenarios, such as bright kitchens and bright stoves, smart construction sites, Xueliang projects, safe villages, etc.

 

Guess you like

Origin blog.csdn.net/EasyNTS/article/details/132754341