Home Forums Gallery FAQs Downloads
 
 

Go Back   Meizu Me > General > Video and Imaging

Register Today!  

Yet Another Mencoder Script

This is a discussion on Yet Another Mencoder Script within the Video and Imaging forums, part of the General category; Since it was kinda hard to find it in the old thread, I've decided to give my script its own ...



Reply
 
Thread Tools Display Modes
Old 03-02-2008   #1
Passing By
 
Join Date: Oct 2007
Posts: 18
Yet Another Mencoder Script

Since it was kinda hard to find it in the old thread, I've decided to give my script its own one. This is a script to transcode videos for the Meizu M6.

To use, copy the code and paste it to a text file, save it somewhere (it'd be a good idea to save it in your $PATH) and make executable (chmod +x filename). Run without parameters for help. You can feed it any amount of files and it'll transcode them to the same directory, appending ".meizu.avi" to the name. If it finds any SRT or SUB files with the same name as the video file, it'll embed them in the video.

It requires mencoder and ffmpeg for aspect ratio detection.

Code:
#!/bin/bash
#
#       Redistribution and use in source and binary forms, with or without
#       modification, are permitted provided that the following conditions are
#       met:
#       
#       * Redistributions of source code must retain the above copyright
#         notice, this list of conditions and the following disclaimer.
#       * Redistributions in binary form must reproduce the above
#         copyright notice, this list of conditions and the following disclaimer
#         in the documentation and/or other materials provided with the
#         distribution.
#       * Neither the name of the  nor the names of its
#         contributors may be used to endorse or promote products derived from
#         this software without specific prior written permission.
#       
#       THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
#       "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
#       LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
#       A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
#       OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#       SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
#       LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
#       DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
#       THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
#       (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
#       OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#       Copyleft 2007 wishmechaos

#    Version 0.1, 21-oct-07
#    Version 0.2, 22-oct-07, Added ratio autodetect (requires ffmpeg),
#     small subtitle fix. Routine from 
#     http://tuxicity.wordpress.com/2006/12/01/avi-to-dvd-with-ffmpeg-and-dvdauthor/
#    Version 0.2.1, 12-feb-08, Fixed small bug when filename has spaces.
#    Version 0.3, 1-mar-08, Tuned mencoder parameters.
#    Version 0.3.1, 8-apr-08, Added color for messages. Warn if conversion fails.
#     Warn is ffmpeg/mencoder is not installed or failed.

# For debugging purposes
# set -x

### Defaults
# Frames per second (15-20)
fps=20

# Two pass encoding, takes longer, better quality
# yes / no
twopass=yes

# Crop settings.
# "auto" will try to detect if the source video is 4:3 or 16:9
#  and leave that intact.
# "yes" will leave 4:3 videos as they are, and will crop 16:9
#  videos in order to take up all of the screen.
crop="auto"

# Turn colored messages on/off.
color=on

# Video bitrate
vbitrate=350
# Audio bitrate
abitrate=112
# Sample rate
srate=44100
# Maximum Bitrate allowed
vrc_maxrate=460
# Buffer size
vrc_buf_size=1835
### End defaults

# Some common options
common="-idx -noodml -force-avi-aspect 1.3333 -msglevel mencoder=1 -ofps $fps -ovc lavc -ffourcc XVID"

if [[ "$color" = "on" ]]; then
RED=$(tput setaf 1;tput setab 0)
GREEN=$(tput setaf 2;tput setab 0)
BLUE=$(tput setaf 6;tput setab 0)
NORM=$(tput sgr0)
fi

show_help() {
    echo "Usage: `basename "$0"` [options] file1.avi [file2.avi...]
    Options are
    -h (show this)
    -c (crop) auto|yes
    -p (two-pass) yes|no
    -f (fps) 15-20
    -v (video bitrate) number
    -a (audio bitrate) number
    Subtitles are automatically loaded if their filename is the same as the movie file."
    exit 1
}

if ! hash mencoder 2>/dev/null; then
echo "    ${RED}Couldn't find mencoder. Please install it.${NORM}
    ${BLUE}In Debian/Ubuntu, type \"sudo apt-get install mencoder\"${NORM}"
exit 1
fi

# find subtitles with same filename
findsubs() {
    echo "    ${BLUE}Searching for subtitles.${NORM}"    
    for possiblefile in "$filename"*; do
        case $possiblefile in
            *.sub) subfile="$possiblefile";;
            *.srt) subfile="$possiblefile";;
        esac
    done
    if test -n "$subfile"; then
        echo "    ${GREEN}Found \"$subfile\"${NORM}"
        subs=(-noautoexpand -subpos 95 -subfont-autoscale 3 -subfont-outline 1 -subcp enca -sub "$subfile")
    else
    echo "    ${BLUE}No subtitles found.${NORM}"
    fi
}

