Page 1 of 1

Converting C Language Pipes

Posted: Fri Nov 09, 2018 7:27 pm
by chris319
I'm having trouble getting this C code converted and running in PB. It uses ffmpeg to read and write video frames. I can get the "read" part to work but I'm having trouble with the "write" part:

Code: Select all


FILE *pipeout = popen("ffmpeg -y -f rawvideo -vcodec rawvideo -pix_fmt rgb24 -s 1280x720 -r 25 -i - -f mp4 -q:v 5 -an -vcodec mpeg4 output.mp4", "w");

fwrite(frame, 1, H*W*3, pipeout);

I'm not sure how to handle the "w" at the end of the above line.

This is what I have so far in PB:

Code: Select all

pipeout$ = "  -y -f rawvideo -vcodec rawvideo -pix_fmt rgb24 -s 1280x720 -r 25 -i - -f mp4 -q:v 5 -an -vcodec mpeg4 output.mp4" + "w"

writeFrame = RunProgram("ffmpeg.exe", pipeOut$, "", #PB_Program_Open | #PB_Program_Write)


Re: Converting C Language Pipes

Posted: Fri Nov 09, 2018 7:53 pm
by mk-soft
The last parameter is the mode of "popen"...

Link: http://pubs.opengroup.org/onlinepubs/00 ... popen.html

You can remove it.

Re: Converting C Language Pipes

Posted: Sat Nov 10, 2018 3:00 am
by chris319
I think the "w" is equivalent to the #PB_Program_Write flag in PB's RunProgram().