Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6544309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:27:01+00:00 2026-05-25T11:27:01+00:00

Input: $ ./ffmpeg -i test020.3gp ffmpeg version UNKNOWN, Copyright (c) 2000-2011 the FFmpeg developers

  • 0

Input:

$ ./ffmpeg -i test020.3gp                                                                                                               
ffmpeg version UNKNOWN, Copyright (c) 2000-2011 the FFmpeg developers
  built on May  5 2011 14:30:25 with gcc 4.4.3
  configuration: 
  libavutil    51.  2. 0 / 51.  2. 0
  libavcodec   53.  3. 0 / 53.  3. 0
  libavformat  53.  0. 3 / 53.  0. 3
  libavdevice  53.  0. 0 / 53.  0. 0
  libavfilter   2.  4. 0 /  2.  4. 0
  libswscale    0. 14. 0 /  0. 14. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test020.3gp':
  Metadata:
    major_brand     : 3gp4
    minor_version   : 512
    compatible_brands: 3gp4
    creation_time   : 2004-07-01 09:59:21
  Duration: 00:01:02.20, start: 0.000000, bitrate: 284 kb/s
    Stream #0.0(und): Audio: aac, 44100 Hz, stereo, s16, 96 kb/s
    Metadata:
      creation_time   : 2004-07-01 09:59:21
    Stream #0.1(und): Video: mpeg4, yuv420p, 176x120 [PAR 1:1 DAR 22:15], 184 kb/s, 15 fps, 15 tbr, 30k tbn, 15 tbc
    Metadata:
      creation_time   : 2004-07-01 09:59:23
At least one output file must be specified

Let’s say I would like to extract the width & height using the following regexp:

(\d+x\d+)

Using perl, I’d do do something like this:

$ ./ffmpeg -i test020.3gp 2>&1 | perl -lane 'print $1 if /(\d+x\d+)/'
176x120

Then I’d tried to construct a similar python one-liner, it sort-of works, but not perfectly:

$ ./ffmpeg -i test020.3gp 2>&1 | python -c "import sys,re;[sys.stdout.write(str(re.findall(r'(\d+x\d+)', line))) for line in sys.stdin]"
[][][][][][][][][][][][][][][][][][][]['176x120'][][][]

What do a python one-liner looks like that corresponds to the perl one?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:27:02+00:00Added an answer on May 25, 2026 at 11:27 am

    What you want is re.search instead of re.findall.

    This does the trick, even if the one-liner itself is a bit “ugly” (/tmp/p is just the sample data you gave):

    % cat /tmp/p 2>&1 | python -c "import re,sys; print re.search(r'(\d+x\d+)', sys.stdin.read()).group()"
    176x120
    

    Any reason you’re not just using grep (egrep in this case)?

    % cat /tmp/p | egrep -o '[0-9]+x[0-9]+'
    176x120
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to pass a full file path to FFMPEG. C:\TestFolder\Input\Friends - Season
I have input bytes from ffmpeg. I'd like to send this output to several
Anyone know if ffmpeg does asynchronous file io? That is, the input file is
INPUT <logs> <logentry revision=648> <author>nshmyrev</author> <date>2008-09-21T19:43:10.819236Z</date> <paths> <path action=M>/trunk/po/ru.pi</path> </paths> <msg>2008-09-21 Nickolay V. Shmyrev
Input: 1) A huge sorted array of string SA; 2) A prefix string P;
Input @StartDate = '01/25/2010' @EndDate = '02/06/2010' I have 2 CTEs in a stored
Input : {5, 13, 6, 5, 13, 7, 8, 6, 5} Output : {5,
Input: SHC 111U,SHB 22x,, SHA 5555G Needed output: SHB 22X, SHC 111U, SHA 5555G
Input: I have a LaTeX file, with plain text & math formulas. Desired output:
Input rz value In the head I have: Event.observe(window, 'load', function() { $$(input).each(function(field){ Event.observe(field,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.