Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
knobtviker
Posts: 145
Registered: ‎05-31-2013
My Device: BlackBerry Z10 Limited Edition

Re: Camera API video callback issue

Whoaa... so far a six seconds video has less than 1MB. I used H264 encoding with a few parameters before camera_start_video. 

I'm not merging them yet. Will start to look at that problem tonight. So far I used nothing but Camera API provided by BlackBerry on 10.2. If you have any good pointers, do share. :smileyhappy:

 

I needed a callback to get the time frame from each frame. While recording I extracted a timestamp, each following was then substracted from very first one and I get the duration of video segment itself. It is also used as a progress bar indicator value. So far so good.

Also, check my 2. In original post. I need to extract a frame on video stop and show it as an overlay ImageView. It's so called ghosting. You can continue to record exactly where you stopped.

I still need to see how server will react at a 720x720 resolution (point 3 in my OP) at 30fps. Since it usually expects a 480x480.

BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer

Re: Camera API video callback issue

hmm.. your timestamp calculation will probably end up wrong.

I mentioned we had a bug whereby when you call camera_stop_video(), it will actually finalize the mp4 file on disk, which may not yet include all frames which are still queued in the encoder.

so your 2.5 second video may actually end up being 2.2 seconds on disk, for example.

 

as for merging the files, you will have to find some off-the-shelf solution or write your own mp4-compliant headers by hand.

 

We're investigating a pause/resume-in-the-same-file feature for a future release, but it won't be ready any time soon.

 

This is why I was suggesting you might just want to cache uncompressed video locally and then try and pipe it through your own encoder as a single file when finished - this would let you resize before encoding too.

Interestingly, since we do allow read/write access to video buffers, you could cache all the frames in memory, and then when done, write them back through the video encoder :smileyhappy:  you wouldn't get the right audio though.

 

So for more accurate timing, you are probably going to want to look at the timestamps in the mp4 file -- unfortunately, those are not actually available until it is finished writing to disk, since the headers go at the end of the file :smileyhappy:

 

anyhow.. lots to think about.

Developer
knobtviker
Posts: 145
Registered: ‎05-31-2013
My Device: BlackBerry Z10 Limited Edition

Re: Camera API video callback issue

Vine has a flexible policy on video duration. Videos can be shorter than 6s but not over 10s. If I target the 6s mark and it ends up 5.8 or even 6.2s it will be accurate enough for this use case. No worries there.

I like your approach with cache, probably the right path to take. 

As for merging and writing my own merger - wouldn't be the first time for me. :smileyvery-happy:

Thanks for the heads up on all new cool features. 

Indeed a lot to think about. I'll do my best to provide a good user experience. :smileyhappy: 

BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer

Re: Camera API video callback issue

aha.. okay, well good luck!

shouldn't be too tricky for you then :smileyhappy:

 

roughly speaking, the mp4 files we write look something like:

 

<start of file>

<data atom  -- this is the large blob which is all the audio/video - the size is not known until finished, so we rewind and fill that in later>

<atoms with timestamps for each frame in the data>

<other misc atoms>

<end of file>

 

so you would need to stuff the multiple data atoms into a new file, then figure out how to merge all the other atoms together and rewrite timestamps.  should be enjoyable :smileyhappy:

of course, you should be able to find code out there that does this sort of thing, I imagine.

Developer
slashkyle
Posts: 820
Registered: ‎10-16-2012
My Device: Red Z10

Re: Camera API video callback issue

Sean, do you have any samples that demonstrate caching camera buffer data to memory?

Developer
knobtviker
Posts: 145
Registered: ‎05-31-2013
My Device: BlackBerry Z10 Limited Edition

Re: Camera API video callback issue

@slashkyle 

A callback on viewfinder and QLIST of camera_buffer_t struct?

 

@Sean

I'm curious because it just crossed my mind, how exactly does BB10 handle thumbnails for videos? It's exactly what I need for frame extraction.

Developer
knobtviker
Posts: 145
Registered: ‎05-31-2013
My Device: BlackBerry Z10 Limited Edition

Re: Camera API video callback issue

I just learned the hard way that you cannot change camera_roll_set_path into your apps private data directory because - camera app has no permissions for that. :smileysad:

So uncool. I have to expose unfinished bits and segments of a final video product now.... hmm...

BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer

Re: Camera API video callback issue

no, that's a limitation on how camera roll currently is implemented in the service.  I am fixing this for 10.2.1 with new roll scheme.


in the meantime, go ahead and save files to your sandbox.. instead of camera_roll_photo_open(), just call open().  there's no need to use the roll api if you are not saving to the roll :smileyhappy:

 

 

BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer

Re: Camera API video callback issue

I think the SlaveFlash sample on the camera wiki does bufferring of jpegs.  not many others do, but yah, whenever I have to do this it's usually just: malloc() & memcpy() and store the results in a list of some sort.

good time to de-stride the NV12 buffer as well!

 

 

BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer

Re: Camera API video callback issue


@Sean

I'm curious because it just crossed my mind, how exactly does BB10 handle thumbnails for videos? It's exactly what I need for frame extraction.


sorry for the multiple replies....

BB10's video thumbnailing is done by by another service on the system called mmsynclite.  it has no publicly documented API presently.  basically, it monitors shared/ for new files, then figures out what they are, runs them through decoders, extracts & scales frames, and saves them somewhere that the media apps are looking.

 

Cheers,

Sean