aspectdetect() {
    if ! hash ffmpeg 2>/dev/null; then
    echo "    ${RED}Couldn't find ffmpeg. Please install it.${NORM}
    ${BLUE}In Debian/Ubuntu, type \"sudo apt-get install ffmpeg\"${NORM}"
    exit 1
    fi    

    aspect=$(( $(ffmpeg -i "$moviefile" 2>&1 | grep "Stream\ #0.0" | sed "s/.* \([1-9][0-9]*\)x\([0-9]*\).*/\10000 \/ \2/") ))
    if [[ $aspect -eq 0 ]]; then
    echo "    ${RED}Either ffmpeg is not working correctly or it couldn't stat your video file.${NORM}"
    echo "    ${RED}I'm assuming that crop=yes for this file${NORM}"
        vf="scale=-2:240,crop=320:240,expand=320:240:::1"
    elif [[ $aspect -lt 15555 ]]; then
        # 4:3
        echo "    ${GREEN}\"$moviefile\" appears to be 4:3${NORM}"
        vf="scale=-2:240,crop=320:240,expand=320:240:::1"
    else
        # 16:9
        echo "    ${GREEN}\"$moviefile\" appears to be Widescreen${NORM}"
        vf="scale=320:-2,crop=320:240,expand=320:240:::1"
    fi
}

return_error() {
    echo "${RED}    Mencoder failed for some reason. Check your logs.${NORM}"
    cleanUp
}

convert() {
    case $crop in
        auto) aspectdetect;;
        yes) vf="scale=-2:240,crop=320:240,expand=320:240:::1"
    esac
    
    if [[ "$twopass" == "no" ]]; then
        mencoder "${subs[@]}" -vf softskip,$vf,rotate=1 "$moviefile" $common -lavcopts threads=8:vcodec=mpeg4:mbd=2:trell:vbitrate=$vbitrate:vrc_maxrate=$vrc_maxrate:vrc_buf_size=$vrc_buf_size:vmax_b_frames=0:vhq:acodec=libmp3lame:abitrate=$abitrate:keyint=100:sc_factor=5 -sws 9 -srate $srate -oac lavc -af volnorm,delay=230:230 -o "$filename.meizu.avi" || return_error
    else
        #pass 1
        mencoder -nosound -vf softskip,$vf,rotate=1 "$moviefile" $common -lavcopts threads=8:vcodec=mpeg4:vpass=1:vbitrate=$vbitrate:vrc_maxrate=$vrc_maxrate:vrc_buf_size=$vrc_buf_size:vmax_b_frames=0:vhq:turbo -sws 9 -o "$filename.meizu.avi" || return_error
        #pass 2
        mencoder "${subs[@]}" -vf softskip,$vf,rotate=1 "$moviefile" $common -lavcopts threads=8:vcodec=mpeg4:mbd=2:trell:vpass=2:vbitrate=$vbitrate:vrc_maxrate=$vrc_maxrate:vrc_buf_size=$vrc_buf_size:vmax_b_frames=0:vhq:acodec=libmp3lame:abitrate=$abitrate:keyint=100:sc_factor=5 -sws 9 -srate $srate -oac lavc -af volnorm,delay=230:230 -o "$filename.meizu.avi" || return_error
        rm divx2pass.log
    fi

    echo "${GREEN}    Finished converting $moviefile ${NORM}"
}

cleanUp() {
    echo "    ${RED}Deleting temporary files.${NORM}"    
    rm "$filename.meizu.avi" >/dev/null 2>&1
    rm divx2pass.log >/dev/null 2>&1
    exit 1
}
trap cleanUp INT

# If there're no arguments
if [ $# = 0 ]; then show_help; fi

# Parse arguments
x=1         # Avoids an error if we get no options at all.
while getopts "hc:pf:" opt; do
    case "$opt" in
        h|\?) show_help;;
        c) crop="$OPTARG";;
        p) twopass="$OPTARG";;
        f) fps="$OPTARG";;
        a) abitrate="$OPTARG";;
        v) vbitrate="$OPTARG";;
    esac
    x=$OPTIND
done
shift $((x-1))

for moviefile in "$@"; do
    if [[ -f "$moviefile" ]]; then
        echo "    ${BLUE}Moviefile is \"$moviefile\"${NORM}"
        extension=".${moviefile##*.}"
        echo "    ${BLUE}Extension is $extension${NORM}"
        filename="`basename "$moviefile" "$extension"`"
        echo "    ${BLUE}Filename is therefore \""$filename"\"${NORM}"
        # ugly way to do it, works though.
        if [[ "$moviefile" != "${moviefile%/*}" ]]; then cd "${moviefile%/*}"; fi
        findsubs
        echo "    ${GREEN}Converting \"$moviefile\"${NORM}"
        convert
    else
        echo "    ${RED}\""$moviefile"\" doesn't exist.${NORM}"
    fi
