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 7712633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:40:52+00:00 2026-06-01T01:40:52+00:00

I’ve been attempting to figure this out for forever now (I’m new to programming)

  • 0

I’ve been attempting to figure this out for forever now (I’m new to programming) and I can’t figure it out.

I’m attempting to build a script that will test the file, and give me output from which I can get information like “Audio Format” that I can then put into the filename. However, I can’t even get the script to return any file info. I’ve hit a wall at inserting an input file…

So at this point I just need help getting it to spit out info based on the argvs I’ve thrown in. Hopefully I’ll be able to figure out how to parse the audio info from that.

My attempt that seems to be close:

#!/usr/bin/python
import os, sys, subprocess, shlex, re
from subprocess import call
def probe_file(filename):
    p = subprocess.Popen(['/opt/local/bin/ffprobe', '-show_format', '-pretty', '-loglevel quiet', -i filename], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
    print filename
    print p.communicate()
[probe_file (f) for f in os.listdir('.') if not f.startswith('.')]
  • 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-06-01T01:40:53+00:00Added an answer on June 1, 2026 at 1:40 am

    There are a few problems in your code:

    1. args list to Popen has last argument as -i filename which is a syntax error use '-i '+filename instead
    2. shell=True is usually not needed and is unnecessary burden.

    Other than that it seems to be working, are you not seeing output after fixing #1 ?

    Edit: Looks like you are having problem with ffprobe commandline, so I installed it and changes you require are:

    1. My ffprobe (ffprobe 0.7.3-4:0.7.3-0ubuntu0.11.10.1) doesn’t seems to accept -i flag, input file is just passed as last argument.
    2. you need to pass -loglevel and option of loglevel quiet as separate arguments i.e. [..., '-loglevel', 'quiet',..]

    So after these changes here is a sample script:

    #!/usr/bin/python
    import os, sys, subprocess, shlex, re
    from subprocess import call
    def probe_file(filename):
        cmnd = ['ffprobe', '-show_format', '-pretty', '-loglevel', 'quiet', filename]
        p = subprocess.Popen(cmnd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        print filename
        out, err =  p.communicate()
        print "==========output=========="
        print out
        if err:
            print "========= error ========"
            print err
    
    probe_file('drop.avi')
    

    And I see the correct output:

    ==========output==========
    [FORMAT]
    filename=drop.avi
    nb_streams=1
    format_name=avi
    format_long_name=AVI format
    start_time=0:00:00.000000
    duration=0:00:06.066667
    size=660.000 Kibyte
    bit_rate=891.217 Kbit/s
    [/FORMAT]
    
    ========= error ========
    ffprobe version 0.7.3-4:0.7.3-0ubuntu0.11.10.1, Copyright (c) 2007-2011 the Libav developers
      built on Jan  4 2012 16:08:51 with gcc 4.6.1
      configuration: --extra-version='4:0.7.3-0ubuntu0.11.10.1' --arch=amd64 --prefix=/usr --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --enable-libvpx --enable-runtime-cpudetect --enable-vaapi --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --enable-shared --disable-static
      libavutil    51.  7. 0 / 51.  7. 0
      libavcodec   53.  6. 0 / 53.  6. 0
      libavformat  53.  3. 0 / 53.  3. 0
      libavdevice  53.  0. 0 / 53.  0. 0
      libavfilter   2.  4. 0 /  2.  4. 0
      libswscale    2.  0. 0 /  2.  0. 0
      libpostproc  52.  0. 0 / 52.  0. 0
    Unsupported codec with id 114 for input stream 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text

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.