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. I don't edit videos much. Time consuming. However this is a useful tutorial.

  2. This comment has been removed by the author.

  3. 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.

  4. Use a good camera, do a pre-record sound test, and learn some simple editing skills if you can’t afford to higher a video editor. albanische hits 2022

  5. Read file path is not working! How to do?

  6. Please help me.

    After I run to apk and I recheck source codes ,real Admob units are right units.

    When I export to .aab and I recheck the source codes, real Admob units change to test units automatically .

    How to fix this error?

    Thank you.

  7. doubles as a fantastic resource for anyone who wants to download free music. The site is primarily aimed at new bands; you're not going to find tracks from the current chart-toppers.

  8. I want to know how to create an appwidget with sketchware. Help me please


Post a Comment

Popular posts from this blog

Simple car racing android game in Sketchware

Enable Fullscreen for Youtube videos in WebView

Creating a Drawing View in Sketchware

How to enable upload from webview in Sketchware?

List of Calendar Format symbols valid in Sketchware