done
If you use Gnome and want quick access, you can place a little helper script in ~/gnome2/nautilus-scripts and it'll add an option to your right-click menu. In my case, the main script is called "meizu-convert" and it's placed in my $PATH (/usr/local/bin in this case). Change it to whatever you called the main script, and if it's not in your path, be sure to add the full path (as in /home/me/scripts/nameofmainscript). It's a bit redundant, but I couldn't think of a better way to do it.

Code:
#!/bin/sh
for moviefile in "$@"; do
    gnome-terminal -x meizu-convert "$moviefile"
done
Hope it's useful. If you spot any errors or have any suggestions, please let me know.

Last edited by wishmechaos; 04-08-2008 at 08:30 AM.. Reason: new version
wishmechaos nincs online   Reply With Quote
Old 03-10-2008   #2
Passing By
 
Join Date: Jan 2008
Posts: 7
that's intresting.

have you found that bitrate=460 is the maximum the meizu m6 can play? i've been trying to find the maximum without skipping.
lambchops468 nincs online   Reply With Quote
Old 03-10-2008   #3
Passing By
 
Join Date: Oct 2007
Posts: 18
Nope, it's just BatMan's Q4, which I find good enough.

Cheers.
wishmechaos nincs online   Reply With Quote
Old 03-10-2008   #4
Member
 
Join Date: Nov 2007
Posts: 108
Originally Posted by lambchops468 View Post
that's intresting.

have you found that bitrate=460 is the maximum the meizu m6 can play? i've been trying to find the maximum without skipping.
460 or so is very close to what the M6 cpu can handle without at first frame droping, or worse having some short image freezes

the M6 cpu is quite low in power , so you really never know how many frames are truely decoded and screened from such a 460kbits movie; *only* a fast shutter apn and multiple time consuming tests could tell

that is , most probably, the frame 'fluctuates' ; and if this goes too far it ends in a sensation of not fluent smooth/even frame rate

