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: 134
Registered: ‎05-31-2013
My Device: BlackBerry Z10 Limited Edition
My Carrier: Bonbon

MP4 and change of resolution

Saga continues...

Merge multiple MP4 on BB10 with Qt

 

With great help, MP4 files have been merged into 1 final file and without errors.

 

Time has come to upload it to "some" server and these are picky.

 

Video was recorded in 720x720 (the only 1:1 resolution available now on BB10) and servers demand the files in 480x480 resolution.

 

As suggested, I tried 352x352 and 480x640 resolutions, freaky servers rejected those files aswell.

 

I tried spoofing the MP4 headers too, forcing 480 as width and height but that was rejected too.

 

Open to all ideas and suggestions (but not to usage of any 3rd party library like ffmpeg).

Nothing against 3rd party, but I have come this far, very far, with just Qt and BB10 APIs and I'll finish it like that even if it takes another 1500 lines of code. :smileyhappy:

 

 

Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

Re: MP4 and change of resolution

so.. the next thing to try is to alter the H.264 headers to specify that the picture is cropped.

This is often done with hardware encoders which have hard requirements that the image dimensions be multiples of 8 or 16 or something.  Many JPEG encoders have similar restrictions.

I have seen one system where if you try to encode an odd-height video, it leads to an error (eg. 720x405).

As a result, the H264 spec defines a means to indicate that picture data only occupies a certain range of the actual buffer.  I don't believe it allows for arbitrary cropping, but it should allow for cropping from the top of the frame. (eg. use only the first 480 lines of this 640-line frame).  You would then just mask off the video window in your app while recording, to give the user the appropriate feedback so they understand what is "in frame" and what is not.

 

Go grab the H.264 spec and search for frame_cropping_flag.  You will probably have to rewrite the whole H264 SPS block if you need to insert fields into it.

 

Alternately, you might be able to cheat the pic_height_in_map_units_minus1 with less effort.

 

I am warned that this is not overly complicated, but it is also not incredibly straightforward, as the bits for these fields may be scrambled, compressed, etc.

 

Transcoding is of course another option, however there are IP encumberances involved with those libraries, so I cannot advise you in that respect :smileyhappy:

 

good luck!

 

Please use plain text.