alm4096 / FFMPEG-Live555-H264-H265-Streamer

H264, H265 and more Encoder and Multicast/Unicast Streamer (example of how to use Live555 and FFMPEG)
100 stars 48 forks source link

Stream two input device #4

Open ahmadi219 opened 8 years ago

ahmadi219 commented 8 years ago

Hi I want to encode dshow devices like webcams with FFmpeg and stream it and I use this project for this purpose. I added a method in FFMPEGClass as SetupDSHOW and I setup my dshow input and a new method that get frame from input device instead of writedummyframe.It works good. If I want to use two webcams and stream them , Do I create two threads seperatly that creates FFMPEG object? for this , I create a method that it contains codes in main (create FFMPEG object and loop while(1) ) and then I create two threads in main method (std::thread (mymethod) ) and then join them. But when I run program two threads begin to work but one thread starts to stream and when I add breakpoint to live555class , one thread entered it . The question is , if I want to create two streams what should I do ? Thanks

alm4096 commented 8 years ago

Hi, you will need to at least have a different stream name for each instance of the ffmpeg thread. You may also need to use a different port for each thread (such as 8554 instead of 554). When i get a chance i will test and add it to the documentation.

ahmadi219 commented 8 years ago

Hi Thanks for your answerI added new stream name for two stream but I did not set different port number for each. I will test it ...

On Friday, July 15, 2016 1:58 PM, alm865 <notifications@github.com> wrote:

Hi, you will need to at least have a different stream name for each instance of the ffmpeg thread. You may also need to use a different port for each thread (such as 8554 instead of 554). When i get a chance i will test and add it to the documentation. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

ahmadi219 commented 8 years ago

Hi Can I remove this loop in Function ? when I open stream in VLC player , 5 - 10 seconds in first , frames are not correct and then suddenly it shows correctly . Should I change some parameters like GOB or other to correct stream ?

alm4096 commented 8 years ago

You can but you need to make sure you include the setupcodec function and then send frames directly. I'd have to check the code but there is nothing stopping you from rewriting anything.

A lower GOB will help with the streaming issues. The problem is that until a "p-frame" is sent vlc won't be able to display the movie correctly. A lower GOB will send p-frames more regularly. Other than that I'm not sure there's much you can do to fix it.

ahmadi219 commented 8 years ago

Hi I create two thread for streaming two webcam and I set different stream name and different rtsp port and rtp port for each them. But when it reach to env->taskScheduler().doEventLoop, application will aborted.
Should I create one rtsp server for all streams ? or I should create rtsp server for each of them ? for skipping this abort , I remove for loop of env->taskScheduler().doEventLoop , but access violation exception occured and in window printed : FramedSource[....]::getNextFrame() : attempting to read more than once at the same time! Should I use lock for AnalysingServerMediaSubsession or other ?

alm4096 commented 8 years ago

As discussed the Live555 class has a number of "global" static variables.

There are plans to fix this in the future. I will close this issue once it's resolved.

ahmadi219 commented 8 years ago

Hello Thanks a lot for your answers.