not to forget that BobbyQ ( Batman's author) believed , having used of a max bit rate parameter , he had set some "clip" value for the bit rate; but indeed he was wrong ; this I proved this in some 'contest' where the Q5 profile would have problems , this due to peak bit rate overshoots quite beyond the max value he believed having set in Q5 (but also to more complex issues)

Batman 2008 ..stutters !

you can see that the Q5 Batman 'demo' movie *has* peak bit rates up to 800kbits ; which means =>

in the end --the codec-- rules ! ( with VBR and a target bit rate)

and , imho, as for a correct bit rate value with the M6 , there is very little interest , if any, going up to 460kbps ; keeping to 350k will deliver just about the very same quality on the tiny 2.4" M6 screen

I like Batman for simple straight simple encoding , but I keep with VDub (and XviD) for more precise things ; especially when it comes to decisions on cropings ; for instance if you have to remove garbage side bars on video stuff , or have to crop/resize 2:35 clean film source to M6 4/3 ratio

the other more difficult issue of encoding for the M6 is due to the overboosted lcd screen ; this can cause blacks turn as dark greys ; and then compression blockiness/pixelation becomes quite visible in these dark areas :/ ; and only shifting up the black level when encoding can be no cure at all sometimes ...

wishmechaos >> Nope, it's just BatMan's Q4, which I find good enough.

definitely
trane nincs online   Reply With Quote
Old 03-27-2008   #5
Passing By
 
Join Date: Mar 2008
Posts: 4
Thanks for the script givemechaos

Before I tried yours I tried to add a single item to Nautilus-actions with mencoder and this code
Code:
%M -idx -noodml -ofps 20 -vf scale=320:-2,expand=:240:::1,crop=320:240,rotate=1 -ovc lavc -ffourcc XVID -lavcopts vcodec=mpeg4:vbitrate=384:vmax_b_frames=0:vhq -sws 9 -srate 44100 -oac mp3lame -lameopts cbr:br=192:mode=0 -o %M[mz].avi
It encoded my .avi files all right, but the sound was bad with all the files I tried.

So I was eager to try your script, especially with the .SRT embedding thing, and gave it a try yesterday but didn't manage anything.
I am still a newbie with linux, it took me more than an hour :eek: to make those first 2 scripts, make them executable and so on.

So I made my main script after yours, made it executable and put it in my Documents folder. (I didn't understand what you call "my $PATH", I use the latest Ubuntu)
Then I created the second helper script in ~/gnome2/nautilus-scripts, made it executable and carefully added the full path. For me :
Code:
#!/bin/sh
for moviefile in "$@"; do
    gnome-terminal -x /home/rem/Documents/meizuconvert.sh "$moviefile"
done
So when I right-click a video file, I do have the "script" menu with its "meizuconvert.sh" item but nothing happens when I launch it.

Obviously I must have missed something, so any help appreciated, I just *hate* having to reboot win to use Virtualdub
DrScholl nincs online   Reply With Quote
Old 03-27-2008   #6
Passing By
 
Join Date: Oct 2007
Posts: 18
It's weird that it doesn't work, since it seems you followed every step correctly. $PATH is a global variable that says where should the system look for executables. You can check it in a terminal by typing 'echo $PATH'; putting the script in any folder in your $PATH makes it possible to just type 'meizu-convert' (or whatever you called it) instead of '/home/me/blah/script'. In my case, I have a folder called 'bin' in my home, and I added ~/bin to my $PATH (edit ~/.bashrc and add 'PATH=$PATH:~/bin', or if there's already a PATH= line, just add :~/bin to it)

Anyway, the helper script isn't essential. Just open a terminal, type '/home/rem/Documents/meizuconvert.sh ' (notice the trailing space) and drag and drop the video files from the file manager.

Cheers
wishmechaos nincs online   Reply With Quote
Old 03-29-2008   #7
Passing By
 
Join Date: Mar 2008
Posts: 4
Thanks for the quick answer !

Here's what happens when I do what you suggest :
Code:
rem@ubuntu-rem:~$ '/home/rem/Documents/meizuconvert.sh ''/home/rem/Vidéos/Breaking Bad/Breaking.Bad.S01E04.avi' '/home/rem/Vidéos/Breaking Bad/Breaking.Bad.S01E04.DSR.XviD-BayHarborButcher.srt' 
bash: /home/rem/Documents/meizuconvert.sh /home/rem/Vidéos/Breaking Bad/Breaking.Bad.S01E04.avi: Aucun fichier ou répertoire de ce type
rem@ubuntu-rem:~$
The french bit means : no such file or directory
I still feel dim witted with the terminal, but I have to ask and improve...
DrScholl nincs online   Reply With Quote
Old 03-29-2008   #8
Passing By
 
Join Date: Oct 2007
Posts: 18
Originally Posted by DrScholl View Post
Code:
rem@ubuntu-rem:~$ '/home/rem/Documents/meizuconvert.sh ''/home/rem/Vidéos/Breaking Bad/Breaking.Bad.S01E04.avi' '/home/rem/Vidéos/Breaking Bad/Breaking.Bad.S01E04.DSR.XviD-BayHarborButcher.srt' 
bash: /home/rem/Documents/meizuconvert.sh /home/rem/Vidéos/Breaking Bad/Breaking.Bad.S01E04.avi: Aucun fichier ou répertoire de ce type
It seems you're quoting the entire command, and you're also feeding meizuconvert.sh the subtitle name. Subtitles are automatically detected when they have the same filename as the .avi, for simplicity's sake (in this case it seems they aren't, so you should rename the sub file to "Breaking.Bad.S01E04.srt").

The correct command would be (notice the quoting):

$ /home/rem/Documents/meizuconvert.sh ''/home/rem/Vidéos/Breaking Bad/Breaking.Bad.S01E04.avi"
(the filename would be dragged-and-dropped, double quotes or single quotes don't matter as long as it's consistent)

you'd put a ' in the start of the command, so bash (the command line software itself) interprets it as a whole file, which it doesn't find (it's searching for a file named "/home/rem/Documents/meizuconvert.sh /home/rem/Vidéos/Breaking Bad/Breaking.Bad.S01E04.avi")

cheers.
wishmechaos nincs online   Reply With Quote
Old 03-30-2008   #9
Passing By
 
Join Date: Mar 2008
Posts: 4
Thanks for your patient explanations.

Thanks to them I managed to launch the conversion by dragging the files like you said.
Mencoder went on for a while, but the result file has a wrong size (o byte) and can't be read.
Here's what the terminal says :
Code:
Please supply the text font file (~/.mplayer/subfont.ttf).
subtitle font: load_sub_face failed.
New_Face failed. Maybe the font path is wrong.in 101mb  A-V:0.000 [326:0]
Please supply the text font file (~/.mplayer/subfont.ttf).
subtitle font: load_sub_face failed.
Writing index...27f (99%) 168.28fps Trem:   0min 101mb  A-V:0.000 [326:0]
Writing header...
ODML: vprp aspect is 4:3.
MEncoder 2:1.0~rc1-0ubuntu13.2 (C) 2000-2006 MPlayer Team
CPU: AMD Athlon(tm) 64 X2 Dual Core Processor 4400+ (Family: 15, Model: 107, Stepping: 2)
CPUflags: Type: 15 MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.
success: format: 0  data: 0x0 - 0x15e01556
AVI file format detected.
VIDEO:  [XVID]  624x352  24bpp  23.976 fps  993.5 kbps (121.3 kbyte/s)
==========================================================================
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
AUDIO: 48000 Hz, 2 ch, s16le, 128.0 kbit/8.33% (ratio: 16000->192000)
Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3)
==========================================================================
SUB: Detected subtitle file format: subviewer
SUB: error opening iconv descriptor.
SUB: Read 1003 subtitles.
SUB: Adjusted 3 subtitle(s).
Opening video filter: [rotate=1]
Opening video filter: [expand w=320 h=240 osd=1]
Expand: 320 x 240, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
Opening video filter: [crop w=320 h=240]
Crop: 320 x 240, -1 ; -1
Opening video filter: [scale w=320 h=-2]
Opening video filter: [softskip]
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffodivx] vfm: ffmpeg (FFmpeg MPEG-4)
==========================================================================
Audio LAVC, couldn't find encoder for codec libmp3lame.
 Finished converting /home/rem/Vidéos/Bones.S03E01.HDTV.XviD-XOR.avi
