LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   watch your widescreen movies more full screen (https://www.linuxquestions.org/questions/linux-software-2/watch-your-widescreen-movies-more-full-screen-349052/)

shanenin 08-01-2005 09:07 PM

watch your widescreen movies more full screen
 
I have a computer connected to my tv which I have my media library on. I personally prefer more of my screen being filled then a very widescreen movie shows. If you use mplayer and have avi files. This program will write a config file for each avi file that will tell mplayer how much to crop it

Code:

#!/usr/bin/env python

# authored by shane lindberg

# This script makes configuration files for mplayer. In particular it makes a configuration that crops widescreen
# avi files so they will better fit your 4:3 aspect tv or computer moniter
# to run this program you need to to be in the directory that contains your avi files. Then just simply run the command
# it will check for the dimensions of the avi file using avitype, I think this is a part of transcode. If avitype is not
# installed the script will not work properly. This does not affect your media it only makes a config file that mplayer
# will use. At any time you can simply do 'rm *conf' to remove all of the config files this program created
# then you will be back to your old widescreen self

import os
import sys

current_dir = os.getcwd()

# this python function gets the dimensions of a video file and returns them as a tuple (width,height)
# it uses the linux video program avitype (I think this is part of the transcode package)
# getdimensions.py
def getdimensions(video_file):

    import commands
    avitype_command= '/usr/bin/avitype "%s" | grep WxH' % video_file
    dimensions = commands.getoutput(avitype_command)
    width = int(dimensions[-7:-4])
    height = int(dimensions[-3:])
    WxH = (width,height)
    return WxH

# this function finds all media in a given directory by file extention. It then places this media in a list
def movie_find(directory):
    ls_dir = os.listdir(directory)
    dir_list =[]
    for i in ls_dir:
        if i.endswith('.avi'):
            dir_list.append(i)
    return dir_list

# this part checks to make sure the user has root privleges, if not it exits the script
current_user = os.geteuid()


#you may want to remove this if statment. It is needed for me because my movie files are in a write protected space
if current_user != 0:
    print "you need to be root to run this script"
    sys.exit()

# this part checks to make sure you are in the directory of the files you want to make .conf files for
print "is this the directory which contains the files you want to make .confs for"
print current_dir
answer = raw_input("enter 1 to continue")
if answer != '1':
    print "change to the correct directory then restart the script"
    sys.exit()

movie_list = movie_find(current_dir)

for i in movie_list:
    conf_name = "%s.conf" %i
    wxh = getdimensions(i)
    width = wxh[0]
    # you can change the amount of crop by adjusting the number multiplied by width. The lower the number
    # the more of a crop you will get. If the number is at the max 1, it will not be cropped at all
    cropped_width = int(.80 * width)
    print_tuple = (cropped_width,wxh[1])
    conf_file = open(conf_name, "w")
    conf_file.write("vf=crop=%s:%s\n"%print_tuple)
    conf_file.close()


Erik_the_Red 08-01-2005 09:40 PM

I certainly appalud your Python program, but widescreen is more of a habit than anything else.

If you're really into the movie, then you shouldn't notice the bars at all.

shanenin 08-01-2005 09:59 PM

I know many people prefer widescreen, I am probably in the minority. I think I have trouble following what is going on when it is much smaller. Maybe I should just go out and get a much bigger telivision.

guideweb 08-02-2005 12:30 AM

Quote:

Originally posted by shanenin
I know many people prefer widescreen, I am probably in the minority. I think I have trouble following what is going on when it is much smaller. Maybe I should just go out and get a much bigger telivision.
Your couch is probably to far away from your tv. Move it closer :p and you will save thousand of precious $$ :)


All times are GMT -5. The time now is 09:17 PM.