Answer the question
In order to leave comments, you need to log in
How to determine if a file is a video in a bash script and get its permission?
In a bash script, you need to determine if a certain file is a video and get its permission in 2 bash variables.
In this case, the file codec and file extension can be any.
Answer the question
In order to leave comments, you need to log in
as part of the ffmpeg project, there is ffprobe, use it.
ffmpeg.org/ffprobe.html Available
in various formats. And plain text(ini) or csv,xml,json
Examples:
$ ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of default=nw=1 "My video file.mpg"
width=704
height=576
$ ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 "another vide file.mkv"
1280,720
$ ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of json "one_more video.mkv"
{
"programs": [
],
"streams": [
{
"width": 1152,
"height": 480
}
]
}
ffprobe from ffmpeg package
ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of default=nw=1:nk=1 input.mp4
#!/usr/bin/env bash
w=$(mediainfo --Inform="Video;%Width%" FileName)
h=$(mediainfo --Inform="Video;%Height%" FileName)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question