-
Notifications
You must be signed in to change notification settings - Fork 97
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
ofxVideoRecorder native windows support #4
Comments
I've never tried on windows, I'm not sure what the equivalent for unistd.h is, or if it is even possible. It might be simpleer to just use a unix compatibility layer like mingw. If you can figure it out on windows with vs2010 that would be great, and I would gladly pull in your changes. |
The equivalent for unistd.h in windows is io.h, but it does not have the ioctl function or the FIOBIO. Do we need it? Could anybody adapted it to windows? Thanks! |
Im seeing that you have TODO: add windows compatable pipe creation (does ffmpeg work with windows pipes?). Could you fix this? |
As I've said, if anyone wants to figure this out, I will gladly pull in changes. Windows support would likely benefit a lot of people, but it is unfortunately very low priority for me personally, and I don't have the time to devote to it right now. |
This seems to be an approach to deal with the streaming options, (https://trac.ffmpeg.org/ticket/986) I am taking a stab at it to see if I can get it working on windows 8.1 vs 2012. I changed a few things and am able to get it to compile at least but it crashed when starting a recording. |
hey,@DomAmato, thanks for the windows update althought it's not fully working yet |
Just a wild guess but it sounds like it could be that the audio thread is stalled on an IO wait (which eventually times out), this would also cause the video thread to skip frames. as there is no audio coming in. |
I will take a look. How quickly did it throw that error? I was doing short recordings of like < 20 seconds and it worked but I think the audio didn't work properly. I'll do some testing this weekend to see if I can replicate the issue |
from the start actually after pressed the r key, yeah,the audio pipe seems not working at all thxs for look into it |
ok,i just noticed i have to change setDevice to 3 enable input recording. this time got audio queue size |
@liquidzym do you have a branch you with your in-progress code anywhere? I could take a look. |
@timscaffidi,sorry,i haven't put any code on github yet,could you please take a look DomAmato's brunch basically i'm just using his contribution,but i can upload it later on tomorrow in case you can help on this |
I think the named pipes arent working properly, I will have to update things. Sorry for the inconvenience but yeah I am getting a similar issue with invalid argument. using pipe: works but its considerably slower than using named pipes |
I pushed a new commit. It fixes things sort of. It can record video or audio but not both. Trying to record both hangs up the pipes (audio will connect video hangs indefinitely). Also spaces in the path name causes a problem but thats actually an easy fix. I just wanted to push an update so that you would have at least something to work with. |
hey,thxs for the update,the video part its working now, do you think any chance can make audio working? btw, i have to change it back to cmd << ffmpegLocation << " -y "; otherwise causing ffmpegffmppeg trouble in cmd not too sure why. |
I changed it so that when you change the ffmpeg location it would run the console command for you but I switched it back now. Audio does work too just not with video. You can do one or the other but not both. I am not sure why but it it will only connect to one pipe, if you try to do both it hangs after connecting to one of the pipes. Not sure why this is |
ok,i see,i added ffmepg to my sys path var maybe that's why. anyway,that's not issue. |
Ffmpeg doesn't handle the devices in this instance. That is handled by openframeworks and audio is dependent on the system. Mostly likely yes the rtaudio or whatever soundstream library you use will connect to direct show since rtaudio only recently supported wasapi. A solution here might be writing a custom script until the pipe situation gets sorted out. U can use ffmpeg to directly connect to a device so u might want to setup a video recording and then add a custom script to connect to the audio device. Not an ideal work around but it should work. |
right,i'll try that thxs,also after googling i found this "ConnectNamedPipe() accepts an inbound connection on a listening named pipe, so that would only work if ffmpeg were calling CreateFile() to connect to the named pipe" thank you again for the help |
Thats not right. ffmpeg does not have to call createfile() to connect to the pipe. |
http://trac.ffmpeg.org/ticket/1663 Seems to be a known issue |
too bad,what you saying is that i can call the setupCustomOutput method with custom script to connect to the audio? |
if you know what devices you will be using you can connect directly to them using ffmpeg http://www.ffmpeg.org/ffmpeg-devices.html#Input-Devices the current custom script method needs work and ill expand it to allow for more robust custom scripts |
@DomAmato In the issue you linked to they are using mkfifo, which is a unix command, and it is how ofxVideoRecorder already works on linux and Mac OS. My guess is that, as a few people have commented over there, there is a synchronization issue. In fact I was getting the same issue when originally developing the audio+video feature for this addon. Perhaps windows pipes have a smaller buffer size by default than a fifo pipe in unix. have you tried increasing the buffer size when calling CreateNamedPipe? I see in your branch that you are only using 512 bytes buffer size for each pipe. I would say you should increase those significantly. According to this stack exchange post on unix systems the pipe buffer sizes are anywhere from 16384 to 65536 bytes. I hope this helps |
The problem is that it hangs when the second ConnectNamedPipe is called, changing the buffer size changed nothing. I also cant get it working on OSX. FFMpeg starts after the other threads so it never records anything. My guess is that ffmpeg only waits for the first pipe to connect so when it tries to connect the second pipe there is nothing listening and so it hangs. I think a solution might be to run two separate ffmpeg instances and then join the audio and video tracks into one at the end in a final script |
The above method worked. it required separate ffmpeg instances each listening to only 1 pipe. It now creates 2 temporary files and merges them afterwards. it doesnt automatically delete the files though. @liquidzym it should work now. I occasionally get avdelta warnings but i didn't notice anything out of sync. I can't say for longer recordings though. |
wow,thank you so much for this! did you got fully working v merged ideo with sound? also i set my devie as 2 which is mircophone input sorry,i just noticed that sound stream is missing during the record |
I don't believe u can encode to mp3 which looks like what you are trying to do. By default it records to .m4a so that it is an easy conversion to mp4. delete the line in the code that says .setaudiocodec(".mp3"). I would guess that is what is causing the problem. I tested it and both audio and video recorded and was in sync. |
@DomAmato,haha, its totally working now,got video&sound sync. for 30s, i'll test it for longer time. but for now i only need 30s. |
@DomAmato void ofxAudioDataWriterThread::threadedFunction(){
...
if (b_written > 0){
b_remaining -= b_written;
b_offset += b_written;
}
else {
if (bClose){
break; // quit writing so we can close the file
}
}
}
bIsWriting = false;
delete[] frame->data;
delete frame;
}
else{
condition.wait(conditionMutex, 1000);
}
}
....
} |
I actually never tested that so I will do that now |
OK i fixed it. I also added a random number generation for the pipe naming so that you can have multiple instances. |
@DomAmato as far as multiple instances goes, this was already supported. look at the requestPipeNumber and retirePipeNumber functions |
I know but i hadn't implemented it in my fork as i was just interested in getting it working. I did see the request and retire functions and ill give them a closer look |
Any updates on this issue? @DomAmato I tried the code in your fork and I can't get it to work. It crashes when I create a simple example using the example code in your fork. If integrate it in my project, I get a file not found on the pipe name. Seems like there are not so many alternatives to recording a video on windows |
Can you tell me what error you get and on what line it crashes. My fork should work. The file not found is probably referring to the location of the compiled ffmpeg application, where do you have that installed? |
Hello @DomAmato ! I was able to compile and run your version, however with small modifications, so that in every place you refer to a file path, I added double quotes. This should take care of issues with spaces in the file path. Another change is that ffmpeg location expects not the "bin" folder, but the complete file path of the ffmpeg.exe file (my Path includes only c:\ffmpeg\bin"). |
Are you talking about changes made to the example or to the code in the addon source? you alter the path to wherever your ffmpeg version is installed which can include the data folder from OF so long as ffmpeg.exe exists in that location. |
Im using @DomAmato repo for record a ofApp on win 10 and is working great, thank you!! But i want to know if is possible to get a callback or a flag somewhere to know when the creation of the video has ended ??... like the linux version one does. |
There are so many forks now I don't even know the state anymore for windows. Maybe @razvanilin might have an idea? it looks like they extended the work I was doing but it should be possible to have an event once the video is done. |
Thanks, lets see if he knows about and also will be nice to know which fork is the good one for windows.. |
Unfortunately, I didn't extend the addon more than just adjusted it to work for both MacOS and Windows. Like @DomAmato said, it's definitely possible to create some sort of event that fires when the video creation ends. You can also have a look at |
Thanks, its a good idea!! i will try using ffprobe to check the video before send an event |
What is the status of this issue in 2020? |
I do not have unistd.h. . .
The text was updated successfully, but these errors were encountered: