Get frames in a video in Sketchware

 This sample shows how to get the frames in a video and display it in a GridView in Sketchware.

1. Create a new project in Sketchware.

2. In main.xml add a LinearLayout linear1. Below this add a ListView listview1.

3. Create a more block custom.xml. Add an ImageView imageview1 in it.

4. For listview1, select custom.xml as Custom View. Set height of linear1 to match_parent.

5. In View main.xml add a Floating Action Button _fab.

6. Add a FilePicker Component fp: video/*, and a Camera component cam.

7. Create a More block extra and declare GridView gridview1 and a list of bitmap images frames using following codes:

} GridView gridview1;

ArrayList<Bitmap> frames; {

8. Create a String path, a Map variable map, a List String list and a List Map imagelist.

9. In onCreate event put following codes.

gridview1 = new GridView(this);

gridview1.setLayoutParams(new GridView.LayoutParams(GridView.LayoutParams.MATCH_PARENT, GridView.LayoutParams.MATCH_PARENT));


gridview1.setNumColumns(2); gridview1.setColumnWidth(GridView.AUTO_FIT);

gridview1.setVerticalSpacing(16); gridview1.setHorizontalSpacing(2); gridview1.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);



gridview1.setAdapter(new Listview1Adapter(imagelist));


10. In fab onClick event, use File Picker fp pick files block.

11. In File Picker onFilesPicked event, use following codes:

path = _filePath.get((int)(0));

java.util.concurrent.ExecutorService executor = java.util.concurrent.Executors.newSingleThreadExecutor();

final Handler handler = new Handler(Looper.getMainLooper());

executor.execute(new Runnable() {


public void run() {

//Background work here


MediaMetadataRetriever retriever = new MediaMetadataRetriever();

retriever.setDataSource(getApplicationContext(), FileProvider.getUriForFile(MainActivity.this, getApplicationContext().getPackageName() + ".provider", new;

String duration = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);

int millSecond = Integer.parseInt(duration);

int duration_second = millSecond / 1000;

frames = new ArrayList<>();

int numeroFrameCaptured = (int)(duration_second*2);

for (int i = 0; i < numeroFrameCaptured; i++){


map = new HashMap<>();

map.put("frame", "new");


} Runnable() {


public void run() {

//UI Thread work here

gridview1.setAdapter(new Listview1Adapter(imagelist));


} });

} });

The code in blue above is for doing the task of retrieving frames in background thread.

12. In ListView onBindCustomView event, display bitmap from bitmap list frames, in imageview1.


13. Run the project.

Watch video below


  1. When you are eager to hire one from our agency then give us the chance to provide the most elite independent models and highest rated Delhi escort for your best moments in life when visiting Delhi

  2. I don't edit videos much. Time consuming. However this is a useful tutorial.

  3. This comment has been removed by the author.

  4. Wow this is a very cool tutorial. Pls sir can you help us make a tutorial on how to enable sav webpage in webview ( like save for offline pages) pls.


Post a Comment

Popular posts from this blog

A Flash Light App in Sketchware

Simple car racing android game in Sketchware

Firebase auth in Sketchware for Login Activity

In Sketchware: How to create a calculator for any simple formula?

Create a PDF reader android App in Sketchware