The first 2 sentences were repeated many times.
DrScholl nincs online   Reply With Quote
Old 03-30-2008   #10
Passing By
 
Join Date: Oct 2007
Posts: 18
The first lines probably mean you probably haven't installed mplayer-fonts. Try 'sudo apt-get install mplayer-fonts'

The other issue, I'm not so sure of. Maybe you're missing some codecs, or maybe a matter of naming conventions. Could you try opening the script with a text editor and replacing all instances of 'libmp3lame' with 'mp3lame'? There should only be 2.

Cheers.
wishmechaos nincs online   Reply With Quote
Old 03-30-2008   #11
Passing By
 
Join Date: Mar 2008
Posts: 4
Actually mplayer and mplayer lib were not installed.
So I installed them and also modified the script.
There's some progress but errors again.
Here's my last attempt :
Code:
rem@ubuntu-rem:~$ /home/rem/Documents/meizuconvert.sh '/home/rem/Vidéos/Breaking Bad/Breaking.Bad.S01E04.avi' 
Moviefile is /home/rem/Vidéos/Breaking Bad/Breaking.Bad.S01E04.avi
Extension is .avi
Filename is therefore Breaking.Bad.S01E04
Found Breaking.Bad.S01E04.srt.
Converting /home/rem/Vidéos/Breaking Bad/Breaking.Bad.S01E04.avi
/home/rem/Vidéos/Breaking Bad/Breaking.Bad.S01E04.avi appears to be Widescreen
MEncoder 2:1.0~rc1-0ubuntu13.2 (C) 2000-2006 MPlayer Team
CPU: AMD Athlon(tm) 64 X2 Dual Core Processor 4400+ (Family: 15, Model: 107, Stepping: 2)
CPUflags: Type: 15 MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.
success: format: 0  data: 0x0 - 0x15e0a800
AVI file format detected.
AVI_NI: No audio stream found -> no sound.
VIDEO:  [XVID]  624x352  12bpp  23.976 fps  891.5 kbps (108.8 kbyte/s)
Opening video filter: [expand osd=1]
Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
Opening video filter: [rotate=1]
Opening video filter: [expand w=320 h=240 osd=1]
Expand: 320 x 240, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
Opening video filter: [crop w=320 h=240]
Crop: 320 x 240, -1 ; -1
Opening video filter: [scale w=320 h=-2]
Opening video filter: [softskip]
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffodivx] vfm: ffmpeg (FFmpeg MPEG-4)
==========================================================================
VDec: vo config request - 624 x 352 (preferred colorspace: Planar YV12)
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is 1.77:1 - prescaling to correct movie aspect.
SwScaler: reducing / aligning filtersize 13 -> 12
SwScaler: reducing / aligning filtersize 13 -> 12
SwScaler: reducing / aligning filtersize 13 -> 12
SwScaler: reducing / aligning filtersize 13 -> 12

