GPUImageMovieWriter without the camera - gpuimage

I'm new to GPUImage, but I think that it is really nice: good work Brad. I love the way the filters chain together so cleanly.
GOAL
I'm trying to wire up the following:
* create an openGL scene
* apply some filters (irrelevant to the discussion below)
* record to video
PROBLEM
My problem is I'm not clear how to connect up the recording. Unfortunately, interacting with opengl-es does not give me enough detail to work out what to do.
ATTEMPT
I have two starting points from the examples in the package:
* CubeExample - getting raw openGL to interact with GPUImage
* SimpleVideoFileFilter - recoding a video file through filters to a new file
I started with the CubeExample, substituted the videoCamera filter for GPUImageSolidColorGenerator (as an aside, I'm not sure how to start with no filter). This allowed me to be able to create a mesh, render it and interact with it. Then I thought that I'd simply add on a GPUImageMovieWriter filter as per the instructions given in filtering and re-encoding a movie, but that requires coordination between the GPUImageMovie (the source) and the writer. As I'm not wanting a camera stream or a video file as the source, but an animated openGL sequence, I'm not clear how to do it. I've tried adding a videoInputReadCallback to the movieWriter:
movieWriter.videoInputReadyCallback = ^{
[renderer nextFrame];
[movieWriter newFrameReadyAtTime:renderer.cmTime atIndex:0];
};
where nextFrame is creates the next frame, calls endProcessing when done and sets the CMTime. Without the newFrameReadyAtTime:atIndex: call, it works fine (animated image rendered as expected to the screen) except that it creates a video with only one frame in it. With the newFrameReadyAtTime:atIndex: call, I get the message
Problem appending pixel buffer at time: 6
before it dies, which makes me think that the movieWriter is not yet ready for the renderer to present its frame, but I'm not sure what to do about it. I've tried many other things, but to no avail. From the description in Interacting with OpenGL-ES (see link above), it seems like it should be easy, but I'm not having any luck.
REQUEST
To make the question more relevant to others, I would just like it if someone might be able to post an example of creating an openGL scene (eg a triangle) and connecting it to GPUImageMovieWriter to record to a file, perhaps rotating the triangle for 10 frames so that we can see that more than a still image is created.
thanks.

Related

posenet p5js position stops updating when I move to another tab

I'm coding with posenet and p5js. I made a grid on my screen which plays different audio fragments on different x ranges. This works very well. However, if I keep it running and open another tab in my chrome webbrowser, the x position gets stuck in one area (it doesn't update anymore) and the same audio fragment is repeated until you get crazy.
Is there a way I can prevent this?
Well, some code would be great to be honest, but variables shouldn't really get stuck if you open another tab and so on, are you sure you haven't just missssspelled some variable, or some function or did one of those random mistakes?
If it truly is the p5.js I guess just try checking everytime draw fires if your canvas is still focused.
I believe you can also have canvas.hasFocus... exept you'd have to declare createCanvas as a variable (cause canvas is basically just a button or a textArea to html and javascript and p5)
Also I think there's a command to only allow for one audio channel and stuff in js and p5...
function draw() {
if(document.hasFocus()){
// all of your other code even
// background() and stuff...
}
}

UITableView too slow on main thread

