Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
10
rated 0 times [  10] [ 0]  / answers: 1 / hits: 14618  / 2 Years ago, tue, october 4, 2022, 5:03:18

I'm not really well versed in the command line so hopefully this isn't too stupid of a question.



If I run:



ffmpeg -i videofile.avi


I get an output such as this:



ffmpeg version git-2013-11-21-6a7980e Copyright (c) 2000-2013 the FFmpeg develop    ers
built on Nov 21 2013 12:06:32 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
configuration: --prefix=/home/user/ffmpeg_build --extra-cflags=-I/home/user/ffmpeg_build/include --extra-ldflags=-L/home/user/ffmpeg_build/lib --b indir=/home/user/bin --extra-libs=-ldl --enable-gpl --enable-libass --enable -libfdk- aac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-l ibx264 --enable- nonfree
libavutil 52. 53.100 / 52. 53.100
libavcodec 55. 44.100 / 55. 44.100
libavformat 55. 21.100 / 55. 21.100
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 91.100 / 3. 91.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
Input #0, avi, from 'videofile.avi':
Metadata:
encoder : Lavf52.68.0
Duration: 00:23:07.68, start: 0.000000, bitrate: 2390 kb/s
Stream #0:0: Video: mpeg4 (Simple Profile) (XVID / 0x44495658), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 23.98 fps, 23.98 tbr, 23.98 tbn, 1199 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, s16p, 128 k b/s


If I were only interested in the command outputting "640x480", how might I do that?



I imagine I have to pipe the output to, and perform, a regular expression? No idea how to do that. Thanks!


More From » bash

 Answers
0

Get video resolution with ffmpeg:



ffmpeg -i filename 2>&1 | grep -oP 'Stream .*, K[0-9]+x[0-9]+'


Output (e.g.):




640x480

[#21589] Tuesday, October 4, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aveerakfas

Total Points: 106
Total Questions: 148
Total Answers: 129

Location: Monaco
Member since Sun, Jan 1, 2023
1 Year ago
;