SwScaler: Lanczos scaler, from yuv420p to yuv420p using MMX2
SwScaler: using n-tap MMX scaler for horizontal luminance scaling
SwScaler: using n-tap MMX scaler for horizontal chrominance scaling
SwScaler: using n-tap MMX scaler for vertical scaling (YV12 like)
SwScaler: 624x352 -> 320x180
Writing header...1f ( 0%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
ODML: vprp aspect is 4:3.
Writing header...
ODML: vprp aspect is 4:3.
Writing index...53f (99%) 213.12fps Trem:   0min 116mb  A-V:0.000 [343:0]
Writing header...
ODML: vprp aspect is 4:3.
MEncoder 2:1.0~rc1-0ubuntu13.2 (C) 2000-2006 MPlayer Team
CPU: AMD Athlon(tm) 64 X2 Dual Core Processor 4400+ (Family: 15, Model: 107, Stepping: 2)
CPUflags: Type: 15 MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.
success: format: 0  data: 0x0 - 0x15e0a800
AVI file format detected.
VIDEO:  [XVID]  624x352  12bpp  23.976 fps  891.5 kbps (108.8 kbyte/s)
==========================================================================
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
AUDIO: 48000 Hz, 2 ch, s16le, 128.0 kbit/8.33% (ratio: 16000->192000)
Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3)
==========================================================================
SUB: Detected subtitle file format: subviewer
SUB: error opening iconv descriptor.
SUB: Read 540 subtitles.
SUB: Adjusted 22 subtitle(s).
Opening video filter: [rotate=1]
Opening video filter: [expand w=320 h=240 osd=1]
Expand: 320 x 240, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
Opening video filter: [crop w=320 h=240]
Crop: 320 x 240, -1 ; -1
Opening video filter: [scale w=320 h=-2]
Opening video filter: [softskip]
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffodivx] vfm: ffmpeg (FFmpeg MPEG-4)
==========================================================================
Audio LAVC, couldn't find encoder for codec mp3lame.
 Finished converting /home/rem/Vidéos/Breaking Bad/Breaking.Bad.S01E04.avi
I tried to see what codecs mencoder installed
Code:
 mencoder -oac help
MEncoder 2:1.0~rc1-0ubuntu13.2 (C) 2000-2006 MPlayer Team
CPU: AMD Athlon(tm) 64 X2 Dual Core Processor 4400+ (Family: 15, Model: 107, Stepping: 2)
CPUflags: Type: 15 MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.

Available codecs:
   copy     - frame copy, without re-encoding (useful for AC3)
   pcm      - uncompressed PCM audio
   mp3lame  - cbr/abr/vbr MP3 using libmp3lame
   lavc     - FFmpeg audio encoder (MP2, AC3, ...)
   faac     - FAAC AAC audio encoder
DrScholl nincs online   Reply With Quote
Old 04-08-2008   #12
Passing By
 
Join Date: Oct 2007
Posts: 18
if mplayer wasn't installed, then that explains the subfont issue. I've uploaded a new version with some corrections, try it out and see if it works for you. Cheers.

Last edited by wishmechaos; 04-08-2008 at 08:29 AM..
wishmechaos nincs online   Reply With Quote
Old 05-21-2008   #13
Lev Lev is on a distinguished road
Stalker
 
Join Date: May 2008
Location: Overasselt/Delft
Posts: 1
My Meizu
a Tip for Ubuntu 8.04 users, ~/bin/ is in the search-path of the console, so by placing the script in here you can just use meizu-convert MOVIEFILE
Lev nincs online   Reply With Quote
Old 05-21-2008   #14
Passing By
 
Join Date: Oct 2007
Posts: 18
Originally Posted by Lev View Post
a Tip for Ubuntu 8.04 users, ~/bin/ is in the search-path of the console, so by placing the script in here you can just use meizu-convert MOVIEFILE
That's what I meant when I said it's useful to place the script in $PATH. In a console you can type 'echo $PATH' to print all "search-paths"... ~/bin and /usr/local/bin are the usual places to put a script in.

Cheers
wishmechaos nincs online   Reply With Quote
Old 08-23-2008   #15
Passing By
 
Join Date: Jun 2008
Posts: 2
Originally Posted by wishmechaos View Post
Since it was kinda hard to find it in the old thread, I've decided to give my script its own one. This is a script to transcode videos for the Meizu M6.
Thanks a lot for script, mate. I had integrated it in Gnome. Nice working for 1 or multi files.

Can you help me to improve it? I have another device - SonyEricsson mobile phone. I added in the end of script:

ffmpeg -i "$filename.meizu.avi" -f mp4 -r 20 -b 192000 -y -acodec aac -ab 64 -vol 512 "$filename.k790.mp4"
del "$filename.meizu.avi"

It works for 1 file only as i need.
Where do I have to put this for multi files converting?

I meen commands like this: meizu-convert 1.avi 2.avi 3.avi
mangust22 nincs online   Reply With Quote
Old 08-23-2008   #16
Passing By
 
