horgh / videostreamer Goto Github PK
View Code? Open in Web Editor NEWStream video (e.g. RTSP) to an HTML5 video element (MP4)
License: GNU General Public License v3.0
Stream video (e.g. RTSP) to an HTML5 video element (MP4)
License: GNU General Public License v3.0
Hello,
I've found an issue when I run multiple versions of the process at once:
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x7f71c7347849]
runtime stack:
runtime.throw(0x6f0eda, 0x2a)
/usr/local/go/src/runtime/panic.go:605 +0x95
runtime.sigpanic()
/usr/local/go/src/runtime/signal_unix.go:351 +0x2b8
goroutine 70 [syscall, locked to thread]:
runtime.cgocall(0x643a10, 0xc420479f40, 0xc420404178)
/usr/local/go/src/runtime/cgocall.go:132 +0xe4 fp=0xc420479f10 sp=0xc420479ed0 pc=0x4040f4
main._Cfunc_vs_write_packet(0x7f71a0000930, 0x7f7164015980, 0x7f7160000b20, 0x0, 0x0)
github.com/horgh/videostreamer/_obj/_cgo_gotypes.go:1161 +0x4d fp=0xc420479f40 sp=0xc420479f10 pc=0x63c83d
main.packetWriter.func1(0x7f71a0000930, 0x7f7164015980, 0x7f7160000b20, 0x0, 0x1)
/home/swiftlet/work/src/github.com/horgh/videostreamer/videostreamer.go:343 +0xeb fp=0xc420479f78 sp=0xc420479f40 pc=0x63fb4b
main.packetWriter(0xc42000c020, 0x7f71a0000930, 0x0)
/home/swiftlet/work/src/github.com/horgh/videostreamer/videostreamer.go:343 +0xd8 fp=0xc420479fc8 sp=0xc420479f78 pc=0x63e6a8
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:2337 +0x1 fp=0xc420479fd0 sp=0xc420479fc8 pc=0x45a301
created by main.writePacketToClients
/home/swiftlet/work/src/github.com/horgh/videostreamer/videostreamer.go:307 +0x46f
goroutine 1 [IO wait, 6 minutes]:
internal/poll.runtime_pollWait(0x7f71c993cf70, 0x72, 0xffffffffffffffff)
/usr/local/go/src/runtime/netpoll.go:173 +0x57
internal/poll.(*pollDesc).wait(0xc420114018, 0x72, 0xc420067a00, 0x0, 0x0)
/usr/local/go/src/internal/poll/fd_poll_runtime.go:85 +0xae
internal/poll.(*pollDesc).waitRead(0xc420114018, 0xffffffffffffff00, 0x0, 0x0)
/usr/local/go/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Accept(0xc420114000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/internal/poll/fd_unix.go:335 +0x1e2
net.(*netFD).accept(0xc420114000, 0x413f99, 0xc420358080, 0x686f20)
/usr/local/go/src/net/fd_unix.go:238 +0x42
net.(*TCPListener).accept(0xc42000e040, 0x686f20, 0xc420067c60, 0x4029c7)
/usr/local/go/src/net/tcpsock_posix.go:136 +0x2e
net.(*TCPListener).AcceptTCP(0xc42000e040, 0xc420067ca8, 0xc420067cb0, 0xc420067ca0)
/usr/local/go/src/net/tcpsock.go:234 +0x49
net/http.tcpKeepAliveListener.Accept(0xc42000e040, 0x6f8e58, 0xc420358000, 0xa395a0, 0xc420082e70)
/usr/local/go/src/net/http/server.go:3120 +0x2f
net/http.(*Server).Serve(0xc42008ec30, 0xa390e0, 0xc42000e040, 0x0, 0x0)
/usr/local/go/src/net/http/server.go:2695 +0x1b2
net/http.(*Server).ListenAndServe(0xc42008ec30, 0x27, 0xc420067e50)
/usr/local/go/src/net/http/server.go:2636 +0xa9
main.main()
/home/swiftlet/work/src/github.com/horgh/videostreamer/videostreamer.go:95 +0x601
goroutine 5 [chan receive]:
main.encoder(0x7fff79ef273f, 0x4, 0x7fff79ef2756, 0x3d, 0x0, 0xc420080120)
/home/swiftlet/work/src/github.com/horgh/videostreamer/videostreamer.go:147 +0xcd
created by main.main
/home/swiftlet/work/src/github.com/horgh/videostreamer/videostreamer.go:64 +0x193
goroutine 16 [runnable]:
syscall.Syscall(0x0, 0xd, 0xc420412000, 0x400, 0x400, 0x400, 0x0)
/usr/local/go/src/syscall/asm_linux_amd64.s:18 +0x5
syscall.read(0xd, 0xc420412000, 0x400, 0x400, 0xc4204cda01, 0x0, 0x0)
/usr/local/go/src/syscall/zsyscall_linux_amd64.go:756 +0x55
syscall.Read(0xd, 0xc420412000, 0x400, 0x400, 0x3f, 0xc4204cdb08, 0x412e07)
/usr/local/go/src/syscall/syscall_unix.go:162 +0x49
internal/poll.(*FD).Read(0xc420564000, 0xc420412000, 0x400, 0x400, 0x0, 0x0, 0x0)
/usr/local/go/src/internal/poll/fd_unix.go:122 +0x125
os.(*File).read(0xc42053e018, 0xc420412000, 0x400, 0x400, 0xc420126140, 0x0, 0x0)
/usr/local/go/src/os/file_unix.go:216 +0x4e
os.(*File).Read(0xc42053e018, 0xc420412000, 0x400, 0x400, 0x400, 0x400, 0x0)
/usr/local/go/src/os/file.go:103 +0x6d
main.HTTPHandler.streamRequest(0x6f2f00, 0xc420080120, 0xa38fa0, 0xc420552000, 0xc42056c200)
/home/swiftlet/work/src/github.com/horgh/videostreamer/videostreamer.go:416 +0x2a3
main.HTTPHandler.ServeHTTP(0xc4204cdc00, 0xc420080120, 0xa38fa0, 0xc420552000, 0xc42056c200)
/home/swiftlet/work/src/github.com/horgh/videostreamer/videostreamer.go:379 +0x2a5
main.(*HTTPHandler).ServeHTTP(0xc420058b00, 0xa38fa0, 0xc420552000, 0xc42056c200)
<autogenerated>:1 +0x62
net/http.serverHandler.ServeHTTP(0xc42008ec30, 0xa38fa0, 0xc420552000, 0xc42056c200)
/usr/local/go/src/net/http/server.go:2619 +0xb4
net/http.(*conn).serve(0xc420358000, 0xa394e0, 0xc4201260c0)
/usr/local/go/src/net/http/server.go:1801 +0x71d
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:2720 +0x288
goroutine 38 [IO wait, 6 minutes]:
internal/poll.runtime_pollWait(0x7f71c993c970, 0x72, 0x0)
/usr/local/go/src/runtime/netpoll.go:173 +0x57
internal/poll.(*pollDesc).wait(0xc420354018, 0x72, 0xffffffffffffff00, 0xa366e0, 0xa33280)
/usr/local/go/src/internal/poll/fd_poll_runtime.go:85 +0xae
internal/poll.(*pollDesc).waitRead(0xc420354018, 0xc420356000, 0x1, 0x1)
/usr/local/go/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Read(0xc420354000, 0xc4203560d1, 0x1, 0x1, 0x0, 0x0, 0x0)
/usr/local/go/src/internal/poll/fd_unix.go:126 +0x18a
net.(*netFD).Read(0xc420354000, 0xc4203560d1, 0x1, 0x1, 0x0, 0x0, 0x0)
/usr/local/go/src/net/fd_unix.go:202 +0x52
net.(*conn).Read(0xc42000ea30, 0xc4203560d1, 0x1, 0x1, 0x0, 0x0, 0x0)
/usr/local/go/src/net/net.go:176 +0x6d
net/http.(*connReader).backgroundRead(0xc4203560c0)
/usr/local/go/src/net/http/server.go:660 +0x62
created by net/http.(*connReader).startBackgroundRead
/usr/local/go/src/net/http/server.go:656 +0xd8
As far as I can tell, one instance will run all day without a problem, but once I add another simultaneous process it craps out after a few minutes.
I'll run in verbose mode and find if that yields more information.
Hi.
I am very new in software developers world, and I have never used golang before.
So, please excuse me. Could you, please, help me resolve this issue?
(the problem)
$ go get github.com/horgh/videostreamer
github.com/horgh/videostreamer
/usr/bin/ld: /usr/local/lib/libavcodec.a(cuviddec.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
github.com/horgh/videostreamer
videostreamer.c: In function ‘vs_setup’:
videostreamer.c:29:2: warning: ‘av_register_all’ is deprecated (declared at /usr/local/include/libavformat/avformat.h:2025) [-Wdeprecated-declarations]
av_register_all();
^
(additional info)
OS: Linux 4.4.0-128-generic #154~14.04.1-Ubuntu
ffmpeg version n4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.4)
configuration: --fatal-warnings --enable-gpl --enable-nonfree --enable-version3 --enable-postproc --disable-w32threads --enable-pthreads --enable-avfilter --enable-libx264 --enable-nvenc --enable-decklink --extra-ldflags=-ldl --extra-libs=-ldl --extra-cflags=-I/usr/include/DeckLink --enable-ffplay --enable-openssl
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
Hi Guys,
I installed the plugin on octoprint 1.4.x,
can see it in the plugin manager but not configure it.
If that still works, I would like to use it in combination with videostream that I don't have to change the tempalte manually.
Tanks
$ go get github.com/horgh/videostreamer
videostreamer.c:87:18: error: no member named 'codecpar' in 'struct AVStream'
videostreamer.c:170:6: warning: implicit declaration of function 'avcodec_parameters_copy' is invalid in C99 [-Wimplicit-function-declaration]
videostreamer.c:170:42: error: no member named 'codecpar' in 'struct AVStream'
videostreamer.c:171:16: error: no member named 'codecpar' in 'struct AVStream'
Hello,
I've just tried your project. Looking exactly for something like this.
Code compiles and starts just fine. Used cmd line
./videostreamer -port 9100 -input rtsp://videostreamer:[email protected]:554/cam/realmonitor?channel=1&subtype=1 -host 192.168.0.20 -verbose -fcgi=false
It outputs:
2018/07/23 21:29:46 Starting to serve requests on 192.168.0.20:9100 (HTTP)
2018/07/23 21:29:46 encoder: Waiting for clients...
Opening the index.html sample page (with corrected video url) it shows nothing.
2018/07/23 21:29:56 Serving [GET] request from [192.168.0.106:50383] to path [/stream] (0 bytes)
2018/07/23 21:29:56 encoder: New client unable to open input
2018/07/23 21:29:56 Unable to open input
2018/07/23 21:29:56 encoder: Unable to open input
2018/07/23 21:29:56 192.168.0.106:50383: Read error: EOF
2018/07/23 21:29:56 192.168.0.106:50383: Client cleaned up
Tried the remux-example to save the video to file and that works just fine.
Any tips on how to troubleshoot?
Regards,
Erik
Hello,
installing on debian stretch is not possible, because:
go get github.com/horgh/videostreamer
# github.com/horgh/videostreamer
work/src/github.com/horgh/videostreamer/videostreamer.go:346:14: could not determine kind of name for C.av_packet_clone
work/src/github.com/horgh/videostreamer/videostreamer.go:265:4: could not determine kind of name for C.av_packet_free
Any idea how to solve this issue?
Hello,
First, sorry for my bad english write..
I followed the install description on Linux without problems, however I have problems on Windows (10), and it is impossible for me to build the program on Win10.
The main problem, seem the only problem, is related to access to the FFmpeg library.
-> i use MinGW 730_x64 (which I use without worries for other constructions with "Go", like for OpenCV)
-> The "ffmpeg" library come from the "pack" developer of the official website, and its installed in a "libs" folder
(!) there is no ".pc" file in this pack, useful for "pkg_config"
So...
I added the program "pkg_config" (and its dependencies) in my MinGW folder, it is taken into account during the construction.
I get ".pc" files from my linux (same library version) and "modified", by hand, the paths to correspond to the "libs" folder of my windows
I indicated in the variable "PKG_CONFIG_PATH" the folder of the files " .pc" (and check that they are taken into account)
Without success, during the build, I always have an error to find the ffmpeg library.
So I tried to indicate the path of the libraries via the set variable CGO_CPPFLAGS ("-I") and CGO_LDFLAGS ("-L"), again without success.
I "resolve" somme error from "*.h" acces file (ffmpeg library), it's very bad method, i know ;), but at the end it was now some "linked" error i get...(sic)
My lack of knowledge "Go" and build options, prevents me from going further, however I remain convinced that I do not miss much :)
Thank you very much in advance for all "tracks" to succeed, finally, in compiling the "Go" program
Hi,
That's a great project, thanks for putting this together!
I see you provide a Dockerfile, it would be great to propose both a dockerimage to pull as well as a docker-compose to ease the setup of the project.
I can contribute and will open a related PR soon.
Hi,
Excuse me!!
I don't know if is by the client (
How can I improve to reduce lag?
Maybe
Thank you so much!!
Maybe you should look towards multi-camera streaming? It's very easy to implement
Hello! Thx for great app. Can you help me? I'm start streamer with command:
./videostreamer -input rtsp://admin:[email protected]:8554/live1.264 -fcgi=false -format RTSP -port 8999
Chrome - perfectli works, but Octo show OK and dint show a stream. A NOT_OK log:
./videostreamer -input rtsp://admin:[email protected]:8554/live1.264 -fcgi=false -format RTSP -port 8999
2023/10/06 07:04:26 Starting to serve requests on 0.0.0.0:8999 (HTTP)
2023/10/06 07:04:26 encoder: Waiting for clients...
2023/10/06 07:04:34 Serving [GET] request from [10.0.1.9:55728] to path [/stream] (0 bytes)
2023/10/06 07:04:34 encoder: New client
2023/10/06 07:04:35 Opened output for client
2023/10/06 07:04:38 10.0.1.9:55728: Write error: write tcp 10.0.1.43:8999->10.0.1.9:55728: write: broken pipe
2023/10/06 07:04:38 10.0.1.9:55728: Client cleaned up
unable to write frame: Broken pipe
2023/10/06 07:04:40 Failure writing packet
2023/10/06 07:04:41 Client too slow
unable to write trailer
2023/10/06 07:04:41 encoder: 0 clients
2023/10/06 07:04:41 encoder: Closed input
2023/10/06 07:04:41 encoder: Waiting for clients...
I'm find a control.jijnja2 in differnt folder - ~/OctoPrint/lib/python3.10/site-packages/octoprint/templates/tabs and it didnt contain
Great project!
I'm not getting any audio with my stream. Is that to be expected?
Hi @horgh ,
I ran the remux_example.c with rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov to test and I get
Application provided invalid, non monotonically increasing dts to muxer in stream 1: 18750 >= 0
Output #0, mp4, to 'file:/tmp/out.mp4':
Stream #0:0: Audio: aac (LC), 48000 Hz, stereo, fltp
Stream #0:1: Video: h264 (Constrained Baseline), yuv420p(progressive), 240x160, q=2-31
in: pts:0 pts_time:0 dts:0 dts_time:0 duration:1024 duration_time:0.0213333 stream_index:0
out: pts:0 pts_time:0 dts:0 dts_time:0 duration:1024 duration_time:0.0213333 stream_index:0
in: pts:18750 pts_time:0.208333 dts:18750 dts_time:0.208333 duration:3750 duration_time:0.0416667 stream_index:1
out: pts:18750 pts_time:0.208333 dts:18750 dts_time:0.208333 duration:3750 duration_time:0.0416667 stream_index:1
in: pts:0 pts_time:0 dts:0 dts_time:0 duration:3750 duration_time:0.0416667 stream_index:1
out: pts:0 pts_time:0 dts:0 dts_time:0 duration:3750 duration_time:0.0416667 stream_index:1
[mp4 @ 0x10f1ae0] Application provided invalid, non monotonically increasing dts to muxer in stream 1: 18750 >= 0
Maybe is easy to resolve for you :)
Thank you so much.
For more convenient use, it may be worth revising the approach to configuring the application through config files. I can help you with that
Hello, and thank you for writing this excellent application! I've been trying to integrate this into a video wall application, but after about 25s, the software closes the input.
I'm running this on Ubuntu 16.04 with FFMPEG installed from this PPA.
The client is Google Chrome (63.0.3239.132) with the mp4 URL opened directly.
Here is the output from the daemon:
2018/01/11 16:36:38 Starting to serve requests on 0.0.0.0:9001 (HTTP)
2018/01/11 16:36:38 encoder: Waiting for clients...
2018/01/11 16:36:44 Serving [GET] request from [192.168.1.148:57365] to path [/stream] (0 bytes)
2018/01/11 16:36:44 encoder: New client
2018/01/11 16:36:45 Opened output for client
2018/01/11 16:36:48 Serving [GET] request from [192.168.1.148:57366] to path [/stream] (0 bytes)
2018/01/11 16:36:48 encoder: 2 clients
2018/01/11 16:36:48 Opened output for client
2018/01/11 16:36:48 192.168.1.148:57365: Write error: write tcp 192.168.1.183:9001->192.168.1.148:57365: write: broken pipe
unable to write frame: Broken pipe
2018/01/11 16:36:48 Failure writing packet
2018/01/11 16:36:48 192.168.1.148:57365: Client cleaned up
2018/01/11 16:36:49 Client too slow
unable to write trailer
2018/01/11 16:36:49 encoder: 1 clients
[mp4 @ 0x964e720] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 2683980 >= 0
unable to write frame: Invalid argument
2018/01/11 16:37:14 Failure writing packet
2018/01/11 16:37:16 Client too slow
unable to write trailer
2018/01/11 16:37:16 encoder: 0 clients
2018/01/11 16:37:16 192.168.1.148:57366: Read error: EOF
2018/01/11 16:37:16 192.168.1.148:57366: Client cleaned up
2018/01/11 16:37:16 encoder: Closed input
2018/01/11 16:37:16 encoder: Waiting for clients...
Can u dockerize this app?
Hi, building on current, up-to-date OctoPi version. Just followed the instructions for Videostreamer, get this deprecated error:
pi@octopi:~ $ go get github.com/horgh/videostreamer
github.com/horgh/videostreamer
videostreamer.c: In function ‘vs_setup’:
videostreamer.c:29:2: warning: ‘av_register_all’ is deprecated [-Wdeprecated-declarations]
av_register_all();
^~~~~~~~~~~~~~~
In file included from /usr/include/arm-linux-gnueabihf/libavdevice/avdevice.h:51,
from videostreamer.c:12:
/usr/include/arm-linux-gnueabihf/libavformat/avformat.h:2043:6: note: declared here
void av_register_all(void);
^~~~~~~~~~~~~~~
pi@octopi:~ $
pi@ender1:~ $ go get github.com/horgh/videostreamer
videostreamer.c: In function ‘vs_setup’:
videostreamer.c:29:2: warning: ‘av_register_all’ is deprecated [-Wdeprecated-dec larations]
av_register_all();
^~~~~~~~~~~~~~~
In file included from /usr/include/arm-linux-gnueabihf/libavdevice/avdevice.h:51 ,
from videostreamer.c:12:
/usr/include/arm-linux-gnueabihf/libavformat/avformat.h:2043:6: note: declared h ere
void av_register_all(void);
^~~~~~~~~~~~~~~
Hello,
Compile on ubuntu produces error:
could not determine kind of name for C.av_packet_clone
could not determine kind of name for C.av_packet_free
could not determine kind of name for C.av_packet_unref
I install packages: libavcodec-dev, libavutil-dev, libavformat-dev
Any idea what could be the issue?
Thanks!
I got it running well enough. I'm using it to monitor my 3d printer using octoprint. I had to use a plugin to get octoprint to be able to read the feed but that's working now. The problem I'm running into is that the stream seem to stop without warning, though maybe the lack of warning is because I have videostreamer set to run as a service? Is there some sort of timeout in the code that I'm not seeing?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.