Home > Backend Development > Golang > Golang Joy4 package release example not working

Golang Joy4 package release example not working

王林
Release: 2024-02-06 09:39:03
forward
923 people have browsed it

Golang Joy4包发布示例不起作用

Question content

  • Server: https://github.com/nareix/joy4/tree/master/examples/http_flv_and_rtmp_server
  • Publish: https://github.com/nareix/joy4/tree/master/examples/rtmp_publish

I started the server first, and then ran rtmp_publish to publish the flv data to the server. Unfortunately, it didn't work out.

Afterwards I tried publishing with ffmpeg:

$ ffmpeg -re -i projectindex.flv -c copy -f flv rtmp://localhost:1936/app/publish
Copy after login

It worked and I can play the stream using vlc.

Then I checked the logs on the server. For ffmpeg, the log contains accept and parsing url. But for rtmp_publish.go, the log only contains accept.


Correct answer


I tested using the flv file (sample-3.flv) downloaded from https:// getsamplefiles.com/sample-video-files/flv, and both ffmpeg and rtmp_publish/main.go will work. Can you test it with this file?

If it works, it's likely that the flv file you originally tested contains a stream that the package doesn't support.

I have used ffprobe to check the information of sample-3.flv:

$ ffprobe sample-3.flv
input #0, flv, from 'sample-3.flv':
  metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : lavf56.15.102
  duration: 00:00:30.08, start: 0.000000, bitrate: 7836 kb/s
  stream #0:0: video: h264 (constrained baseline), yuv420p(progressive), 1920x1080 [sar 1:1 dar 16:9], 8000 kb/s, 25 fps, 25 tbr, 1k tbn
Copy after login

You can check your output and compare the output with the above (but I don't know what this package supports or doesn't support).

Notes to others who want to run this example:

First of all, the source code of this package does not contain a go.mod file. Create one at the root of the repository:

$ go mod init github.com/nareix/joy4
Copy after login

http_flv_and_rtmp_server Default listening port 1935. So if we don't change the server, we have to change rtmp_publish/main.go:

- file, _ := avutil.open("projectindex.flv")
- conn, _ := rtmp.dial("rtmp://localhost:1936/app/publish")
+ file, _ := avutil.open("sample-3.flv")
+ conn, _ := rtmp.dial("rtmp://localhost:1935/app/publish")
Copy after login

ffmpeg command should be:

$ ffmpeg -re -i sample-3.flv -c copy -f flv rtmp://localhost:1935/app/publish
Copy after login

And the stream can be played using ffplay:

$ ffplay http://localhost:8089/app/publish
Copy after login

Please make sure sample-3.flv is in the current working directory when running ffmpeg or go run rtmp_publish/main.go

The above is the detailed content of Golang Joy4 package release example not working. For more information, please follow other related articles on the PHP Chinese website!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template