Join Date: Oct 2007
Posts: 18
Originally Posted by mangust22 View Post
I added in the end of script:

ffmpeg -i "$filename.meizu.avi" -f mp4 -r 20 -b 192000 -y -acodec aac -ab 64 -vol 512 "$filename.k790.mp4"
del "$filename.meizu.avi"

It works for 1 file only as i need.
Where do I have to put this for multi files converting?
If you're using single pass, you have to put that line below this mencoder line. Are you converting the already transcoded file into another format?

Code:
if [[ "$twopass" == "no" ]]; then
        mencoder "${subs[@]}" -vf softskip,$vf,rotate=1 "$moviefile" $common -lavcopts threads=8:vcodec=mpeg4:mbd=2:trell:vbitrate=$vbitrate:vrc_maxrate=$vrc_maxrate:vrc_buf_size=$vrc_buf_size:vmax_b_frames=0:vhq:acodec=libmp3lame:abitrate=$abitrate:keyint=100:sc_factor=5 -sws 9 -srate $srate -oac lavc -af volnorm,delay=230:230 -o "$filename.meizu.avi" || return_error
ffmpeg -i "$filename.meizu.avi" -f mp4 -r 20 -b 192000 -y -acodec aac -ab 64 -vol 512 "$filename.k790.mp4"
rm "$filename.meizu.avi"
If you're using two-pass encoding, then you should place the line twice under the "if [[ "$twopass" == "no" ]]", but you'd have to modify your command to somehow do twopass encoding.

Cheers
wishmechaos nincs online   Reply With Quote
Old 08-24-2008   #17
Passing By
 
Join Date: Jun 2008
Posts: 2
it's what exactly I need. Thanks a lot!
mangust22 nincs online   Reply With Quote
Old 3 Weeks Ago   #18
Passing By
 
Join Date: Mar 2008
Posts: 4
Hi wishmechaos, this is the best script I've found so far. I did some minor tweaks a while ago that I'd like to share. mainly I did some tweaks on subs size and placement and dropped requirement for ffmpeg. Also I found the double pass feature to be broken so I changed it. Now if you pass -p it will do double pass and will not if you omit it.
I've noticied that you did some tweaks also since I downloaded it, should have sent you these changes a while back.

Code:
#!/bin/bash
#
#       Redistribution and use in source and binary forms, with or without
#       modification, are permitted provided that the following conditions are
#       met:
#       
#       * Redistributions of source code must retain the above copyright
#         notice, this list of conditions and the following disclaimer.
#       * Redistributions in binary form must reproduce the above
#         copyright notice, this list of conditions and the following disclaimer
#         in the documentation and/or other materials provided with the
#         distribution.
#       * Neither the name of the  nor the names of its
#         contributors may be used to endorse or promote products derived from
#         this software without specific prior written permission.
#       
#       THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
#       "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
#       LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
#       A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
#       OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#       SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
#       LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
#       DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
#       THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
#       (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
#       OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#       Copyleft 2007, 2008 wishmechaos
#
#        Version 0.1, 21-oct-07
#        Version 0.2, 22-oct-07, Added ratio autodetect (requires ffmpeg),
#            small subtitle fix.
#             routine from http://tuxicity.wordpress.com/2006/12/01/avi-to-dvd-with-ffmpeg-and-dvdauthor/
#        Version 0.2.1, 12-feb-08, Fixed small bug when filename has spaces.
#        Version 0.3, 1-mar-08, Tuned mencoder parameters.
#        Version 0.4, 20-mar-08, fixed double pass and subtitles loading
#        version 0.5, 17-oct-08, detect ratio using file rather than ffmpeg, 
#           dropping requirement for ffmpeg

# For debugging purposes
# set -x

### Defaults
# Frames per second (15-20)
fps=20

# Two pass encoding, takes longer, better quality
# yes / no
twopass=no

# Crop settings.
# "auto" will try to detect if the source video is 4:3 or 16:9
#  and leave that intact.
# "yes" will leave 4:3 videos as they are, and will crop 16:9
#  videos in order to take up all of the screen.
crop="auto"

# Video bitrate
vbitrate=350
# Audio bitrate
abitrate=112
# Sample rate
srate=44100
# Maximum Bitrate allowed
vrc_maxrate=460
# Buffer size
vrc_buf_size=1835
### End defaults

# Some common options
common="-idx -noodml -force-avi-aspect 1.3333 -msglevel mencoder=1 -ofps $fps -ovc lavc -ffourcc XVID"

show_help() {
    echo "Usage: `basename "$0"` [-h(elp)] [-c(rop) auto yes] [-p (two-pass)] [-f(ps) number]
    [-v(ideo bitrate) number] [-a(udio bitrate) number] file1.avi [file2.avi...]
    Subtitles are automatically loaded if their filename is the same as the movie file"
    exit 1
}

