Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.
This repository was archived by the owner on May 22, 2025. It is now read-only.

Pass extra video filters to takeScreenshots #322

@hdn8

Description

@hdn8

Sometimes for example a video has a rotation value, if it was recorded on a mobile for example, and the screenshot will come out rotated according to the "metadata.stream.tags.rotation" field. Consider either passing a 'correctRotation' option to takeScreenshots (or do it automatically).

For correcting rotation I use code such as:

                var rotation = null;
                for (var i=0;i<metadata.streams.length;i++){
                    if (metadata.streams[i].tags.rotate){
                        rotation = metadata.streams[i].tags.rotate;
                    }
                }                    

                if (rotation == '180'){
                    extra_vf = 'scale=iw*sar:ih,hflip,vflip';
                } else if (rotation == '90') {
                    extra_vf = 'scale=iw*sar:ih,transpose=1';
                } else if (rotation == '270') {
                    extra_vf = 'scale=iw*sar:ih,transpose=1';
                } else {
                    extra_vf = 'scale=iw*sar:ih';
                }

metadata comes from ffprobe, could of course just have a simple option input and the user do the first part i.e.:

                     .takeScreenshots({
                            count: 1,
                            timemarks: ['50%'],
                            rotation: '180'
                            size: '?x480'
                    }

extra_vf then could be added to the filter_complex and voila!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions