Page 1 of 1

script for omxplayer with subtitles

Posted: Fri Feb 20, 2015 11:01 am
by piepolitb
hello guys,
I'm a new happy owner of a pi b+ with raspbian installed. Also I'm quite a newbie to the raspberry pi world...

first of all, here is the situation: I have tons of movies over streamed over my wifi, collected in organized folders containing the following files with the following formatted names:
1. file-name.mp4 - the video file
2. file-name_ITA.srt - italian subtitle (if any)
3. file-name_ENG.srt - english subtitles (if any)
I'm able to have everything working fine with omxplayer

Code: Select all

omxplayer -o hdmi -r file-name.mp4 --subtitles file-name_XXX.srt
BUT because I'm little lazy and I don't want to play the video by terminal line command, I would like to write down a little script to open the video file on double click to put in /usr/local/bin and then in the "open with" property. I would like this script to:
1. play the double-clicked file with omxplayer
2. check for existing subtitles in the folder
3. ask me which subtitles I want to be set up
4.enjoy the movie

any suggestions?
thanks
Giuseppe

Re: script for omxplayer with subtitles

Posted: Sat Feb 21, 2015 9:29 pm
by piepolitb
nobody?

Re: script for omxplayer with subtitles

Posted: Sun Feb 22, 2015 2:06 am
by expandables
piepolitb wrote:nobody?
Why not install a gui like emulationstation and have a section that plays video files.
But you will have to do your script yourself Mr. Lazy. :lol: :mrgreen: OR try vlc player http://www.raspberrypi.org/forums/viewt ... 99#p629999
Or download scamp from the store. http://store.raspberrypi.com/projects/scamp

Re: script for omxplayer with subtitles

Posted: Sun Feb 22, 2015 2:53 am
by kusti8
piepolitb wrote:hello guys,
I'm a new happy owner of a pi b+ with raspbian installed. Also I'm quite a newbie to the raspberry pi world...

first of all, here is the situation: I have tons of movies over streamed over my wifi, collected in organized folders containing the following files with the following formatted names:
1. file-name.mp4 - the video file
2. file-name_ITA.srt - italian subtitle (if any)
3. file-name_ENG.srt - english subtitles (if any)
I'm able to have everything working fine with omxplayer

Code: Select all

omxplayer -o hdmi -r file-name.mp4 --subtitles file-name_XXX.srt
BUT because I'm little lazy and I don't want to play the video by terminal line command, I would like to write down a little script to open the video file on double click to put in /usr/local/bin and then in the "open with" property. I would like this script to:
1. play the double-clicked file with omxplayer
2. check for existing subtitles in the folder
3. ask me which subtitles I want to be set up
4.enjoy the movie

any suggestions?
thanks
Giuseppe

Code: Select all

import subprocess
import glob
import os

file = raw_input("What is the file name (with extension): ")
directory = raw_input("What is the directory: ")
if directory!= "":
    os.chdir(directory)
subtitles = []
sub_file = []
for subtitle in glob.glob("*.srt"):
    subtitles.append(subtitle[-3:])
    sub_file.append(subtitle)

choice = raw_input("Which subtitle do you want:" + subtitles)
got=""
for s_file in sub_file:
    if s_file[-3:] == choice:
        got=sub_file
        break
if got!="":
    subprocess.open("omxplayer -o hdmi -r " + file + " --subtitles " + sub_file, shell=True)

Re: script for omxplayer with subtitles

Posted: Sun Feb 22, 2015 4:58 am
by expandables
Looks like you are all set :mrgreen: