video writer does not allow a string variable ?
Video writer gives me empty containers messages and such on mac if i do not specify a constant literal myself, i.e. "test". If i give it a string variable, it won't write.
This is making it difficult for me to add timestamps and such.
Any ideas?
a string where ?
Sorry, in the first argument (the path). For example if i do format("%s",variable) it won't work. If i put in "filename" it works fine.
could you show, what you tried ? (examples, that did not work) ?
it really should work ..
did you try something like ctime ?
those are terminated with
\n
, which is a bummer to have in any filename (it's not just the videoWriter)Hmm yes I did. But I also experienced it with any word I Put in a string variable. So maybe I should chop of the last character and retry. I'll post my code in a bit.
yes, exactly. cut it off.
Ok i'll try that. Thanks!
My code was:
Hmm i don't think c++ has strlen? (wait it does in cstring but for some reason although i use std namespace it doesn't recognise strlen..) I tried this though, also didn't work:
Ok i don't get it. So i started using size or length to get the size of the string, and do as follows.
But still no go, even though i'm chopping the newline terminator. I keep getting this: 25Wed Jul 27 20:17:09 2016
WARNING: Could not create empty movie file container. Didn't successfully update movie file.
ah, sorry for the confusion, you were meant to chop the c
char*
, not the c++std::string
. so:int len = strlen(ctime_str) ctime_str[len-1] = 0; // chop string filename = ctime_str