# find subtitles with same filename
findsubs() {
    for possiblefile in "$filename"*; do
        case $possiblefile in
            *.sub) subfile="$possiblefile";;
            *.srt) subfile="$possiblefile";;
        esac
    done
    if test -n "$subfile"; then #if [[ "$subfile" != "" ]]; then
        echo "Found $subfile."
        subs=(-noautoexpand -subpos 95 -subfont-autoscale 3 -subfont-outline 1 -subcp enca -sub "$subfile")
    fi
}

aspectdetect() {
    aspect=$(( $(file "$moviefile" | sed "s/.* \([1-9][0-9]*\) x \([0-9]*\).*/\10000 \/ \2/") ))
    
    if [[ $aspect -lt 15555 ]]; then
        # 4:3
        echo "$moviefile appears to be 4:3"
        vf="scale=-2:240,crop=320:240,expand=320:240:::1"
    else
        # 16:9
        echo "$moviefile appears to be Widescreen"
        vf="scale=320:-2,crop=320:240,expand=320:240:::1"
    fi
}

convert() {
    case $crop in
        auto) aspectdetect;;
        yes) vf="scale=-2:240,crop=320:240,expand=320:240:::1"
    esac
    
    if [[ "$twopass" == "no" ]]; then
        mencoder "${subs[@]}" -vf softskip,$vf,rotate=1 "$moviefile" $common -lavcopts threads=8:vcodec=mpeg4:mbd=2:trell:vbitrate=$vbitrate:vrc_maxrate=$vrc_maxrate:vrc_buf_size=$vrc_buf_size:vmax_b_frames=0:vhq:acodec=libmp3lame:abitrate=$abitrate:keyint=100:sc_factor=5 -sws 9 -srate $srate -oac lavc -af volnorm,delay=230:230 -o "$filename.meizu.avi"
    else
        #pass 1
        mencoder -nosound -vf softskip,$vf,rotate=1 "$moviefile" $common -lavcopts threads=8:vcodec=mpeg4:vpass=1:vbitrate=$vbitrate:vrc_maxrate=$vrc_maxrate:vrc_buf_size=$vrc_buf_size:vmax_b_frames=0:vhq:turbo -sws 9 -o "$filename.meizu.avi"
        #pass 2
        mencoder "${subs[@]}" -vf softskip,$vf,rotate=1 "$moviefile" $common -lavcopts threads=8:vcodec=mpeg4:mbd=2:trell:vpass=2:vbitrate=$vbitrate:vrc_maxrate=$vrc_maxrate:vrc_buf_size=$vrc_buf_size:vmax_b_frames=0:vhq:acodec=libmp3lame:abitrate=$abitrate:keyint=100:sc_factor=5 -sws 9 -srate $srate -oac lavc -af volnorm,delay=230:230 -o "$filename.meizu.avi"
        rm divx2pass.log
    fi

    echo " Finished converting $moviefile"
}

cleanUp() {
    rm "$filename.meizu.avi"
    rm divx2pass.log
    exit 1
}
trap cleanUp INT

# If there're no arguments
if [ $# = 0 ]; then show_help; fi

# Parse arguments
x=1         # Avoids an error if we get no options at all.
while getopts "hc:pf:" opt; do
    case "$opt" in
        h|\?) show_help;;
        c) crop="$OPTARG";;
        p) twopass="yes";;
        f) fps="$OPTARG";;
        a) abitrate="$OPTARG";;
        v) vbitrate="$OPTARG";;
    esac
    x=$OPTIND
done
shift $((x-1))

for moviefile in "$@"; do
    if [[ -f "$moviefile" ]]; then
        echo "Moviefile is $moviefile"
        extension=".${moviefile##*.}"
        echo "Extension is $extension"
        filename="`basename "$moviefile" "$extension"`"
        echo "Filename is therefore "$filename""
        # ugly way to do it, works though.
        if [[ "$moviefile" != "${moviefile%/*}" ]]; then cd "${moviefile%/*}"; fi
        findsubs
        echo "Converting $moviefile"
        convert
    else
        echo ""$moviefile" doesn't exist."
    fi
done
dudus nincs online   Reply With Quote
Reply


Thread Tools
Display Modes

Hot Deals for Meizu & Related Products Related Threads
All times are GMT. The time now is 06:23 PM.







   
 
Meizu Me is an independent resource for all things Meizu. All rights reserved. Powered by vBulletin. Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc. Meizu M8, miniPlayer and all related names are properties of MEIZU Electronic Technology, Inc. Copyright 2008 Meizu Me.