New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zms/videostream improvements #404
Zms/videostream improvements #404
Conversation
* ZoneMinder compiles with ffmpeg 0.5..master * Make VideoStream class able to stream through ffmpeg better. * Ability to use fixed quality instead of fixed bitrate (by specifying bitrate 0...100) * Format url parameter supports <format>/<encoder> syntax Details: - Redefine av_err2str to a to avoid compiler warning on newer g++'s - When using rtp format; if ffmpeg does not have a default codec, use CODEC_ID_MPEG4. (because this is what the default is as of 2.2 when this code was written) - Specify ofc->packet_size if rtp format is requested - Video generated in a thread to guarantee a constant fps. - Move _AVCODECID definition into zm_ffmpeg.h (and use instead of (AV)CodecID - Call avformat_network_init because ffmpeg warns about it beeing required soon. - increase VideoStream::video_outbuf_size to 4MiB to be able to encode larger pictures
- fixed compilation issue with sws_..isSupported when compiling with ffmpeg 0.5
This is the cleaned up version of #382 as agreed! |
A good format to use is "&format=mpegts/mpeg4". It works pretty long way back with FFmpeg. Otherwise the point of this request is to give the user (me :)) better control for his/hers own purposes. |
this is to deliver frames more accurately to the client
uint8_t *opicture_buf = (uint8_t *)av_malloc(size); | ||
|
||
int size = avpicture_get_size( c->pix_fmt, c->width, c->height ); | ||
uint8_t *opicture_buf = (uint8_t *)av_malloc( size ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't av_mallocz be used here?
Oops, looks not, my bad.
When you say it like that it sounds so obvious :) |
@Sune1337 he does that to me too :-) Not sure if you know this, but we are usually online on the #zoneminder freenode irc channel. You are welcome to join us. |
Unless I hear otherwise from someonese else, I am going to give this a shot at merging this weekend. It can't be auto-merged so I'll have to manually address whatever merge conflicts exists. When it comes to troubleshooting zoneminder's streaming video C code, my understanding of what is going on is very limited. Consequently, @Sune1337 if you have a second and can take a look at what the problem might be, you are more likely to be able to fix the issue much faster than I can. Anyway, I'll give it a shot. |
I had some uncommitted code in this branch; im gonna investigate what that is tomow. I'll also check out the conflicts. |
My uncommitted changes is an attempt to implement variable framerate; which failed at the time. those are not important for this pull-request, so i'll just keep that experiment locally. I'll check out the conflicts now. |
I have resolved the conflicts. as in #351 i will await confirmation that checking in alot of files in this branch will actually help you merge, and not make thins messier :) To repeat: If i commit now i'll commit changes to a lot of files. I guess these are the changes between this branch and the ZoneMinder-master. Is this correct? Should i do the commit and push? |
I'll paste files to help you resolve conflicts on this pull request too. What i did: Resolves conflicts: edit: the zm_ffmpeg.h pastebin had been deleted somehow. updated the link. |
This cannot be auto-merged due to conflicts with the following pull request that has already been merged: #325 There appear to be just two conflicts, and we need to figure out how to merge your changes in w/o unravelling the changes from that pull request. For the conflict in zm_mpeg.cpp, you are using _AVCODECID_NONE while the author of #325 chose to use AV_CODEC_ID_NONE. Another example uses "of->video_codec" while you are using "codec_id". I don't know exactly what the end results should be.... probably a merge of your changes and his, but that's all I know right now. Can you compare what is going on in #325 and then tell me how this new code should look? |
No, it means I just don't know what I am looking at and didn't understand which to use. |
I gave you 2 pastebin files above which i intended for you to use when resolving the conflicts. Isn't it the zm_ffmpeg.h and zm_mpeg.cpp that conflicts? |
I'm just trying to understand it first. Give me a minute. |
Arrrghh - this doesn't build.
libavutil 52. 48.101 / 52. 48.101 |
This does not build on Fedora 20 w/ ffmpeg 2.1.1 (error is in previous post) |
Further progress... forgot that my build environment for Fedora tries to build w/o ffmpeg by default. |
Do you want me to create a pull request that can compile w/o ffmpeg? |
it seems the avformat_alloc_output_context2 isn't the only function not supported by libav (the fork). |
I don't like libav now. |
I created https://github.com/Sune1337/ZoneMinder_dup/tree/libav_the_fork_compat which compiles iwth libav. ZMS do however coredump if one is trying to stream using libav video. |
I wonder if we should just revert back to the old code path if building against libav. We know that worked, right? We could always come back to this and improve it after we release 1.28.0. |
the coredump was a bug; should exist when compiling with ffmpeg too. |
ps. i never got the zms to stream video before this pullrequest. ever. and i never saw anyone claiming they did either,, so i don't agree with old code working. |
i could test-stream now with libav using AVI format. seems there are some differences in mpegts handling (which was the other format i tested) |
do you want me to create pull-request on the branch? If nothing else, to suggest a solution to compiling with libav. |
Yeah, and I'll ask @connortechnology to test. I don't have an environment to test libav from so I'm going to be relying on others to tell what works and what doesn't. Also, can you make line 61 do this?
I did like the extra info in those debug statements from your original pull request. Maybe we can get those back in sometime later after we develop a compatible solution. |
Do you mean change zm_ffmpege.cpp:61 from:
into
|
btw; can you use 'LIBAVFORMAT_VERSION_MICRO >= 100' to determine if we're using libav or ffmpeg? |
Yes. I was looking at zm_ffmpeg.cpp from your branch: We want that condition to be false if using libav, but I'm assuming we are looking for a solution that uses avformat_alloc_output_context2 but only when building against ffmpeg. |
You can use LIBAVFORMAT_VERSION_MICRO >= 100 but it may not be that simple depending on what you are trying to do. |
oh, the changes is in a branch called 'libav_the_fork_compat'. But i'm gonna use the 'LIBAVFORMAT_VERSION_MICRO >= 100' method instead as you suggested. I agree this is better. |
@SteveGilvarry posted a good example from libvlc earlier, but I think in our particular case we can just tack on LIBAVFORMAT_VERSION_MICRO. In time if we run into more of these, then we may have to look into doing something more encompasing like in libvlc library. |
So; i have started to get stuff sorted out :) |
Man, github is messing with me. To be able to create a branch for the fixes, i needed to fork the ZoneMinder repo again. I needed to do this since i cant remove my existing one. I cant use my existing one because i have an active pull-request on that. Phew. github.com does not allow one to create a second fork, so i had to do this manually. Now i cant create pull-requests on the new fork; github.com isnt aware of the "connection". Can you use https://github.com/Sune1337/ZoneMinder_dup/tree/libav_the_fork_compat and create some manual pull request? https://github.com/Sune1337/ZoneMinder_dup/tree/libav_the_fork_compat now contains what i think is the correct way of adressing the issues caused by #404 in regards to libav the fork. |
i just pushed a new commit "compile with ffmpeg <= 0.8". Found issues with older FFmpegs. |
Yeah, that's why you don't create pull requests against your own master branch. When viewing a commit, one can add ".patch" to the url and github will auto-create a patch. |
It's all the commits in the branch "libav_the_fork_compat"; here are direct links to all patch files. https://github.com/Sune1337/ZoneMinder_dup/commit/6e77632a5946097bcb5489dce999814f1110716b.patch |
The pull request on master branch is an old mistake i'll never forget. Even so, i guess there's nothing i can do about it as it's already done. |
Sometimes learning the hard way is a good way to learn. I've made many github mistakes and have learned from it. honestly, I have learned to really like github. |
the commit messages for easy reviwing: 6e77632
4b47336
df4a9f2
0555068
|
@connortechnology is building it now. Sounds like it worked. He is just going to merge the changes directly into master. |
sounds great |
I checked out the commits; the commit "bugfix; coredump if no codec name was specified in url. " is missing from the master branch. Its not really related to compilation issues; just a bugfix i sneaked in there :) just wanted to point it out. |
I've got it now. Now sure how I missed it. Thanks for your efforts on these. |
Just confirmed that master (still) builds fine on Fedora & CentOS using ffmpeg. |
i wish i had champagne |
Support streaming with zms (using ffmpeg) better …
See commit message for details.