Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Welcome to LinuxQuestions.org, a friendly and active Linux Community.

You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!

Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.

If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.

Having a problem logging in? Please visit this page to clear all LQ-related cookies.

Introduction to Linux - A Hands on Guide

This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.

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()

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.

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 and you will save thousand of precious $$