[MPlayer-users] Using .sub-Subtitles in mencoder possible?

Thomas Heuving heuving at gmx.de
Wed May 6 11:20:46 CEST 2009


Mark Blain schrieb am Mon, 4 May 2009 21:32:32 +0000 (UTC):
> Thomas Heuving <heuving at gmx.de> wrote in
> news:e4u1d6-unf.ln1 at ID-32009.user.uni-berlin.de: 
>
>> But -vobsub isn't a mencoder-Option, you can use it only with
>> mplayer.
>
> You are of course correct.  One way around this would be to pipe the output 
> of mplayer into mencoder with mkfifo.   That's beyond my meager skills, but 
> there's a sample script at:
>
> "Howto: create video DVDs from avi with .idx/.sub subtitles""

That was a great tip. Never thought about piping the output of mplayer
to mencoder. Here's my script, just in case anyone has the same
problem:
===============================

#!/bin/bash
# create MPEG2 from file with .idx/.sub subtitles
# requires: mencoder, mplayer
# Resulting file is named $(basename infile).mpg
# and therefore in the current Directory
USAGE="Usage: $(basename $0) <format (pal, ntsc or telecine)>
       <aspect (16/9 or 4/3)> <scale, eg 704:352 or something like that>
        <bitrate (e.g. 3000)> <vobsubid eg 0-31>
	<input filename without suffix>";

if [ $# -ne 6 ]; then
echo $USAGE;
exit 1;
fi

standard=$1;
aspect=$2;
scale=$3;
bitrate=$4;
vobsubid=$5;
infile=$6;
baseinfile=$(basename $infile);
if [ $standard = "telecine" ]
then
  format="format=dvd:tsaf:telecine -ofps 24000/1001";
else
  if [ $standard = "ntsc" ]
  then
    format="format=dvd:tsaf -ofps 30000/1001";
  else
    format="format=dvd:tsaf -ofps 25";
  fi
fi
streamfile=$baseinfile.yuv;
wavfile=$baseinfile.wav;
outfile=$baseinfile.mpg;

# mencoder options:
DVDFORMAT="-ovc lavc -of mpeg -mpegopts $format -vf $scale,harddup";
AUDIO2CHAN="-srate 48000 -af lavcresample=48000 -oac lavc ";
QUAL="-lavcopts acodec=ac3:abitrate=128:dc=10:vcodec=mpeg2video\
      -lavcopts vrc_buf_size=1835:vrc_maxrate=9000:vbitrate=$bitrate\
      -lavcopts keyint=15:trell:mbd=2:aspect=$aspect";

# create named pipe and convert to mpeg with subtitles:
if [ -e $streamfile ]; then
rm $streamfile;
fi
mkfifo $streamfile;
# Produce the audio
mplayer "$infile.avi" -dumpaudio -dumpfile $wavfile;
# Produce the video. It is put in stream.yuv and contains the
# subtitles
mplayer "$infile.avi" -vobsub "$infile" -vobsubid $vobsubid -nosound\
      -noframedrop -vo yuv4mpeg:file=$streamfile\
      < /dev/null > /dev/null 2>&1 &
sleep 10;
# Produce the MPEG2-Video with Subtitles and Sound
mencoder $streamfile -cache 1024 -audiofile $wavfile\
  $DVDFORMAT $QUAL $AUDIO2CHAN -o $outfile;
rm $wavfile $streamfile;

================================================================

Best regards
-- 
Thomas Heuving



More information about the MPlayer-users mailing list