ireader / media-server Goto Github PK
View Code? Open in Web Editor NEWRTSP/RTP/RTMP/FLV/HLS/MPEG-TS/MPEG-PS/MPEG-DASH/MP4/fMP4/MKV/WebM
License: MIT License
RTSP/RTP/RTMP/FLV/HLS/MPEG-TS/MPEG-PS/MPEG-DASH/MP4/fMP4/MKV/WebM
License: MIT License
When I do make on the MAC,have a err !
make -C sdk/libaio && make -C sdk/libhttp && make -C media-server/libmpeg && make -C media-server/libflv && make -C media-server/libhls
gcc -I. -I./include -I../include -DOS_LINUX -DDEBUG -D_DEBUG -Wall -fPIC -g -Wall -fvisibility=hidden -fvisibility=default -c -MMD -MP -MF debug.linux/aio-accept.d -o src/aio-accept.o src/aio-accept.c
In file included from src/aio-accept.c:2:
../include/sys/locker.h:39:35: error: use of undeclared identifier 'PTHREAD_MUTEX_RECURSIVE_NP'
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
error: use of undeclared identifier 'PTHREAD_MUTEX_RECURSIVE_NP'
source/rtsp-reason.c:1:10: fatal error: 'http-reason.h' file not found
#include "http-reason.h"
^~~~~~~~~~~~~~~
1 error generated.
make[1]: *** [source/rtsp-reason.o] Error 1
make: *** [all] Error 2
./librtsp/source/rtsp-reason.c:31: return http_reason_phrase(code);
mpeg4_hevc_t结构体里 nalu.data 固定256
但遇到libx265编码,Prefix SEI 大大超出这个值,1800多字节,这里解析就错误了
我暂时设置了个大值
Hi,
I'm newbee for media streaming,
I want to know where can I find documents for your lib?
Thanks.
I see the make file include ../../sdk
folder。 but not found。
服务器使用srs
在test目录下执行make clean&make,出现../../sdk/gcc.mk:86: recipe for target '../librtsp/test/media/mp4-file-source.o' failed以下错误,如何解决
如内存或udp的视频流,我试着做了个live source,但是各种错
生成环境可以使用吗?
Hi.So I spent whole evening to build this thing. Media-server lib I built ok. But the 'sdk' on which it depends is not in the operable state. It has a lot of WinAPI old and deprecated functionality which is not even possible to build using Windows 10 SDK. Also its VS solution is broken. At the end I had to manually pull sources and build them,but it didn't work at the end. Total mess. It would be great if you could supply those dependencies as pre-compiled libs, or at least some CMake scripts to builds those properly
代码如下:
struct mpeg_ts_func_t tshandler[VENC_CHANNEL_NUM];
int chn[VENC_CHANNEL_NUM];
tshandler[i].alloc = ts_alloc;
tshandler[i].write = ts_write;
tshandler[i].free = ts_free;
void* ts = mpeg_ts_create(tshandler + i, chn + i);
mpeg_ts_write(ts, ts_stream(ts, STREAM_VIDEO_H264),isKeyFrame, cts , cts , pPacket->GetBuffer(), pPacket->GetLength());
只有一个mux能出数据。
调试了挺久,感觉和/proc/cpu/alignment这个有点关系 但是不太确定。
mpeg-ts-proto.h这个文件里的结构体定义有点怪怪的
struct ts_adaptation_field_t
{
unsigned int adaptation_field_length : 8;
unsigned int discontinuity_indicator : 1;
unsigned int random_access_indicator : 1;
unsigned int elementary_stream_priority_indicator : 1;
unsigned int PCR_flag : 1;
unsigned int OPCR_flag : 1;
unsigned int splicing_point_flag : 1;
unsigned int transport_private_data_flag : 1;
unsigned int adaptation_field_extension_flag : 1;
int64_t program_clock_reference_base; // 33-bits
unsigned int program_clock_reference_extension; // 9-bits
int64_t original_program_clock_reference_base; // 33-bits
unsigned int original_program_clock_reference_extension; // 9-bits
unsigned int splice_countdown : 8;
unsigned int transport_private_data_length : 8;
unsigned int adaptation_field_extension_length : 8;
unsigned int ltw_flag : 1;
unsigned int piecewise_rate_flag : 1;
unsigned int seamless_splice_flag : 1;
unsigned int ltw_valid_flag : 1;
unsigned int ltw_offset : 15;
unsigned int piecewise_rate : 22;
unsigned int Splice_type : 4;
int64_t DTS_next_AU;
};
hi ireader, I am testing suitablity of your mpeg ts code in my android app and I like what I see!
Just wondering why you cue the audio samples in mpeg_ts_test.cpp and then output them when a video packet is detected?
static void ts_packet(void* param, int avtype, int64_t pts, int64_t dts, void* data, size_t bytes)
{
struct mpeg_ts_test_t* ctx = (struct mpeg_ts_test_t*)param;
char s_char[] = { ' ', 'A', 'V', 'a', 'v' };
printf("[%c] pts: %08lu, dts: %08lu\n", s_char[avtype], (unsigned long)pts, (unsigned long)dts);
if (PSI_STREAM_AAC == avtype)
{
std::auto_ptr<char> ptr(new char[bytes]);
memcpy(ptr.get(), data, bytes);
ctx->audios.push_back(mpeg_ts_test_t::audio(ptr, bytes, pts, dts));
}
else if (PSI_STREAM_H264 == avtype)
{
while (!ctx->audios.empty())
{
const mpeg_ts_test_t::audio& audio = ctx->audios.front();
if (audio.dts > dts)
break;
mpeg_ts_write(ctx->ts, PSI_STREAM_AAC, audio.pts, audio.dts, audio.data.get(), audio.bytes);
ctx->audios.pop_front();
}
mpeg_ts_write(ctx->ts, avtype, pts, dts, data, bytes);
}
else
{
assert(0);
}
}
source/rtsp-reason.c:1:25: 致命错误:http-reason.h:没有那个文件或目录
Hi!
Could you give me this ('live555-surfing.h265.rtp') file?
make -C sdk/libaio && make -C sdk/libhttp && make -C media-server/libmpeg && make -C media-server/libflv && make -C media-server/libhls
gcc -I. -I./include -I../include -DOS_LINUX -DDEBUG -D_DEBUG -Wall -fPIC -g -Wall -fvisibility=hidden -fvisibility=default -c -MMD -MP -MF debug.linux/aio-connect.d -o src/aio-connect.o src/aio-connect.c
In file included from ../include/sockutil.h:4:0,
from src/aio-connect.c:6:
../include/sys/sock.h: 在函数‘socket_select_read’中:
../include/sys/sock.h:427:16: 错误:‘fds’的存储大小未知
struct pollfd fds;
^
../include/sys/sock.h:430:15: 错误:‘POLLIN’未声明(在此函数内第一次使用)
fds.events = POLLIN;
^
../include/sys/sock.h:430:15: 附注:每个未声明的标识符在其出现的函数内只报告一次
../include/sys/sock.h:433:2: 警告:隐式声明函数‘poll’ [-Wimplicit-function-declaration]
r = poll(&fds, 1, timeout);
^
../include/sys/sock.h:427:16: 警告:未使用的变量‘fds’ [-Wunused-variable]
struct pollfd fds;
^
../include/sys/sock.h: 在函数‘socket_select_write’中:
../include/sys/sock.h:456:16: 错误:‘fds’的存储大小未知
struct pollfd fds;
^
../include/sys/sock.h:459:15: 错误:‘POLLOUT’未声明(在此函数内第一次使用)
fds.events = POLLOUT;
^
../include/sys/sock.h:456:16: 警告:未使用的变量‘fds’ [-Wunused-variable]
struct pollfd fds;
^
../include/sys/sock.h: 在函数‘socket_addr_compare’中:
../include/sys/sock.h:984:45: 错误:invalid application of ‘sizeof’ to incomplete type ‘struct sockaddr_un’
case AF_UNIX: return memcmp(sa, sb, sizeof(struct sockaddr_un));
^
fmp4_writer_test fmp4 aac audio play no voice
fmp4_writer_test 320x240 run fail
从github下载依赖的sdk目录,与media-server平级
git clone https://github.com/ireader/sdk sdk
分别编译libaio/libhttp/libmpeg/libflv/libhls
make -C sdk/libaio && make -C sdk/libhttp && make -C media-server/libmpeg && make -C media-server/libflv && make -C media-server/libhls
cd media-server/libhls/test目录下执行make
第三部没有测试代码, 请作者提供一份,cd media-server/libhls/test
I want to use rtsp server,but i don't know how to use the librtsp,can you help me?thanks!
size_t psm_write(const struct psm_t *psm, uint8_t *data)
{
。。。。。。
// elementary_stream_map_length 16-bits
// elementary_stream_map_length not include CRC32
// nbo_w16(data+10, (uint16_t)(j-12+4));
nbo_w16(data+10, (uint16_t)(j-12)) ;
// program_stream_map_length:16
nbo_w16(data+4, (uint16_t)(j-6+4)); // 4-bytes crc32
// crc32
crc = mpeg_crc32(0xffffffff, data, (uint32_t)j);
data[j+3] = (uint8_t)((crc >> 24) & 0xFF);
data[j+2] = (uint8_t)((crc >> 16) & 0xFF);
data[j+1] = (uint8_t)((crc >> 8) & 0xFF);
data[j+0] = (uint8_t)(crc & 0xFF);
return j+4;
}
Hi.
Try to convert h265 video to fragmented mp4 does to infinite loop (nalu pointer doesnt change)
Maybe you mean something like this
if (hevc.numOfArrays < 1) {
nalu = nalu2;
continue; // wait for key frame
}
?
But in any case result video is not fragmented... ((
ubuntu@ip-172-31-93-66:~/media-server-build/media-server/libhls/demo$ make
/bin/sh: bc: command not found
g++ -I. -I../include -I../../libmpeg/include -I../../libflv/include -I../../../sdk/include -I../../../sdk/libhttp/include -I../../../sdk/libaio/include -D_HLS_SERVER_TEST_ -DOS_LINUX -DDEBUG -D_DEBUG -Wall -Wall -fPIC -g -Wall -fvisibility=hidden -c -MMD -MP -MF debug.linux/hls-server.d -o hls-server.o hls-server.cpp
hls-server.cpp:31:10: error: ‘atomic’ in namespace ‘std’ does not name a template type
std::atomic ref;
^
hls-server.cpp: In function ‘int hls_handler(void*, const void*, size_t, int64_t, int64_t, int64_t)’:
hls-server.cpp:72:6: error: ‘struct hls_ts_t’ has no member named ‘ref’
ts->ref = 1;
^
hls-server.cpp:84:18: error: ‘atomic_fetch_sub’ is not a member of ‘std’
if (0 == std::atomic_fetch_sub(&ts->ref, 1) - 1)
^
hls-server.cpp:84:45: error: ‘struct hls_ts_t’ has no member named ‘ref’
if (0 == std::atomic_fetch_sub(&ts->ref, 1) - 1)
^
hls-server.cpp: In function ‘int hls_server_ts_onsend(void*, int, size_t)’:
hls-server.cpp:178:14: error: ‘atomic_fetch_sub’ is not a member of ‘std’
if (0 == std::atomic_fetch_sub(&ts->ref, 1) - 1)
^
hls-server.cpp:178:41: error: ‘struct hls_ts_t’ has no member named ‘ref’
if (0 == std::atomic_fetch_sub(&ts->ref, 1) - 1)
^
hls-server.cpp: In function ‘int hls_server_ts(http_session_t*, const string&, const string&)’:
hls-server.cpp:198:13: error: ‘atomic_fetch_add’ is not a member of ‘std’
std::atomic_fetch_add(&ts->ref, 1);
^
hls-server.cpp:198:40: error: ‘struct hls_ts_t’ has no member named ‘ref’
std::atomic_fetch_add(&ts->ref, 1);
^
../../gcc.mk:86: recipe for target 'hls-server.o' failed
make: *** [hls-server.o] Error 1
TODO RFC-7826
pts和dts时间戳是毫秒单位吗?如果是30帧,pts和dts是33.3,但这里填整数,要怎么处理?
flv_muxer_h264_nalu(m, nalu, next - nalu, pts, dts);
uint8_t type = *nalu & 0x1f;
if (type > 0 && type < 6)
{
pts += 40;
dts += 40;
}
Code is as below:
int main(int argc, char* argv[])
{
socket_init();
rtmp_server_forward_aio_test("192.168.0.73", 1935);
socket_cleanup();
return 0;
}
I use rtmp client to push to rtmp://192.168.0.73/live/test, seems ok
But I failed to play rtmp://192.168.0.73/live/test using another rtmp flash player.
and the program run-into Assert usually.
可以用在Linux上做rstp服务器吗?
CentOS上如何编译运行呢?
arm-hisiv100nptl-linux-ar: Command not found
mpeg-s-enc.c line 86
// write system_header(p76)
if(0 == (ps->psm_period % 30))
i += system_header_write(&ps->system, packet + i);
// write program_stream_map(p79)
if(0 == (ps->psm_period % 30))
i += psm_write(&ps->psm, packet + i);
EasyICE查看文件显示的信息:
CRC 错误,共 2 次.
其中:
CRC 错误出现在 PAT 表中,有 2 次.
CRC 错误出现在 CAT 表中,有 0 次.
CRC 错误出现在 PMT 表中,有 0 次.
CRC 错误出现在 NIT 表中,有 0 次.
CRC 错误出现在 SDT 表中,有 0 次.
CRC 错误出现在 BAT 表中,有 0 次.
CRC 错误出现在 TOT 表中,有 0 次.
CRC 错误出现在 EIT 表中,有 0 次.
调用的源码:
struct mpeg_ts_func_t h;
h.alloc=mpegalloc;
h.free=mpegfree;
h.write=mpegwrite;
void* param;
ts=mpeg_ts_create(&h,param);
const char* cpath=(*env)->GetStringUTFChars(env,path,0);
file=open(cpath,O_RDWR|O_CREAT);
if(ts==NULL){
LOGE("ts==NULL");
return -1;
}
int stream_type;
if(codecID==0){//0表示 video
stream_type=PSI_STREAM_H264;
}else{
stream_type=PSI_STREAM_AAC;
}
jbyte *Src_data=(*env)->GetByteArrayElements(env,data,NULL);
int result=mpeg_ts_write(ts,stream_type,pts,dts,(void*)Src_data,(size_t)bytes);
void mpegwrite(void* param, const void* packet, size_t bytes){
write(file,packet,bytes);
}
这是ts文件
main.zip
在test目录下执行make clean&make,出现../../sdk/gcc.mk:86: recipe for target '../librtsp/test/media/mp4-file-source.o' failed以下错误,如何解决
Hello,
just a little suggestion; could you refactor the libraries so that all the .so files could be found from the same place?
I'm currently compiling in-tree, and I need to include a whopping list of
-L../media-server/libdash/release.linux -L../sdk/libaio/release.linux \
-I../media-server/libdash/include -I../sdk/libaio/include \
-L../media-server/libflv/release.linux -I../media-server/libflv/include \
-L../media-server/libmov/release.linux -I../media-server/libmov/include \
-L../sdk/libhttp/release.linux -I../sdk/libhttp/include \
-I../sdk/include
libraries. This is not nice. Also, when linking against these with the sample application, I get the linker error when linking against libhttp.a:
/usr/bin/ld: ../sdk/libhttp/release.linux/libhttp.a(http-server-route.o): in function `http_server_route':
/home/jussi/kurssit/IP/project/sdk/libhttp/source/http-server-route.cpp:42: undefined reference to `uri_parse'
/usr/bin/ld: /home/jussi/kurssit/IP/project/sdk/libhttp/source/http-server-route.cpp:43: undefined reference to `url_decode'
/usr/bin/ld: /home/jussi/kurssit/IP/project/sdk/libhttp/source/http-server-route.cpp:44: undefined reference to `uri_free'
because the url/uri functions are not embedded into the libhttp.a. Please fix this.
您好 Media-server 这个项目是MIT license,但是这个项目依赖了sdk,能否介绍一下sdk 的license 类型https://github.com/ireader/sdk,如果sdk license 也是MIT能否在项目中也加一个license 文件
目前fire-writer和fire-reader使用系统调用做io,能抽象成io接口由使用者决定使用何种io调用吗?
感觉mp4文件要回写数据,是不是很麻烦
我在用最新版本编译librtsp模块时,报找不到头文件错误(http-reason.h);错误如下:
gcc -I. -I./include -I../../sdk/include -I../../sdk/libhttp/include -I../librtp/include -DOS_LINUX -DDEBUG -D_DEBUG -Wall -fPIC -g -Wall -fvisibility=hidden -c -MMD -MP -MF debug.linux/rtsp-reason.d -o source/rtsp-reason.o source/rtsp-reason.c
source/rtsp-reason.c:1:25: error: http-reason.h: No such file or directory
source/rtsp-reason.c: In function ‘rtsp_reason_phrase’:
PES_packet_length, A value of 0 indicates that the PES packet length is neither specified nor bounded and is allowed only in PES packets whose payload consists of bytes from a video elementary stream contained in Transport Stream packets
试用了一下rtmp-publish-test.c,flv读取文件, 第一个包是metadata, 会assert(0)
如果忽略, 则会在rtmp_client_push_video的地方assert(0 != ctx->stream_id);
I may call mpeg_ts_write from seperate video and audio threads. Is this safe?
I only have pts (timestamp) can I make dts 0 ?
Showing All Errors Only
Undefined symbol: _rtsp_server_get_parameter
Undefined symbol: _rtsp_server_reply_get_parameter
Undefined symbol: _rtsp_server_reply_set_parameter
Undefined symbol: _rtsp_server_set_parameter
hls-server.cpp:1:24: 致命错误:aio-worker.h:没有那个文件或目录
ffplay 软件版本:ffmpeg-3.3.1
H.264 + AAC 测试正常
只修改了tsctx->pat.pmt[0].streams[1].avtype = PSI_STREAM_H265;
然后送入AAC的音频和H.265 视频数据,用ffplay 播放只有音频,解析提示如下:
yangchar@yangchar:$ ffmpeg-3.3.1/ffplay /tftpboot/output.ts14.04.1)
ffplay version 3.3.1 Copyright (c) 2003-2017 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1
configuration:
libavutil 55. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
[mpegts @ 0x7fdcc40008c0] PES packet size mismatchsq= 0B f=0/0
[mp3 @ 0x7fdcc4009540] Header missingB vq= 0KB sq= 0B f=0/0
Last message repeated 5 times
[mpegts @ 0x7fdcc40008c0] decoding for stream 0 failed
[mpegts @ 0x7fdcc40008c0] PES packet size mismatch
[mpegts @ 0x7fdcc40008c0] Could not find codec parameters for stream 0 (Audio: mp3, 0 channels, s16p): unspecified frame size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, mpegts, from '/tftpboot/output.ts':
Duration: 00:00:15.83, start: 156.592000, bitrate: 711 kb/s
Program 1
No Program
Stream #0:0[0x102]: Audio: mp3, 0 channels, s16p
Stream #0:1[0x101]: Audio: aac (LC), 44100 Hz, mono, fltp, 128 kb/s
160.61 M-A: -0.000 fd= 0 aq= 21KB vq= 0KB sq= 0B f=0/0
文件在附件中
output.zip
Hello there,
Can you tell me how can it run on windows?
Regards
老陈你好,希望你能将你所用到的RFC文档也上传上来,谢谢
在test目录下执行make clean;make后存在以下问题:
../../sdk/libhttp/debug.linux/libhttp.a(http-cookie.o):在函数‘http_cookie_parse_test’中:
/home/zang/rtspserver/sdk/libhttp/source/http-cookie.c:251:对‘__asan_handle_no_return’未定义的引用
/home/zang/rtspserver/sdk/libhttp/source/http-cookie.c:252:对‘__asan_handle_no_return’未定义的引用
/home/zang/rtspserver/sdk/libhttp/source/http-cookie.c:257:对‘__asan_handle_no_return’未定义的引用
/home/zang/rtspserver/sdk/libhttp/source/http-cookie.c:258:对‘__asan_handle_no_return’未定义的引用
/home/zang/rtspserver/sdk/libhttp/source/http-cookie.c:263:对‘__asan_handle_no_return’未定义的引用
../../sdk/libhttp/debug.linux/libhttp.a(http-cookie.o):/home/zang/rtspserver/sdk/libhttp/source/http-cookie.c:264: 跟着更多未定义的参考到 __asan_handle_no_return
../../sdk/libhttp/debug.linux/libhttp.a(http-cookie.o):在函数‘http_cookie_create_test’中:
/home/zang/rtspserver/sdk/libhttp/source/http-cookie.c:287:对‘__asan_option_detect_stack_use_after_return’未定义的引用
/home/zang/rtspserver/sdk/libhttp/source/http-cookie.c:287:对‘__asan_stack_malloc_2’未定义的引用
/home/zang/rtspserver/sdk/libhttp/source/http-cookie.c:289:对‘__asan_handle_no_return’未定义的引用
/home/zang/rtspserver/sdk/libhttp/source/http-cookie.c:290:对‘__asan_handle_no_return’未定义的引用
/home/zang/rtspserver/sdk/libhttp/source/http-cookie.c:291:对‘__asan_handle_no_return’未定义的引用
/home/zang/rtspserver/sdk/libhttp/source/http-cookie.c:292:对‘__asan_handle_no_return’未定义的引用
/home/zang/rtspserver/sdk/libhttp/source/http-cookie.c:293:对‘__asan_handle_no_return’未定义的引用
../../sdk/libhttp/debug.linux/libhttp.a(http-cookie.o):/home/zang/rtspserver/sdk/libhttp/source/http-cookie.c:294: 跟着更多未定义的参考到 __asan_handle_no_return
../../sdk/libhttp/debug.linux/libhttp.a(http-cookie.o):在函数‘_GLOBAL__sub_D_00099_0_http_cookie.c’中:
/home/zang/rtspserver/sdk/libhttp/source/http-cookie.c:309:对‘__asan_unregister_globals’未定义的引用
../../sdk/libhttp/debug.linux/libhttp.a(http-cookie.o):在函数‘_GLOBAL__sub_I_00099_1_http_cookie.c’中:
/home/zang/rtspserver/sdk/libhttp/source/http-cookie.c:309:对‘__asan_init_v4’未定义的引用
/home/zang/rtspserver/sdk/libhttp/source/http-cookie.c:309:对‘__asan_register_globals’未定义的引用
avc->nb_pps = 0;
avc->nb_sps = 0;
老陈,这两句应该注释吧,不然每次进来赋0后,后面flv->avc.nb_sps < 1 判断就一直过不去了
Hello!
Before I'll continue previous question, I want to know how to properly get fmp4 with your library.
So I expect get something like this
check here
Can you show code example?
Thx.
我发现RTSP server 目前不支持音频是吧?
Hi, I am looking for "usable" RTSP server lib. I am saying "usable" because things like live555 are hard even to get how to work with. I see here in the RTSP folder the code looks good.
Has this code been actually used in production?
Are you maintaining still this codebase?
Thanks!
libmpeg aac 8k 单声道 muxer 出来的test_aac.ps使用VLC无法播放声音,AAC单独写成ADTS+ES数据可以播放。
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.