I was wondering if there is any way to accelerate/speed up the UItableView/[reload data].
Even though I reload the data on the main thread using:
> [self.tableview performSelectorOnMainThread:#selector(reloadData) withObject:nil waitUntilDone:No]
I still think the results is quite slow (2 to 3 seconds to refresh each time the table is being reloaded, making a bad user experience if the user keep refreshing the table).
For a bit of background here is how it works at the moment.
1) I create my UITableView from data coming from the database on apple starting (until here no problem and I am fine if its taking few seconds).
2) I click on one of the item of the table view, which opens a new screen to modify the elements.
3) Once the elements is modified, I change the database of my table view so that the elements I changed comes at the top of my table view.
4) When I press the back button on the screen to change my elements, I implements the ViewWillAppear of my UITableView and I reload the data on the main thread.
5) What I observer is a latency of about 2/3 seconds to go from one screen to another. Removing the reload data line from my code, make the transition instantaneous. So the problem is really in the reload data.
Each row of my UITableView has the following elements inside:
A background color coming from a file (this is basically a gradient, the file is about 20Ko, it is a PNG, the file is store on the phone)
1 or 2 UIImageView (depending on the status of what I display) (about 5Ko each, very small PNG icons, the file is store on the phone)
3 UILabel
1 UIButton (inside this PNG, there is a picture, the original size of the picture may vary from 200 to 300ko, the original source is coming from internet. I use SDWebImage to load it/cache it)
I would think I may have too much information on each of my cell, as I can see a big difference in loading time when I only have one row, versus having 10rows.
Would like to have some input from the community to see if anything can be done to improve. The best would be to be able to update the UI in the background, so for example, when I am modifying my elements, I do reloaddata in the background, so that when I come back to the previous screen that shows the UITableView my view is already refreshed,
Thanks
Ok I foudn the solution on this website:
http://www.raywenderlich.com/31166/25-ios-app-performance-tips-tricks#drawing
20) Optimize Your Table Views
Table views need to scroll quickly — when they don’t, users really notice the lag.
To keep your table views scrolling smoothly, ensure that you’ve implemented all of the suggestions below:
Reuse cells by setting the correct reuseIdentifier.
Make as many views opaque as possible, including the cell itself.
Avoid gradients, image scaling, and offscreen drawing.
Cache the height of any rows if they aren’t always the same.
If the cell shows content that comes from the web, be sure to make those calls asynchronously and cache the responses. (Personnal note on this one as it was my issue: look at this other website http://keighl.com/post/sdwebimage-uitableviewcell/ that explains how to use SDWebImage in a UITableView. Very useful.
Use shadowPath to set up shadows.
Reduce the number of subviews.
Do as little work as possible in cellForRowAtIndexPath:. If you need to do some work, do it only once and cache the results.
Use the appropriate data structure to hold the information you need. Different structures have different costs for different operations.
Use rowHeight, sectionFooterHeight and sectionHeaderHeight to set constant heights instead of asking the delegate.
You say "A background color coming from a file" - this alerts me that you're doing IO work, which is generally time-consuming, I'm curious if you remmed out the loading a colour from a file if you get a significant speed increase?

Questions about Citymaps

1、I want to create a circle and set an image that customized to fill the circle,use this as a marker on the map, not only could change the image but also the color of circle anytime,what can I do to implements this function? Please look at the picture below!
2、Like your CityMaps app show,when I enlarge the map, some business icon that hide are show on the map,which are hide again while shrink the map, How to achieve this effect?
3、After I initialization the Object Marker and called the method marker.setFadeTime(3000),the software give my tips the method is no exist and I see the class Marker.java but really not find the method,Why is it so?
4、I want to add some stars beside the marker like this:
What can I do to add the stars?the label only can set the text beside the marker.
5、I want to load your maps at the fragment,not the activity that extends FragmentActivity,I found the SupportCitymapsMapFragment is no use,What I can do to complete this requirement?
6、In your apps,it is locate that place after input New York in the search box,What can i do to complete this function whatever i input?
7、During I develop the apps about the Citymaps,I found a serious problem so that your apps had happend too. When I run the apps, the program force flash back all of a sudden and I run your apps Citymaps at this time,the problems are same of the front,I found some error in logical view that is follows:15327-15374/com.map.maplbs A/libc﹕ Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 15374 (Thread-1819).
To solve the problem,I must restart my device. Why is it so?
I am a developer on the Citymaps SDK, I will do my best to answer your questions.
1) I recommend using the Android Canvas API to construct the images, and then use a Marker to display it on the map. See the documentation for details: http://developer.citymaps.com/markers
2) This is built into the Citymaps BusinessLayer. This functionality is not exposed through an API. If you wish to use the Citymaps BusinessLayer, you should create a CitymapsMapView or CitymapsMapFragment/SupportCitymapsMapFragment and it will automatically be added to your map.
3) At this time, there appears to be a known issue with the fadeTime API. Thank you for bringing this to our attention. We will fix it in an upcoming release. For now, you can animate the alpha property of the Marker.
4) Once again, the functionality of the BusinessLayer is not directly exposed. If you wish to create similar markers, I recommend you construct the image using Android's Canvas and then adding it as a Marker to the map.
5) If you wish to load the map inside of a fragment, you can accomplish this using child fragments (check Android documentation for more details). You can also accomplish this by instantiating CitymapsMapView or MapView directly and adding it to your view hierarchy either in XML or in code. However if you do this, remember to call the lifecycle methods on your map instance, or else the map will not behave properly.
6) If you wish to have a search in your app, it is up to you to implement this feature. We do not currently provide a search API out of the box.
7) Thank you for the bug report. We will investigate this issue and fix it in a future release.
If you have any more questions, feel free to ask, and thank you for using the Citymaps SDK.

Painting frames while media session is paused

I'm working on a custom video player using the Media Foundation framework.
Currently, I can play, pause, stop or change the rate of the playback using an IMFMediaSession.
I can also retrieve a single frame using an IMFSourceReader.
I am currently able to render a frame (IMFSample) to a window area (a HWND) but only when the media session is stopped.
My goal is to be able to render a frame while the media session is paused.
(= doing frame-stepping using a source reader and not the media session)
I'm using GetDC, CreateBitmap, SelectObject and BitBlt to render my frame.
I tried using directd3d interfaces to fill it with a solid color (I'm really new to direct3d so followed a basic tutorial) but it didn't work.
Here is what I did : retrieving an IDirect3DDeviceManager9 with MR_VIDEO_ACCELERATION_SERVICE, doing OpenDeviceHandle, LockDevice, Clear, Begin/EndScene and Present.
None of these calls fail but I suspect the EVR is still painting the last frame.
So basically, I want the EVR to stop repainting its frame when I want and of course, I need to re-enable its painting process.
Any idea how to do that ?
Thanks
I finally got it working.
If you're interested, do the following:
retrieve IMFVideoDisplayControl and IMFVideoMixerBitmap from the media session using MFGetService
set up MFVideoAlphaBitmap structure and feed it to IMFVideoMixerBitmap::SetAlphaBitmap (there is a working example at the dedicated MSDN page)
call IMFVideoDisplayControl::RepaintVideo to update the output
To hide the previous content, don't set the alpha so that it's opaque.
Call IMFVideoMixerBitmap::ClearAlphaBitmap to get the previous content back.
And voilà !

iPhone mapview will only update when in wifi

I have a little application in progress.
One of my current problems is: it seems that the MapView will only load map data when I am in wifi range (when e.g. zooming in). When only 3G/2G is available, it displays the tiles already cached but will not load new ones. It seems to be no problem with the general setup of my iPhone: the Maps application works nicley.
Any ideas?
... well, looks like I was indeed too impatient. Sometimes, it takes a lot of time until the maps starts loading.

Resources