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

Thread: mencoder script problem

  1. #1
    Join Date
    Feb 2012
    Beans
    45

    mencoder script problem

    Code:
    Code:
    #!/bin/bash for file do base=${file%.*} ext=${file##*.} newname=${base}"_subt".mpg mencoder "$file" -sub ${base}.srt -subcp utf-8 -font /usr/share/fonts/msttcorefonts/arial.ttf -subfont-text-scale 2.5 -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd:tsaf -vf harddup -srate 44100 -af lavcresample=44100 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:keyint=15:vstrict=0:acodec=mp2:abitrate=128:aspect=16/9 -ofps 25 -o "$newname" | zenity --progress --text="Working: $file" --pulsate --auto-close done zenity --info \ --text="Finished"
    whats wrong with this script?it's supposed to convert a video file to mpeg2 and embed the subtitles.i tried it in an mp4 file and it worked.i tried in mkv and it does convert the video but doesn't embed the subs. so any ideas how should i make the script to work.with all filetypes?

  2. #2
    Join Date
    Jul 2009
    Location
    Hippiesoldierstan Norwich
    Beans
    2,326
    Distro
    Lubuntu 22.04 Jammy Jellyfish

    Re: mencoder script problem

    you might want to work mkvmerge somewhere in your script ; it might be a lot easier than mencoder for this specific task


    part of
    Code:
    sudo apt-get install mkvtoolnix
    Last edited by shantiq; March 25th, 2013 at 06:53 PM.
    Linux is Latin for off-the-beaten-track
    what I like MOST about our Ubuntu ... The Community ie 50 brains are better than one
    Playing with Slackware too now ...
    ShanArt

  3. #3
    Join Date
    Feb 2012
    Beans
    45

    Re: mencoder script problem

    what would be the benefit of mkvmerge and how would it help me to embed the subs?

  4. #4
    Join Date
    Jul 2009
    Location
    Hippiesoldierstan Norwich
    Beans
    2,326
    Distro
    Lubuntu 22.04 Jammy Jellyfish

    Re: mencoder script problem

    i tried in mkv and it does convert the video but doesn't embed the subs.
    ::]]



    if my suggestion is not of use to you i apologize. [it was only a thought]


    syntax here

    and to see tracks use


    First, use mkvmerge to list the MKV file’s contents:

    mkvmerge -i MovieFile.mkv
    You’ll see a listing similar to this:

    File 'MovieFile.mkv': container: Matroska
    Track ID 1: subtitles (S_TEXT/ASS)
    Track ID 2: audio (A_MPEG/L3)
    Track ID 3: video (V_MPEG4/ISO/AVC)
    Last edited by shantiq; March 26th, 2013 at 09:34 AM.
    Linux is Latin for off-the-beaten-track
    what I like MOST about our Ubuntu ... The Community ie 50 brains are better than one
    Playing with Slackware too now ...
    ShanArt

  5. #5
    Join Date
    Nov 2008
    Location
    Boston MetroWest
    Beans
    16,326

    Re: mencoder script problem

    Well after that less than informative response, let me ask a couple of questions.

    First, are you trying to create a standard DVD playable in a DVD player? When you say you want to "embed" the subtitles, do you mean you want to keep them as "soft" subtitles which can be switched on or off, or "hard" subtitles that are burned into the video image?

    Matroska (".mkv") is a container format that supports soft subtitles. In the script you posted, the subtitles are stored in a .srt file, but a Matroska file includes the subs as a "stream" just like the audio and video streams. You can extract the subs, and the audio and video streams, using mkvtoolnix, convert the video, and reassemble the result into a new Matroska file, but I don't think that is really what you are trying to do. Perhaps you can extract the subs to an .srt file then run your script.

    If you want to create a standard DVD from existing media files, I suggest trying DeVeDe. It's in the Ubuntu repositories. If that's not what you want to accomplish, why are you bothering with mpeg2, an old and inefficient format compared to modern mpeg4 derivatives like H.264?

    Mencoder was designed long ago and was targeted at producing AVI files from various material. I used it when H.264 was first released because my computer didn't have the horsepower to decode the more processor-intensive format. It was pretty foolproof for converting H.264-encoded videos in the Matroska container to XviD-encoded videos in the AVI container. Mencoder has been tweaked to try and keep up with changes in video technologies, but at this point it is pretty much a dead project. The mplayer2 developers, for instance, explicitly removed mencoder from their mplayer fork because the code was just too shoddy to warrant further development. You might want to look into using ffmpeg (aka avconv) instead.
    Last edited by SeijiSensei; March 26th, 2013 at 10:10 AM.
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  6. #6
    Join Date
    Jul 2009
    Location
    Hippiesoldierstan Norwich
    Beans
    2,326
    Distro
    Lubuntu 22.04 Jammy Jellyfish

    Re: mencoder script problem

    removed
    Last edited by shantiq; March 26th, 2013 at 12:55 PM.
    Linux is Latin for off-the-beaten-track
    what I like MOST about our Ubuntu ... The Community ie 50 brains are better than one
    Playing with Slackware too now ...
    ShanArt

  7. #7
    Join Date
    Nov 2008
    Location
    Boston MetroWest
    Beans
    16,326

    Re: mencoder script problem

    Your original post above mine originally read simply "::]]". I have no idea what this is supposed to mean. In general, smileys and their equivalents should be avoided in forums like this one with an emphasis on content and a worldwide audience. I notice that you have since added more content to your posting. I was responding to the original version which was, to say the least, uninformative.
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  8. #8
    Join Date
    Jul 2009
    Location
    Hippiesoldierstan Norwich
    Beans
    2,326
    Distro
    Lubuntu 22.04 Jammy Jellyfish

    Re: mencoder script problem

    oh Sensei terrible misunderstanding !!
    For some reason your browser only displayed a tiny portion of my reply [it was all there from the start!]

    i see it happens from time to time..... no worries.... it seemed right out of character [seen much of your good work on Forum previously]... hope you see it all now.. and i was not sure how much help mkvtoolnix and especially mkvmerge could help here but somehow always a better tool for mkv than mencoder for the reasons you mentioned; to see if it can b worked in into a script anyway best of luck to OP here.
    Last edited by shantiq; March 26th, 2013 at 12:56 PM.
    Linux is Latin for off-the-beaten-track
    what I like MOST about our Ubuntu ... The Community ie 50 brains are better than one
    Playing with Slackware too now ...
    ShanArt

  9. #9
    Join Date
    Feb 2012
    Beans
    45

    Re: mencoder script problem

    i have a crappy sony bravia TV that supports usb. for some reason this TV only responds well and foolproof to mpeg2 files and some avis. But mpeg2 is the guarantee way. and of course, the TV doesnt support external subs,so the only way its hardcoded. so what i.need is a way to convert every video (avi,mkv,mp4) to mpeg2, fast -no avidemux. i didnt actually knew tha mencoder is dead, so i'll take a look into mkvmerge.any other suggestions are welcome.

    p.s.every video i own has external srt subs, so no streams in any of my mkv's.
    Last edited by bbb13; March 26th, 2013 at 06:38 PM.

  10. #10
    Join Date
    Oct 2010
    Location
    London
    Beans
    482
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: mencoder script problem

    MKVmerge is a very useful tool in general, but I don't think it can do what you want. It can set up soft subtitles, but it can't burn them into the image (hardsub). Your best bet would be to use ffmpeg's subtitles filter. Assuming your input file is called 'input.mp4', and the subtitles file is called 'subtitle.srt':

    Code:
    ffmpeg -i input.mp4 -filter:v 'subtitles=subtitle.srt' -c:v mpeg2video -q:v 4 -c:a ac3 -ac 2 -ab 192k output.avi
    This will give you mpeg2 video, with a quantiser setting of 4 - this sets a sort of constant quality, rather than a bit rate (VBR, Variable Bit Rate). The range is 1-32, where lower=better quality and about 2-5 is generally a sensible range to use. You should consider using MPEG4 video, which will give you smaller/better quality files, and should be compatible with most DVD players, even most cheap ones. MPEG4 uses the same quantiser range as MPEG2.

    This command will also convert the audio to AC3 with two audio channels (so, stereo) and a constant bit rate of 192 kbit/s. AC3 is a standard part of DVD VOB files, so should be compatible. If you have surround-sound audio that you don't want to be downmixed to stereo, just ditch the '-ac 2' and dial the bit rate up to 384k. If you have some audio that you just want copied (because you're sure that it will work), use '-c:a copy' and ditch the other audio options.

    The following command will use MPEG4 video with an xvid tag (which some players need for some reason), and will simply copy the audio:

    Code:
    ffmpeg -i input.mp4 -filter:v 'subtitles=subtitle.srt' -c:v mpeg4 -q:v 4 -tag:v xvid -c:a copy output.avi
    Note that the version of ffmpeg in the Ubuntu repos is a crippled, fake version from the libav team. If you use avconv instead, that might work; you'd be best off either grabbing a static build from the downloads page or compiling it yourself. The Jon Severinsson PPA might be an option (I don't know if it has the subtitles filter yet).

    This blog post gives a decent general overview of useful delivery codecs & their usage with ffmpeg (though the information of VP8 is out of date).

Page 1 of 2 12 LastLast

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
  •