Sunday, May 19, 2024
12
rated 0 times [  12] [ 0]  / answers: 1 / hits: 14784  / 3 Years ago, fri, september 3, 2021, 1:36:33

I use mediainfo at the moment.



It's too detailed



$ mediainfo vine.mp4 | wc -l
66


I wish a command with only short summary. 6 lines of output.


More From » command-line

 Answers
2

First define a shell function:



shortinfo() { 
mediainfo --Inform="General;Duration=%Duration/String3%
File size=%FileSize/String1%" "$@"
mediainfo --Inform="Video;Resolution=%Width%x%Height%
Codec=%CodecID%" "$@";
}


Now, use this shell function on your video file. For example:



$ shortinfo sample.mp4
Duration=00:00:10.027
File size=13 MiB
Resolution=1920x1080
Codec=avc1


To make the shell function permanent, place it in your ~/.bashrc file.



How it works



mediainfo allows for custom output but, as far as I can tell, the custom output can only come from one section (general, video, audio) at a time. This leads us to need two mediainfo commands. The first selects information from the general category:



mediainfo --Inform="General;Duration=%Duration/String3%
File size=%FileSize/String1%" "$@"


The second selects information from the Video category:



mediainfo --Inform="Video;Resolution=%Width%x%Height%
Codec=%CodecID%" "$@";


As you can see, the output allows us to insert any text we like and then substitute in file parameters using a string surrounded by percent signs, such as %CodecID%. Information can be put on one line or spread out over several. To insert a line break, use the string
.



For a list of all the possible file parameters that you can put in your custom output, run:



mediainfo --info-parameters | less

[#21577] Saturday, September 4, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
polcomposte

Total Points: 421
Total Questions: 92
Total Answers: 109

Location: Uzbekistan
Member since Mon, Jul 20, 2020
4 Years ago
polcomposte questions
Wed, Dec 14, 22, 02:45, 1 Year ago
Sat, Apr 9, 22, 01:36, 2 Years ago
Mon, Dec 26, 22, 01:52, 1 Year ago
Fri, May 20, 22, 12:03, 2 Years ago
;