Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Mencoder - how do I make a script that replace the implements filenames automatically

  1. #1
    Join Date
    Sep 2011
    Beans
    180
    Distro
    Ubuntu

    Question Mencoder - how do I make a script that replace the implements filenames automatically

    So I've been doing some studying on Mencoder, it is actually a really good useful program.

    So I made a command for hardcoding subs, but the only issue is I want to make this a script that can be used in Nautilus and will automatically fill in the input file names and create an output file name based on the input file name.

    Here's what I have so far:

    Code:
    mencoder movie.avi -sub moviesubs.srt -subfont-text-scale 3.3 -subpos 96 -o /dev/null -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vpass=1 -o movieWithSubs.avi
    Can someone add some tweaks to it for me? thanks in return and its much appreciated.

  2. #2
    Join Date
    May 2008
    Location
    United Kingdom
    Beans
    4,274
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Mencoder - how do I make a script that replace the implements filenames automatic

    Are you saying that you want to be able to right-click a file in Nautilus and call the script?

    If so, open Nautilus. Go to File > Scripts > Open Scripts Folder > Show more details. (If you don't see that menu item, you need to place a script (any script) in ~/.gnome2/nautilus-scripts first).
    Full Circle Magazine :: Cheap Linux stickers :: Problems with WINE?
    In my day, we had outdoors in which to run, play, and socialise. Now we have computers to do those.

  3. #3
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Mencoder - how do I make a script that replace the implements filenames automatic

    install nautilus-actions that allows you to create custom entries and fine tune their properties (files or dirs, filetypes, single or multiple selection)

    as for script part

    assuming that your script gets movie file as a parameter - name will be stored in $1

    Code:
    #!/bin/bash
    
    mencoder "$1" -sub moviesubs.srt -subfont-text-scale 3.3 -subpos 96 -o /dev/null -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vpass=1 -o "${1%.*}WithSubs.${1##*.}"
    there is some voodoo just in case you want to preserve file extension, but not necessarily hardcoded avi
    ${1%.*} = everything from $1 except shortest possible '.<anything>' on the right -> extension is out, name stays
    ${1##*.} = everything from $1 except longest possible '<anything>.' on the left -> whole name is out, extension stays

    i don't know if the subs file should be dependent on movie name so i left it untouched
    Last edited by Vaphell; April 9th, 2012 at 04:50 PM.

  4. #4
    Join Date
    Sep 2011
    Beans
    180
    Distro
    Ubuntu

    Smile Re: Mencoder - how do I make a script that replace the implements filenames automatic

    Quote Originally Posted by Paddy Landau View Post
    Are you saying that you want to be able to right-click a file in Nautilus and call the script?

    If so, open Nautilus. Go to File > Scripts > Open Scripts Folder > Show more details. (If you don't see that menu item, you need to place a script (any script) in ~/.gnome2/nautilus-scripts first).
    Yes, I've already completed that, I understand how to install scripts to work with Nautilus. but thank you for the information

    Quote Originally Posted by Vaphell View Post
    install nautilus-actions that allows you to create custom entries and fine tune their properties (files or dirs, filetypes, single or multiple selection)

    as for script part

    assuming that your script gets movie file as a parameter - name will be stored in $1

    Code:
    #!/bin/bash
    
    mencoder "$1" -sub moviesubs.srt -subfont-text-scale 3.3 -subpos 96 -o /dev/null -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vpass=1 -o "${1%.*}WithSubs.${1##*.}"
    there is some voodoo just in case you want to preserve file extension, but not necessarily hardcoded avi
    ${1%.*} = everything from $1 except shortest possible '.<anything>' on the right -> extension is out, name stays
    ${1##*.} = everything from $1 except longest possible '<anything>.' on the left -> whole name is out, extension stays

    i don't know if the subs file should be dependent on movie name so i left it untouched
    Thank you for explaining how the '$1' parameter works, that's what's been puzzling me. I've been trying to figure out how I can create a script that will work universally for any movie file I want to add subs to without having to go in and edit the code each time.

    Now as far as the rest of the code, was I on the right track or no? because this is the first time I've really went and used the CLI for Mencoder.



    ----UPDATE-----

    Also, is there a way I could possibly edit the bash script to include a sort of progress bar, if you will? like say a GUI progress bar to show how much/close it is to being done?
    Last edited by AlexOnVinyl; April 9th, 2012 at 11:30 PM. Reason: added an "update" section

  5. #5
    Join Date
    Sep 2011
    Beans
    180
    Distro
    Ubuntu

    Re: Mencoder - how do I make a script that replace the implements filenames automatic

    Bump

  6. #6
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Mencoder - how do I make a script that replace the implements filenames automatic

    if you need gui for your script, look at zenity with --progress parameter. Unfortunately i have no experience with it. I'd just run the script from terminal without bothering with useless bling

  7. #7
    Join Date
    Sep 2011
    Beans
    180
    Distro
    Ubuntu

    Re: Mencoder - how do I make a script that replace the implements filenames automatic

    Quote Originally Posted by Vaphell View Post
    if you need gui for your script, look at zenity with --progress parameter. Unfortunately i have no experience with it. I'd just run the script from terminal without bothering with useless bling
    for some reason I'm running into the issue where the subbed video has lower quality than the original video.

    I'll show you:

    Original:

    Sub encoded:

    is there something wrong with the code?

  8. #8
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Mencoder - how do I make a script that replace the implements filenames automatic

    no idea, i think you should ask in the Multimedia & Video subforum

  9. #9
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    11,671
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: Mencoder - how do I make a script that replace the implements filenames automatic

    It's probably smaller because you're using a more efficient codec to store the re-encoded file. That would be true if, for instance, the original is in MPEG2, and you're encoding to MPEG4. If you want an exact copy, use "-ovc copy".

  10. #10
    Join Date
    Sep 2011
    Beans
    180
    Distro
    Ubuntu

    Re: Mencoder - how do I make a script that replace the implements filenames automatic

    Quote Originally Posted by SeijiSensei View Post
    It's probably smaller because you're using a more efficient codec to store the re-encoded file. That would be true if, for instance, the original is in MPEG2, and you're encoding to MPEG4. If you want an exact copy, use "-ovc copy".
    I'm going to give that a shot right now - thanks, I'll let you know what I get.

    Do I replace the
    Code:
    -lavcopts vcodec=mpeg4
    line as well? with a simple
    Code:
    -ovc copy
    ?
    Last edited by AlexOnVinyl; April 12th, 2012 at 10:26 AM. Reason: added extra question

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •