Open darkvertex opened 4 years ago
Hmmm... if I run strings
on the outputted file it's full of this:
$ strings output.h264
Us^d
[m[connector] Connector ip:192.168.55.129, port:9999
Us^d
[m[connector] Connector ip:192.168.55.129, port:9999
Us^d
[m[connector] Connector ip:192.168.55.129, port:9999
Us^d
[m[connector] Connector ip:192.168.55.129, port:9999
Us^d
[m[connector] Connector ip:192.168.55.129, port:9999
Us^d
[m[connector] Connector ip:192.168.55.129, port:9999
Us^d
[m[connector] Connector ip:192.168.55.129, port:9999
Us^d
[m[connector] Connector ip:192.168.55.129, port:9999
Should that be in the H264 raw data?? :thinking:
I copy/pasted your code and it works perfectly fine here.
On Ubuntu here so I'm on commit 051f1a3. Commits after this doesn't compile for Ubuntu... 🤔
I just managed to compile the latest in Ubuntu with g++ 4.8.5. Now I get the same results as you. h264->len seems a bit off to me.
Probably best to use 051f1a3 until this has been fixed.
I was able to debug the application and found a temporary solution.
It seems that the sspclient.h is not up to date with the library in the latest commit. The data has been shifted in some of the structs.
In sspclient.h.
Change SspVideoMeta to this:
struct LIBSSP_API SspVideoMeta {
uint32_t unknowndata[6]; // This is the fix
uint32_t width;
uint32_t height;
uint32_t timescale;
uint32_t unit;
uint32_t gop;
uint32_t encoder;
};
and change SspH264Data to this:
struct LIBSSP_API SspH264Data {
uint16_t unknowndata; // This is the fix
uint8_t * data;
size_t len;
uint64_t pts;
uint64_t ntp_timestamp;
uint32_t frm_no;
uint32_t type; // I or P
};
Maybe @ailike can submit a correct version of sspclient.h?
@secit Your fix made me get a real stream. Thank you! (It may be broken in other ways, but ffplay
can play the frames now so that's cool.)
I tried code at commit 051f1a3 and I straight up cannot compile on my CentOS7 with g++ 4.8.5:
$ make all
g++ ../libssp_test.cpp --std=c++11 -L../../lib/linux_x64/ -lssp -lpthread -I../../include/ -I../../include/libuv/include/ -o libssp_test
../../lib/linux_x64//libssp.a(sspclient.o): In function `imf::SspClientImp::SspClientImp(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, imf::Loop*, unsigned long, unsigned short, unsigned int)':
sspclient.cpp:(.text+0x7f5): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)'
../../lib/linux_x64//libssp.a(connector.o): In function `imf::Connector::Connector(imf::Loop*, char const*, unsigned short)':
connector.cpp:(.text+0x3ea): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)'
/tmp/cc8XM10J.o: In function `setup(imf::Loop*)':
libssp_test.cpp:(.text+0x3b2): undefined reference to `imf::SspClient::SspClient(std::string const&, imf::Loop*, unsigned long, unsigned short, unsigned int)'
collect2: error: ld returned 1 exit status
@darkvertex That's great!
I think you can "safely" use the latest commit with the fix. That should compile with g++ 4.8.5. The frames should be safe to use anyway. Not so sure about the other data. I didn't check audio for instance.
With the commit 051f1a3 I actually used g++ 7.4.0, but with other compile options.
@secit By the way, do you have any trouble with disconnections after some period of time?
I was testing with an E2 model, writing to a named pipe file (mkfifo to make the file and edited the file open mode in my C sample code to "a" to append) and I could have ffmpeg's ffplay player play the file direct in real-time (which is great) but for some reason I was getting consistently disconnected about 43 seconds in.
Have you experienced any behavior like that? (What model do you test with?)
I'm going to try playing with encoding settings to see if it changes anything.
@darkvertex E2 camera with default settings that are connected for several days without any issues.
For realtime video I use libav to decode and present images. I also remux and transport an RTP stream at the same time so I can view it realtime on another computer as well.
You could also write raw H264 to stdout and pipe it to ffplay.
Good luck!
So I found out that when using named pipes I get disconnected after some time (under a minute) and with real files I don't.
After some reading, I learnt that sending EOF to a pipe effectively closes it everywhere, so I'm guessing that at some point the camera closes the file and opens a new one, even though it's streaming non-stop it would seem it sends the EOF through the buffer anyway.
By the way, does someone know what's the point of the on_264_2
callback? why "2"?
Hello, I'm on Linux CentOS 7 x64. I have a Zcam V1 Pro.
I'm not a C++ expert so this may not be the best way, but I've modified the
libssp_test.cpp
file a little bit to:Here is my code in full:
I can compile it and it runs and writes my file. I have a few questions though:
1) What sets the encoding settings? Is it using the settings for video mode on the zcam?
2) In your opinion, am I dumping the data to disk in a valid way? (
fwrite(h264->data, 1, h264->len, output_file);
= OK?)2) The written file is supposed to be a raw H264 stream, correct?
I tried calling ffmpeg's
ffprobe
utility on it and it seems to hint that it may be invalid/corrupt:Likewise, ffmpeg fails to encode me an mp4 from it, so something is wrong... but I don't understand where.
Any advice?? :/