klaxa / mkvserver_mk2 Goto Github PK
View Code? Open in Web Editor NEWThe streaming solution to end all streaming problems
License: GNU General Public License v3.0
The streaming solution to end all streaming problems
License: GNU General Public License v3.0
I get a URL read error: -57 most of the time if I leave it running too long, sometimes if I refresh the url (with port included) specified in server2.c. This also sometimes occurs if the browser download prompt is cancelled. This happened sporadically as it happens almost every other time I test. Sometimes, while not downloading, the error just occurs while the tab wasn't open. When this error occurs, the server shutsdown and needs to be restarted. I was testing this on a Firefox client on installed on Windows 7 and the server is FreeBSD 12.0 where the executable was compiled as well.
This is some of the output I get before the error occurs. The error -54 error you see is due to cancelling the download prompt:
http://web.archive.org/save/https://pastebin.com/7E3aamiw
EDIT: I tested streaming with VLC and it gave the error after jumping forward in time while streaming.
How can I change the port used to stream?
I want to serve many files from the same server...can't do that without using a different port
Thanks!
Instead of -c libx264
use -codec:v libx264
.
helios@helios-PowerEdge-R7425:~/mkvserver_mk2$ ./server SampleVideo_1280x720_1mb.mkv
{
"free": 16,
"reserved": 0,
"wait": 0,
"writable": 0,
"busy": 0
"buffer_full": 0
"current_read": -1
"newest_write": 0
"oldest_write": -1
}
Accepting new clients...
[mpeg4 @ 0x1e81f80] Failed to parse extradata
Finding video stream.
Checking stream 0
Got stream
Got params
Got type
starting new segment
Initializing segment
Initialized segment.
segment id = 0
On all of these OSes I get build errors. For example, in 18.04 I get
cc -g -Wall `pkg-config --cflags libavformat libavcodec libavutil` `pkg-config --libs libavformat libavcodec libavutil` -pthread -o server segment.o buffer.o publisher.o server2.c
server2.c: In function ‘accept_thread’:
server2.c:301:66: warning: passing argument 4 of ‘av_opt_get’ from incompatible pointer type [-Wincompatible-pointer-types]
av_opt_get(client, "method", AV_OPT_SEARCH_CHILDREN, &method);
^
In file included from server2.c:8:0:
/usr/include/x86_64-linux-gnu/libavutil/opt.h:737:5: note: expected ‘uint8_t ** {aka unsigned char **}’ but argument is of type ‘char **’
int av_opt_get (void *obj, const char *name, int search_flags, uint8_t **out_val);
^~~~~~~~~~
server2.c:302:68: warning: passing argument 4 of ‘av_opt_get’ from incompatible pointer type [-Wincompatible-pointer-types]
av_opt_get(client, "resource", AV_OPT_SEARCH_CHILDREN, &resource);
^
In file included from server2.c:8:0:
/usr/include/x86_64-linux-gnu/libavutil/opt.h:737:5: note: expected ‘uint8_t ** {aka unsigned char **}’ but argument is of type ‘char **’
int av_opt_get (void *obj, const char *name, int search_flags, uint8_t **out_val);
^~~~~~~~~~
segment.o: In function `av_make_error_string':
/usr/include/x86_64-linux-gnu/libavutil/error.h:111: undefined reference to `av_strerror'
segment.o: In function `segment_free':
/root/t/mkvserver_mk2-master/segment.c:18: undefined reference to `avformat_free_context'
/root/t/mkvserver_mk2-master/segment.c:19: undefined reference to `av_free'
/root/t/mkvserver_mk2-master/segment.c:20: undefined reference to `av_free'
segment.o: In function `segment_close':
/root/t/mkvserver_mk2-master/segment.c:95: undefined reference to `av_write_trailer'
segment.o: In function `segment_init':
/root/t/mkvserver_mk2-master/segment.c:118: undefined reference to `av_malloc'
/root/t/mkvserver_mk2-master/segment.c:121: undefined reference to `avio_alloc_context'
/root/t/mkvserver_mk2-master/segment.c:123: undefined reference to `avformat_alloc_output_context2'
/root/t/mkvserver_mk2-master/segment.c:124: undefined reference to `av_opt_set_int'
/root/t/mkvserver_mk2-master/segment.c:137: undefined reference to `avcodec_alloc_context3'
/root/t/mkvserver_mk2-master/segment.c:138: undefined reference to `avcodec_parameters_to_context'
/root/t/mkvserver_mk2-master/segment.c:139: undefined reference to `avformat_new_stream'
/root/t/mkvserver_mk2-master/segment.c:141: undefined reference to `avcodec_free_context'
/root/t/mkvserver_mk2-master/segment.c:146: undefined reference to `avcodec_parameters_copy'
/root/t/mkvserver_mk2-master/segment.c:151: undefined reference to `av_dict_copy'
/root/t/mkvserver_mk2-master/segment.c:160: undefined reference to `avformat_write_header'
/root/t/mkvserver_mk2-master/segment.c:161: undefined reference to `avio_flush'
publisher.o: In function `client_disconnect':
/root/t/mkvserver_mk2-master/publisher.c:34: undefined reference to `av_write_trailer'
/root/t/mkvserver_mk2-master/publisher.c:35: undefined reference to `avio_close'
/root/t/mkvserver_mk2-master/publisher.c:36: undefined reference to `avformat_free_context'
/tmp/ccDCmLsD.o: In function `av_make_error_string':
/usr/include/x86_64-linux-gnu/libavutil/error.h:111: undefined reference to `av_strerror'
/tmp/ccDCmLsD.o: In function `read_thread':
/root/t/mkvserver_mk2-master/server2.c:64: undefined reference to `avformat_find_stream_info'
/root/t/mkvserver_mk2-master/server2.c:76: undefined reference to `avcodec_alloc_context3'
/root/t/mkvserver_mk2-master/server2.c:79: undefined reference to `avcodec_parameters_to_context'
/root/t/mkvserver_mk2-master/server2.c:94: undefined reference to `av_gettime_relative'
/root/t/mkvserver_mk2-master/server2.c:98: undefined reference to `av_read_frame'
/root/t/mkvserver_mk2-master/server2.c:109: undefined reference to `av_rescale_q'
/root/t/mkvserver_mk2-master/server2.c:110: undefined reference to `av_gettime_relative'
/root/t/mkvserver_mk2-master/server2.c:115: undefined reference to `av_gettime_relative'
/root/t/mkvserver_mk2-master/server2.c:132: undefined reference to `av_write_frame'
/root/t/mkvserver_mk2-master/server2.c:133: undefined reference to `av_packet_unref'
/root/t/mkvserver_mk2-master/server2.c:146: undefined reference to `avformat_close_input'
/tmp/ccDCmLsD.o: In function `write_segment':
/root/t/mkvserver_mk2-master/server2.c:178: undefined reference to `avformat_alloc_context'
/root/t/mkvserver_mk2-master/server2.c:184: undefined reference to `av_malloc'
/root/t/mkvserver_mk2-master/server2.c:185: undefined reference to `avio_alloc_context'
/root/t/mkvserver_mk2-master/server2.c:188: undefined reference to `avformat_open_input'
/root/t/mkvserver_mk2-master/server2.c:191: undefined reference to `av_free'
/root/t/mkvserver_mk2-master/server2.c:194: undefined reference to `avformat_find_stream_info'
/root/t/mkvserver_mk2-master/server2.c:197: undefined reference to `av_free'
/root/t/mkvserver_mk2-master/server2.c:202: undefined reference to `av_read_frame'
/root/t/mkvserver_mk2-master/server2.c:211: undefined reference to `av_write_frame'
/root/t/mkvserver_mk2-master/server2.c:212: undefined reference to `av_packet_unref'
/root/t/mkvserver_mk2-master/server2.c:215: undefined reference to `avformat_close_input'
/root/t/mkvserver_mk2-master/server2.c:216: undefined reference to `av_free'
/root/t/mkvserver_mk2-master/server2.c:222: undefined reference to `avformat_close_input'
/root/t/mkvserver_mk2-master/server2.c:223: undefined reference to `av_free'
/root/t/mkvserver_mk2-master/server2.c:224: undefined reference to `avformat_free_context'
/root/t/mkvserver_mk2-master/server2.c:225: undefined reference to `avio_context_free'
/tmp/ccDCmLsD.o: In function `accept_thread':
/root/t/mkvserver_mk2-master/server2.c:250: undefined reference to `av_dict_set'
/root/t/mkvserver_mk2-master/server2.c:255: undefined reference to `av_dict_set_int'
/root/t/mkvserver_mk2-master/server2.c:260: undefined reference to `av_dict_set_int'
/root/t/mkvserver_mk2-master/server2.c:265: undefined reference to `avio_open2'
/root/t/mkvserver_mk2-master/server2.c:279: undefined reference to `avio_accept'
/root/t/mkvserver_mk2-master/server2.c:291: undefined reference to `av_dict_set'
/root/t/mkvserver_mk2-master/server2.c:301: undefined reference to `av_opt_get'
/root/t/mkvserver_mk2-master/server2.c:302: undefined reference to `av_opt_get'
/root/t/mkvserver_mk2-master/server2.c:300: undefined reference to `avio_handshake'
/root/t/mkvserver_mk2-master/server2.c:318: undefined reference to `av_opt_set_int'
/root/t/mkvserver_mk2-master/server2.c:319: undefined reference to `av_log'
/root/t/mkvserver_mk2-master/server2.c:325: undefined reference to `avio_close'
/root/t/mkvserver_mk2-master/server2.c:330: undefined reference to `avio_close'
/root/t/mkvserver_mk2-master/server2.c:334: undefined reference to `avformat_alloc_output_context2'
/root/t/mkvserver_mk2-master/server2.c:348: undefined reference to `avcodec_alloc_context3'
/root/t/mkvserver_mk2-master/server2.c:349: undefined reference to `avcodec_parameters_to_context'
/root/t/mkvserver_mk2-master/server2.c:350: undefined reference to `avformat_new_stream'
/root/t/mkvserver_mk2-master/server2.c:351: undefined reference to `avcodec_free_context'
/root/t/mkvserver_mk2-master/server2.c:357: undefined reference to `avcodec_parameters_copy'
/root/t/mkvserver_mk2-master/server2.c:362: undefined reference to `av_dict_copy'
/root/t/mkvserver_mk2-master/server2.c:370: undefined reference to `avformat_write_header'
/root/t/mkvserver_mk2-master/server2.c:381: undefined reference to `avio_close'
/tmp/ccDCmLsD.o: In function `main':
/root/t/mkvserver_mk2-master/server2.c:440: undefined reference to `av_register_all'
/root/t/mkvserver_mk2-master/server2.c:441: undefined reference to `avformat_network_init'
/root/t/mkvserver_mk2-master/server2.c:443: undefined reference to `avformat_open_input'
collect2: error: ld returned 1 exit status
Makefile:11: recipe for target 'server' failed
make: *** [server] Error 1
Is there any more detail on what OS or what ffmpeg version I should be using? Readme just says ffmpeg should be "recent".
Hi I’m looking for a RTSP server on MIPS architecture, I’v tried ffserver. On ffserver, it takes about 5% of CPU for every channel. It’s pretty high. Is there alternative ?
Thanks!
When i tried to compile, i can't do that, this is what i get when i try it.
segment.h:4:34: fatal error: libavformat/avformat.h: No such file or directory
Thank you very much for this project!
I would like to create web page and display the stream generated by this server but currently I don't how. I use the last example (I had to add -f matroska
to ffmpeg call) and in server output I don't see any hints how to consume the stream -- I am not even sure if the stream is correctly created, because I see periodically "Error or timeout, ret: -110" error.
So, my question is -- what is the minimal setup/example to consume the stream?
I have tried with a local mkv and it work great.
I have tried with a remote mkv (http://****.mkv) and it work great.
I have an online video stream that seems to start ok but playback never starts in VLC (it also never seems to time out).
Here is the FFMPEG output:
Duration: N/A, start: 20541.882667, bitrate: N/A
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 704x576 [SAR 16:11 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1[0x101](eng): Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 66 kb/s
Any ideas how to fix this or why it won't work?
Thanks a lot for sharing this, much useful now that ffserver is gone.
Could you please add an open-source software license to your code? Check out: https://choosealicense.com/
Without a license, as it is, all your code is under copyright, which means that no one can copy, distribute or modify it.
I get the following error when trying to compile on Ubuntu 16.04 or Centos 7 after running make.
`cc -g -Wall `pkg-config --cflags libavformat libavcodec libavutil` -pthread -c segment.c
segment.c: In function ‘segment_init’:
segment.c:138:13: warning: implicit declaration of function ‘avcodec_parameters_to_context’ [-Wimplicit-function-declaration]
avcodec_parameters_to_context(codec_ctx, in_stream->codecpar);
^
segment.c:138:63: error: ‘AVStream’ has no member named ‘codecpar’
avcodec_parameters_to_context(codec_ctx, in_stream->codecpar);
^
segment.c:146:13: warning: implicit declaration of function ‘avcodec_parameters_copy’ [-Wimplicit-function-declaration]
ret = avcodec_parameters_copy(out_stream->codecpar, in_stream->codecpar);
^
segment.c:146:53: error: ‘AVStream’ has no member named ‘codecpar’
ret = avcodec_parameters_copy(out_stream->codecpar, in_stream->codecpar);
^
segment.c:146:74: error: ‘AVStream’ has no member named ‘codecpar’
ret = avcodec_parameters_copy(out_stream->codecpar, in_stream->codecpar);
^
make: *** [segment.o] Error 1`
I found your software googling about ffserver...seems to be a awesome software...but I can't build it?
I cloned the repo, but when I do make
:
cc -g -Wall `pkg-config --cflags libavformat libavcodec libavutil` -pthread -c segment.c
Package libavformat was not found in the pkg-config search path.
Perhaps you should add the directory containing `libavformat.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libavformat' found
Package libavcodec was not found in the pkg-config search path.
Perhaps you should add the directory containing `libavcodec.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libavcodec' found
Package libavutil was not found in the pkg-config search path.
Perhaps you should add the directory containing `libavutil.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libavutil' found
In file included from segment.c:2:0:
segment.h:4:10: fatal error: libavformat/avformat.h: No such file or directory
#include <libavformat/avformat.h>
^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Makefile:15: recipe for target 'segment.o' failed
make: *** [segment.o] Error 1
This software seems to be the perfect software to put into a docker container. I could help with that if you give me instructions...
weiwang99@cs000061:/ffmpeg-4.1.3$ ffmpeg -f x11grab -framerate 15 -s 1920x1080 -i :0.0 -c libx264 tcp://remote:1234516.04.11) 20160609
ffmpeg version 4.1.3 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1
configuration: --enable-libxcb
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
[x11grab @ 0x2ced5c0] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, x11grab, from ':0.0':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1920x1080, 15 fps, 1000k tbr, 1000k tbn, 1000k tbc
[NULL @ 0x2cf5500] Unable to find a suitable output format for 'tcp://remote:12345'
tcp://remote:12345: Invalid argument
Hello,
I have try you server, and with vlc and ffplay I'm able to play the stream. But I would like to embed the stream to. Is this possible?, with something like this:
<video id="myStream" class="video-js">
<source src="http://192.168.0.91:8080" type="application/x-mpegURL">
</video>
helios@helios-PowerEdge-R7425:~/mkvserver_mk2$ ./server SampleVideo_360x240_30mb.mkv
{
"free": 16,
"reserved": 0,
"wait": 0,
"writable": 0,
"busy": 0
"buffer_full": 0
"current_read": -1
"newest_write": 0
"oldest_write": -1
}
Accepting new clients...
Finding video stream.
Checking stream 0
Got stream
Got params
Got type
starting new segment
Initializing segment
Initialized segment.
segment id = 0
[matroska @ 0x7faa2c041840] Application provided invalid, non monotonically increasing dts to muxer in stream 1: 2261 >= 5
write frame failed
[matroska @ 0x7faa2c041840] Application provided invalid, non monotonically increasing dts to muxer in stream 1: 2261 >= 27
write frame failed
[matroska @ 0x7faa2c041840] Application provided invalid, non monotonically increasing dts to muxer in stream 1: 2261 >= 48
write frame failed
[matroska @ 0x7faa2c041840] Application provided invalid, non monotonically increasing dts to muxer in stream 1: 2261 >= 69
write frame failed
[matroska @ 0x7faa2c041840] Application provided invalid, non monotonically increasing dts to muxer in stream 1: 2261 >= 91
write frame failed
[matroska @ 0x7faa2c041840] Application provided invalid, non monotonically increasing dts to muxer in stream 1: 2261 >= 112
write frame failed
[matroska @ 0x7faa2c041840] Application provided invalid, non monotonically increasing dts to muxer in stream 1: 2261 >= 133
write frame failed
[matroska @ 0x7faa2c041840] Application provided invalid, non monotonically increasing dts to muxer in stream 1: 2261 >= 155
write frame failed
[matroska @ 0x7faa2c041840] Application provided invalid, non monotonically increasing dts to muxer in stream 1: 2261 >= 176
write frame failed
[matroska @ 0x7faa2c041840] Application provided invalid, non monotonically increasing dts to muxer in stream 1: 2261 >= 197
write frame failed
[matroska @ 0x7faa2c041840] Application provided invalid, non monotonically increasing dts to muxer in stream 1: 2261 >= 219
write frame failed
[matroska @ 0x7faa2c041840] Application provided invalid, non monotonically increasing dts to muxer in stream 1: 2261 >= 240
write frame failed
[matroska @ 0x7faa2c041840] Application provided invalid, non monotonically increasing dts to muxer in stream 1: 2261 >= 261
write frame failed
[matroska @ 0x7faa2c041840] Application provided invalid, non monotonically increasing dts to muxer in stream 1: 2261 >= 283
write frame failed
[matroska @ 0x7faa2c041840] Application provided invalid, non monotonically increasing dts to muxer in stream 1: 2261 >= 304
I'm trying to set up ffmpeg
on a Raspberry Pi 3B+ to record 2 USB webcams (/dev/video0
and /dev/video1
) to disk and simultaneously stream them live to connected web browsers (presumably using <video>
elements). ffserver
sounds like what I need, except it appears to be discontinued. Can mkvserver_mk2
do this? How would I set it up?
I'm wondering why ffserver
is no longer offered, as it seems like it filled a common need.
Environment:
Ubuntu 16.04
Ffmpeg latest
Gdb debug info:
Checking clients, thread: 0
Checking clients, thread: 1
Checking clients, thread: 3
Checking clients, thread: 2
279 if ((ret = avio_accept(server, &client)) < 0) {
Checking clients, thread: 2
Checking clients, thread: 1
Checking clients, thread: 3
Checking clients, thread:
Finding video stream.
Checking stream 0
Got stream
Got params
Got type
startlng new segment
Initializing segment
Thread 2 "server" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff4120700 (LWP 1781)]
_memcpy_avx_unaligned () at ../sysdeps/x86_64/multiarch/memcpy-avx-unaligned.S:238
238 ../sysdeps/x86_64/multiarch/memcpy-avx-unaligned.S: No such file or directory.
(gdb) bt
_memcpy_avx_unaligned () at ../sysdeps/x86_64/multiarch/memcpy-avx-unaligned.S:238
0x00007ffff692cb24 in avcodec_parameters_to_context () from /usr/local/lib/libavcodec.so.58
0x0000000000401f21 in segment_init (seg_p=0x7ffff411fe50, fmt=0x607040) at segment.c:138
0x00000000004033d5 in read_thread (arg=0x7fffffffe410) at server2.c:126
0x00007ffff5c3d6ba in start_thread (arg=0x7ffff 4120700) at pthread_create.c:333
0x00007ffff597341d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
I'm filing this as a documentation bug, rather than a bug with the code, which I assume supports this.
I am / was considering using this project for a near-realtime streaming application, but I'm seeing lag of about 60 seconds between the source (screen recording with ffmpeg) and seeing the result on VLC. So far as I can tell, almost none of this is network lag. I've tried tinkering with the buffering constants in the source without success. Is there any way to get lag down below 5 seconds or so?
cc -g -Wall `pkg-config --cflags libavformat libavcodec libavutil` -pthread -c segment.c
cc -g -Wall `pkg-config --cflags libavformat libavcodec libavutil` -pthread -c buffer.c
cc -g -Wall `pkg-config --cflags libavformat libavcodec libavutil` -pthread -c publisher.c
#cc -g -Wall `pkg-config --cflags libavformat libavcodec libavutil` `pkg-config --libs libavformat libavcodec libavutil` -pthread -o server segment.o buffer.o publisher.o server2.c
cc -g -Wall `pkg-config --cflags libavformat libavcodec libavutil` -pthread -o server segment.o buffer.o publisher.o server2.c `pkg-config --libs libavformat libavcodec libavutil`
server2.c: In function ‘accept_thread’:
server2.c:301:66: warning: passing argument 4 of ‘av_opt_get’ from incompatible pointer type [-Wincompatible-pointer-types]
301 | av_opt_get(client, "method", AV_OPT_SEARCH_CHILDREN, &method);
| ^~~~~~~
| |
| char **
In file included from server2.c:8:
/usr/include/x86_64-linux-gnu/libavutil/opt.h:757:84: note: expected ‘uint8_t **’ {aka ‘unsigned char **’} but argument is of type ‘char **’
757 | int av_opt_get (void *obj, const char *name, int search_flags, uint8_t **out_val);
| ~~~~~~~~~~~~^~~~~~~
server2.c:302:68: warning: passing argument 4 of ‘av_opt_get’ from incompatible pointer type [-Wincompatible-pointer-types]
302 | av_opt_get(client, "resource", AV_OPT_SEARCH_CHILDREN, &resource);
| ^~~~~~~~~
| |
| char **
In file included from server2.c:8:
/usr/include/x86_64-linux-gnu/libavutil/opt.h:757:84: note: expected ‘uint8_t **’ {aka ‘unsigned char **’} but argument is of type ‘char **’
757 | int av_opt_get (void *obj, const char *name, int search_flags, uint8_t **out_val);
| ~~~~~~~~~~~~^~~~~~~
server2.c: In function ‘main’:
server2.c:440:5: warning: ‘av_register_all’ is deprecated [-Wdeprecated-declarations]
440 | av_register_all();
| ^~~~~~~~~~~~~~~
In file included from server2.c:9:
/usr/include/x86_64-linux-gnu/libavformat/avformat.h:1955:6: note: declared here
1955 | void av_register_all(void);
| ^~~~~~~~~~~~~~~
Good day, dears.
Could you please advice me with following situation ?
After step 'Make' i got few errors:
Log:
segment.c:108:5: error: must use 'struct' tag to refer to type 'AVCodecContext'
AVCodecContext *codec_ctx;
^
struct
segment.c:111:15: warning: assigning to 'AVInputFormat *' (aka 'struct AVInputFormat *') from 'const struct AVInputFormat *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
seg->ifmt = fmt->iformat;
^ ~~~~~~~~~~~~
segment.c:129:34: error: cannot assign to non-static data member 'oformat' with const-qualified type 'const struct AVOutputFormat *'
seg->fmt_ctx->oformat->flags &= AVFMT_NOFILE;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
/opt/homebrew/Cellar/ffmpeg/5.0/include/libavformat/avformat.h:1221:34: note: non-static data member 'oformat' declared const here
const struct AVOutputFormat *oformat;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
segment.c:137:25: error: implicit declaration of function 'avcodec_alloc_context3' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
codec_ctx = avcodec_alloc_context3(NULL);
^
segment.c:137:25: note: did you mean 'avio_alloc_context'?
/opt/homebrew/Cellar/ffmpeg/5.0/include/libavformat/avio.h:409:14: note: 'avio_alloc_context' declared here
AVIOContext *avio_alloc_context(
^
segment.c:137:23: warning: incompatible integer to pointer conversion assigning to 'struct AVCodecContext *' from 'int' [-Wint-conversion]
codec_ctx = avcodec_alloc_context3(NULL);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
segment.c:138:13: error: implicit declaration of function 'avcodec_parameters_to_context' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
avcodec_parameters_to_context(codec_ctx, in_stream->codecpar);
^
segment.c:138:13: note: did you mean 'avcodec_parameters_copy'?
/opt/homebrew/Cellar/ffmpeg/5.0/include/libavcodec/codec_par.h:222:5: note: 'avcodec_parameters_copy' declared here
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src);
^
segment.c:139:69: error: incomplete definition of type 'struct AVCodecContext'
out_stream = avformat_new_stream(seg->fmt_ctx, codec_ctx->codec);
~~~~~~~~~^
/opt/homebrew/Cellar/ffmpeg/5.0/include/libavcodec/codec.h:195:8: note: forward declaration of 'struct AVCodecContext'
struct AVCodecContext;
^
segment.c:141:13: error: implicit declaration of function 'avcodec_free_context' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
avcodec_free_context(&codec_ctx);
^
segment.c:141:13: note: did you mean 'avformat_free_context'?
/opt/homebrew/Cellar/ffmpeg/5.0/include/libavformat/avformat.h:1903:6: note: 'avformat_free_context' declared here
void avformat_free_context(AVFormatContext *s);
^
2 warnings and 6 errors generated.
make: *** [segment.o] Error 1
How can i fix it? I have succesfully installed "ffmpeg" via Homebrew and not found "ffserver", and decided to install this software.
Just starting server
and running in gdb
:
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff615d3ef in av_strstart () from /usr/lib/x86_64-linux-gnu/libavutil.so.55
(gdb) bt
#0 0x00007ffff615d3ef in av_strstart () from /usr/lib/x86_64-linux-gnu/libavutil.so.55
#1 0x00007ffff6526845 in ?? () from /usr/lib/x86_64-linux-gnu/libavformat.so.57
#2 0x00007ffff64517fa in av_probe_input_format3 () from /usr/lib/x86_64-linux-gnu/libavformat.so.57
#3 0x00007ffff6451a72 in av_probe_input_format2 () from /usr/lib/x86_64-linux-gnu/libavformat.so.57
#4 0x00007ffff655f0ab in avformat_open_input () from /usr/lib/x86_64-linux-gnu/libavformat.so.57
#5 0x000055555555824f in main (argc=1, argv=0x7fffffffe3f8) at server2.c:440
On Debian stretch:
$ cat /etc/*-release file.
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
Great project :)
Is it possible to add support for building on Windows?
I'm trying to host a live stream on a website, but first testing by streaming a video file locally. However, trying to run it results in this ending the stream right after it starts. What is the fix for this? Thanks :)
I'm able to live stream webcam via ffmpeg
to mkvserver
On Client :
ffmpeg -f avfoundation -framerate 30 -i 0 -b 900k -f matroska -r 20 tcp://<ip-address>:<port-number>
On Server :
nc -l <port-number> | ./server
I've tried : ffplay tcp://<ip-address>:<port>
to view the stream but got the Connection timed out
error.
Please suggest a way to view the stream on the server.
Thanks for any help!
hi
i need add mpegts to server out and in server http
plz help me
Hello, I'm trying to implement a rtsp server with ffmpeg and I was wondering if your server suports rtsp.
Thanks.
This happens at the second segment being sent to a client. The buffer Client.avio_buffer of said client points to the address allocated in publisher.c:publisher_add_client(). This address is av_free()'d by avformat_open_input().
*** Error in `/home/klaxa/Development/mkvserver_mk2/server': double free or corruption (out): 0xb2500030 ***
Thread 3 "server" received signal SIGABRT, Aborted.
[Switching to Thread 0xb43ff450 (LWP 23775)]
0xb595d1d8 in raise () from /usr/lib/libc.so.6
(gdb) backtrace
#0 0xb595d1d8 in raise () from /usr/lib/libc.so.6
#1 0xb595e7d4 in abort () from /usr/lib/libc.so.6
#2 0xb5997bac in __libc_message () from /usr/lib/libc.so.6
#3 0xb599e74c in malloc_printerr () from /usr/lib/libc.so.6
#4 0xb59a037c in _int_free () from /usr/lib/libc.so.6
#5 0xb6de0744 in ffio_ensure_seekback (s=s@entry=0xb23b98f0, buf_size=-5597974130663063542) at libavformat/aviobuf.c:1015
#6 0xb6e2c020 in id3v2_read_internal (pb=0xb23b98f0, metadata=0xb6f22e24 <read_frame_internal+1052>, s=0xb250d420, s@entry=0x0,
magic=0x1 <error: Cannot access memory at address 0x1>, extra_meta=0xb43fed64, extra_meta@entry=0xb43fed0c, max_search_size=max_search_size@entry=0)
at libavformat/id3v2.c:1084
#7 0xb6e2d23c in id3v2_read_internal (max_search_size=0, extra_meta=extra_meta@entry=0xb43fed0c, magic=<optimized out>, s=0x0, metadata=<optimized out>,
pb=<optimized out>) at libavformat/id3v2.c:1111
#8 ff_id3v2_read_dict (pb=<optimized out>, metadata=<optimized out>, magic=<optimized out>, extra_meta=extra_meta@entry=0xb43fed5c) at libavformat/id3v2.c:1112
#9 0xb6f28734 in avformat_open_input (ps=0xb43fedbc, filename=0x0, fmt=<optimized out>, options=0x0) at libavformat/utils.c:609
#10 0x0040353c in write_segment (c=0x43dba8) at server2.c:188
#11 0x004040e0 in write_thread (arg=0x434130) at server2.c:398
#12 0xb5a7ceec in start_thread () from /usr/lib/libpthread.so.0
#13 0xb5a04588 in ?? () from /usr/lib/libc.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb)
Hello, I builded this repo in termux. arm cpu
Running the command tsudo ./server somevid.mkv
, I got this error:
[tcp @ 0xb4e79190] Failed to resolve hostname 0: No address associated with hostname
Is this normal?
If you need elaboration, I could reply.
Dropped segment from prebuffer buffer.
Freed buffer
Checking clients, thread: 0
Checking clients, thread: 3
Checking clients, thread: 1
Checking clients, thread: 2
Error or timeout
ret: -110
[http @ 0x2b300c0] URL read error: -107
Shut down http server.
unref Readers: 0
{
"free": 16,
"reserved": 0,
"wait": 0,
"writable": 0,
"busy": 0
"buffer_full": 0
"current_read": -1
"newest_write": 0
"oldest_write": -1
}
Accepting new clients...
Finding video stream.
Checking stream 0
Got stream
Got params
Got type
starting new segment
Initializing segment
[matroska @ 0x7f9401d330] Tag mp4a incompatible with output codec id '86018' ([255][0][0][0])
Error occured while writing header: Invalid data found when processing input
Initialized segment.
segment id = 0
Segmentation fault (core dumped)
Hello,
I'm using gstreamer to stream from v4l. Currently, it consumes about 40% CPU, regardless if somebody watches or not.
It would be nice to specify a command that is executed as soon as the first viewer connects, and is killed as soon as the last viewer disconnects.
I hope it's understandable what I mean..
Current:
/root/gstreamer.sh | /root/mkvserver_mk2/server
Proposal: Something like
/root/mkvserver_mk2/server --exec /root/gstreamer.sh --timeout 30
% freebsd-version
11.1-RELEASE-p6
ferz@w1:/tmp/mkvserver_mk2 % gmake
cc -g -Wall -I/usr/local/include -L/usr/local/lib -lavformat -lavcodec -lavutil -lpthread -c segment.c
cc: warning: -lavformat: 'linker' input unused [-Wunused-command-line-argument]
cc: warning: -lavcodec: 'linker' input unused [-Wunused-command-line-argument]
cc: warning: -lavutil: 'linker' input unused [-Wunused-command-line-argument]
cc: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
cc: warning: argument unused during compilation: '-L/usr/local/lib' [-Wunused-command-line-argument]
In file included from segment.c:2:
./segment.h:25:5: error: unknown type name 'pthread_mutex_t'
pthread_mutex_t nb_read_lock;
^
1 error generated.
gmake: *** [Makefile:9: segment.o] Error 1
Good afternoon
Hello Brother
I am trying to compile but the following error is being returned, can you help me please
$ make
#cc -g -Wall `pkg-config --cflags libavformat libavcodec libavutil` `pkg-config --libs libavformat libavcodec libavutil` -pthread -o server segment.o buffer.o publisher.o server2.c
cc -g -Wall `pkg-config --cflags libavformat libavcodec libavutil` -pthread -o server segment.o buffer.o publisher.o server2.c `pkg-config --libs libavformat libavcodec libavutil`
server2.c: In function ‘write_segment’:
server2.c:225:9: warning: implicit declaration of function ‘avio_context_free’ [-Wimplicit-function-declaration]
avio_context_free(&avio_ctx);
^~~~~~~~~~~~~~~~~
server2.c: In function ‘accept_thread’:
server2.c:301:66: warning: passing argument 4 of ‘av_opt_get’ from incompatible pointer type [-Wincompatible-pointer-types]
av_opt_get(client, "method", AV_OPT_SEARCH_CHILDREN, &method);
^
In file included from server2.c:8:0:
/usr/include/x86_64-linux-gnu/libavutil/opt.h:736:5: note: expected ‘uint8_t ** {aka unsigned char **}’ but argument is of type ‘char **’
int av_opt_get (void *obj, const char *name, int search_flags, uint8_t **out_val);
^~~~~~~~~~
server2.c:302:68: warning: passing argument 4 of ‘av_opt_get’ from incompatible pointer type [-Wincompatible-pointer-types]
av_opt_get(client, "resource", AV_OPT_SEARCH_CHILDREN, &resource);
^
In file included from server2.c:8:0:
/usr/include/x86_64-linux-gnu/libavutil/opt.h:736:5: note: expected ‘uint8_t ** {aka unsigned char **}’ but argument is of type ‘char **’
int av_opt_get (void *obj, const char *name, int search_flags, uint8_t **out_val);
^~~~~~~~~~
/tmp/cccoshgL.o: In function `write_segment':
/home/marcio/dados/mkvserver_mk2/server2.c:225: undefined reference to `avio_context_free'
collect2: error: ld returned 1 exit status
Makefile:11: recipe for target 'server' failed
make: *** [server] Error 1
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.