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

  • Home
  • SEARCH
  • 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 6565347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:04:58+00:00 2026-05-25T14:04:58+00:00

I have the following command: $ ffmpeg -i http://url/1video.mp4 2>&1 | perl -lane ‘print

  • 0

I have the following command:

$ ffmpeg -i http://url/1video.mp4 2>&1 | perl -lane 'print $1 if /(\d+x\d+)/'
640x360

I’m trying to set the output of this command into a python variable. Here is what I have so far:

>>> from subprocess import Popen, PIPE
>>> p1 = Popen(['ffmpeg', '-i', 'http://url/1video.mp4', '2>&1'], stdout=PIPE)
>>> p2=Popen(['perl','-lane','print $1 if /(\d+x\d+)/'], stdin=p1.stdout, stdout=PIPE)
>>> dimensions = p2.communicate()[0]
''

What am I doing incorrectly here, and how would I get the correct value for dimensions?

  • 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-25T14:04:59+00:00Added an answer on May 25, 2026 at 2:04 pm

    In general, you can replace a shell pipeline with this pattern:

    p1 = Popen(["dmesg"], stdout=PIPE)
    p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE)
    p1.stdout.close()  # Allow p1 to receive a SIGPIPE if p2 exits.
    output = p2.communicate()[0]
    

    However, in this case, no pipeline is necessary:

    import subprocess
    import shlex
    import re
    url='http://url/1video.mp4'
    proc=subprocess.Popen(shlex.split('ffmpeg -i {f}'.format(f=url)),
                          stdout=subprocess.PIPE,
                          stderr=subprocess.PIPE)
    dimensions=None
    for line in proc.stderr:
        match=re.search(r'(\d+x\d+)',line)
        if match:
            dimensions=match.group(1)
            break
    print(dimensions)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have found the following command in AWK useful in Vim :'<,'>!awk '{ print
I have the following code. I am trying to bind the Command property of
I have the following command in a bash script, time=$((./a.out) 2>&1) When run it,
i have the following command in my .vimrc: nmap gtb texecute !perl /home/hermann/hi.pl .shellescape(getline('.'),
I have the following awk command which works perfectly: awk 'BEGIN { ORS =
I have the following SQL command that I need to save as a csv
I have a setup.exe project that I run with the following command-line arguments to
I have a MySQL innodb database at 1.9GB, showed by following command. SELECT table_schema
I have the following function that deletes the LaTeX command surrounding the current cursor
I have created a certificate using the following SSL command: makecert -r -pe -n

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.