Quantcast FFmpeg: What a Better Script with a Subtitle ??? - digitalFAQ.com Forums [Archives]
Go Back    digitalFAQ.com Forums [Archives] > Video Production Forums > Video Encoding and Conversion

Reply
 
LinkBack Thread Tools
  #1  
01-01-2004, 11:05 AM
otzi otzi is offline
Free Member
 
Join Date: Nov 2003
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
I using script maded by TETRA and working fine but its slowly ...
Somebody have a script more fast ?

or tetra script have upgrade ?
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Site Staff / Ad Manager
 
Join Date: Dec 2002
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
  #2  
01-01-2004, 12:36 PM
Dialhot Dialhot is offline
Free Member
 
Join Date: May 2003
Posts: 10,463
Thanks: 0
Thanked 0 Times in 0 Posts
As we can't know every script than run around the world, can you copy this script there ?
Reply With Quote
  #3  
01-01-2004, 01:46 PM
otzi otzi is offline
Free Member
 
Join Date: Nov 2003
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Dialhot
As we can't know every script than run around the world, can you copy this script there ?

Code:
#!/bin/bash
#
# Copyright (C) 2003-2038 russiansexpat
# Portions taken from paranouei's scripts
#
# Modified by tetra
# script: mpeg(1,2,3,4) conversion to (S,X)VCD with quantisation matrix
# and auto-splitting into multiple CDs and writing them.
#
# requires: mencoder mplayer ffmpeg tcmplex vcdimager cdrdao


#!!!!!!!!!!!!!! below you can edit parameters !!!!!!!!!!!!!!!!!!!!!!

# Storage medium size
#---------------------------------------------------------------
#CDSIZE=735             # 74min CD
CDSIZE=795             # 80min CD
#CDSIZE=895             # 90min CD
AUDIORATE=128
#---------------------------------------------------------------


# Subtitle settings
#---------------------------------------------------------------
# These settings look good with arialbd.ttf font
blur=2
#font="/home/alexandre/.kde/share/fonts/TrueType/arialbd.ttf"
font="/home/alexandre/.mplayer/subfont.ttf"
subpos=65
textscale=4
outline=2
autoscale=2
#---------------------------------------------------------------

# FPS settings
#---------------------------------------------------------------
#FPS=",telecine,lavcdeint -fps 29.97 -ofps 29.97"
#FPS=" -ofps 29.97" # NTSC
FPS=" -ofps 25" # PAL
#FPS=" -ofps 23.976" # NTSC pulldowned
#FPS=",ivtc=1 -ofps 23.976"
#---------------------------------------------------------------

# Optional filters
#---------------------------------------------------------------
VFILTER="hqdn3d,"
#LAVCOPTS=":vlelim=-4:vcelim=7:lumi_mask=0.05:dark_mask=0.01"
LAVCOPTS=""
#---------------------------------------------------------------


# Pass
#---------------------------------------------------------------
PASS="single"
#PASS="1st 2nd"
#---------------------------------------------------------------

# Verbosity
#---------------------------------------------------------------
NOTverbose="2> /dev/null"      # I want to see what is going on
#NOTverbose="&> /dev/null"      # I don't care what's going on
#---------------------------------------------------------------

# Target type settings
#---------------------------------------------------------------

# for VideoCD (VCD)
#WID=352
#HEI=240
#HEI=288
#VCODEC=mpeg1video
#MUXMODE="-m 1 -F tcmplex.tmp"
#IMAMODE="-t vcd2"


# for SuperVideoCD (SVCD)
WID=480
HEI=480      # NTSC??
#HEI=576      # This is for PAL
VCODEC=mpeg2video
MUXMODE="-m 2 -F tcmplex.tmp"
IMAMODE="-t svcd"

# CD-burner device ID (for a list of your devices, type 'cdrdao scanbus')
CDDEV="--device 0,0,0"

# Movie length in seconds
DEFAULT_MOVIE_SECONDS=6800

# !!!!!!!!!!!!!!!!!!!!! above you can edit parameters !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

echo "maxFileSize = $CDSIZE" > tcmplex.tmp

CDOPT="--force --reload --eject --speed 4 --overburn --driver generic-mmc"


# Find out if we have a subtitle-file to be hard encoded
FILE=$2
tmp=`echo $FILE | sed s/\.avi//`
SUB=""
[ -f "${tmp}".sub ]  && SUB="-sub ${tmp}.sub"
[ -f "${tmp}".srt ] && SUB="-sub ${tmp}.srt"


# Get some necessary information
# Taken from paranouei's scripts
tcprobe -i "${FILE}" > info
if [ $? -eq 0 ]; then

   ORIGFPS=`grep 'frame rate' info | \
     perl -e ' $line=<STDIN> ; $line =~ /frame rate: -f (.+?) \[/  ;  print $1' `

   ORIGFPS_1=`echo "scale=1 ; $ORIGFPS/1"| bc -l`

   WIDTH=`grep 'import frame size' info | \
     perl -e ' $line=<STDIN> ; $line =~ /import frame size: -g (\d+?)x\d+ /  ;  print $1' `

   HEIGHT=`grep 'import frame size' info | \
     perl -e ' $line=<STDIN> ; $line =~ /import frame size: -g \d+?x(\d+) /  ;  print $1' `

   FRAMES=`grep '\[avilib\] V:' info | \
     perl -e ' $line=<STDIN> ; $line =~ /frames=(\d+)/  ;  print $1' `
else
   mplayer -ao null -vo null -frames 10 "$FILE" > info
   WIDTH=`grep 'VIDEO' info | \
     perl -e ' $line=<STDIN> ; $line =~ / (\d+)x\d+ /  ;  print $1' `
   HEIGHT=`grep 'VIDEO' info | \
     perl -e ' $line=<STDIN> ; $line =~ / \d+x(\d+) /  ;  print $1' `
   ORIGFPS=`grep 'VIDEO' info | \
     perl -e ' $line=<STDIN> ; $line =~ /\s(\S+)\sfps/  ;  print $1' `
   ORIGFPS=`echo "$ORIGFPS"| tr , .`
   ORIGFPS_1=`echo "scale=1 ; $ORIGFPS/1"| bc -l`
fi

SEGUNDOS_TOTAL=`echo "scale=0 ; ($FRAMES / $ORIGFPS)"| bc -l`

#If couldn't get the length, use the default
[ "$SEGUNDOS_TOTAL" == "" ] && SEGUNDOS_TOTAL=$DEFAULT_MOVIE_SECONDS
HORAS=`echo "scale=0 ; ($SEGUNDOS_TOTAL / 3600)"| bc -l`
MINUTOS=`echo "scale=0 ; (($SEGUNDOS_TOTAL - \
  3600 * $HORAS)/60)"| bc -l`
SEGUNDOS=`echo "scale=0 ; ($SEGUNDOS_TOTAL % 60)"| bc -l`

# Calculate variable videobitrate
VIDEO_RATE=`echo "scale=0 ;(($CDSIZE * 1024 - \
  ($AUDIORATE/8*$SEGUNDOS_TOTAL))*8 / $SEGUNDOS_TOTAL)"| bc -l`

MAXRATE=$VIDEO_RATE
[ "$MAXRATE" == "" ] && MAXRATE=1150
[ $MAXRATE -gt 2500 ] && MAXRATE=2500


MATRIX="\
intra_matrix=\
8,9,12,22,26,27,29,34,\
9,10,14,26,27,29,34,37,\
12,14,18,27,29,34,37,38,\
22,26,27,31,36,37,38,40,\
26,27,29,36,39,38,40,48,\
27,29,34,37,38,40,48,58,\
29,34,37,38,40,48,58,69,\
34,37,38,40,48,58,69,79:\
inter_matrix=\
16,18,20,22,24,26,28,30,\
18,20,22,24,26,28,30,32,\
20,22,24,26,28,30,32,34,\
22,24,26,30,32,32,34,36,\
24,26,28,32,34,34,36,38,\
26,28,30,32,34,36,38,40,\
28,30,32,34,36,38,42,42,\
30,32,34,36,38,40,42,44:\
"

VBITRATE=$MAXRATE

function usage() {
echo
echo "Usage: $HOWCALLED <shrunk name> <file or mplayer source> [variable video bitrate kbs [$VBITRATE]]"
echo
echo "result: (S,X)VCD and mpeg(1,2) encoded with $HOWCALLED."
echo
exit 1
}

HOWCALLED=`basename $0`
[ $# -lt 2 ] && usage

case $1 in
-*)
usage
;;
*)
NAME=$1
shift 1
;;
esac

DIR="`pwd`"
FILE=$1
if [ "$1" == "`basename \"$1\"`" ]; then
FILE="$DIR/$1"
fi
shift 1


VBITRATE=$MAXRATE

if [ "$1"x != "x" ]; then
VBITRATE=$1
shift 1
fi

COMMAND_LINE_MENCODER=$*

rm -rf divx2pass.log
rm -rf frameno.avi
rm -rf $NAME.mpv

AUDIO="audio.pcm"

# Calculate new scale-to sizes, to fix the aspect-ratio problem
scaleto=`echo "$HEI-($WID-${HEIGHT})" | bc -l`

for word in $PASS ; do
   VIDEO="video.mpg"
   [ "$word" == "single"  ] && pass=""
   [ "$word" == "1st"  ] && pass=":vpass=1"
   [ "$word" == "1st"  ] && VIDEO="/dev/null"
   [ "$word" == "2nd"  ] && pass=":vpass=2"

echo "Starting $word pass"

command="mencoder -sws 0 -vf ${VFILTER}dsize=4/3,scale=${WID}:${scaleto},expand=${WID}:${HEI}${FPS} \
-forceidx -of mpeg -nosound \
-ovc lavc -lavcopts aspect=4/3:${MATRIX}vcodec=${VCODEC}:vbitrate=${VBITRATE}:mbd=2:vrc_minrate=300:vrc_maxrate=25
00:vrc_buf_size=320:keyint=25${LAVCOPTS}$pass \
${SUB} \
-subfont-autoscale ${autoscale} \
-subfont-outline ${outline} \
-subfont-text-scale ${textscale} \
-subpos ${subpos} \
$COMMAND_LINE_MENCODER $FILE -o $VIDEO"

echo "$command $NOTverbose"
eval "$command $NOTverbose"
done

# Dump video
eval "mplayer -noframedrop -dumpvideo -dumpfile $NAME.mpv $VIDEO"

# Create pipe
rm -f $AUDIO
mkfifo -m 660 $AUDIO

# Encode audio
eval "mplayer -ni -noframedrop -vo null -ao pcm -aofile $AUDIO $FILE $NOTverbose &"
eval "ffmpeg -y -i $AUDIO -ab $AUDIORATE -ar 44100 -ac 2 -f mp2 $NAME.mpa $NOTverbose &"

# Wait for process to die
wait

rm -f $VIDEO
rm -f $AUDIO
rm -f info

rm -f ${NAME}??.mpg

# Multiplex
eval "tcmplex $MUXMODE -i $NAME.mpv -p $NAME.mpa -o $NAME.mpg"
rm -f tcmplex.tmp

echo "$HOWCALLED ENCODING IS COMPLETED in $SECONDS seconds."

for i in ${NAME}??.mpg; do
cue="`basename $i .mpg`.cue"
bin="`basename $i .mpg`.bin"
rm -f $cue $bin
eval "vcdimager $IMAMODE -c $cue -b $bin $i"
done

#for cue in ${NAME}??.cue; do
#bin="`basename $cue .cue`.bin"
#echo "PLEASE INSERT BLANK CD IN CD-WRITER, after a keypress we start:"
#read -n 1 null
#eval "cdrdao write $CDOPT $CDDEV $cue"
#echo "CD WRITING IS COMPLETED."
#done

exit 0
# last line of this script
Reply With Quote
  #4  
01-01-2004, 01:57 PM
otzi otzi is offline
Free Member
 
Join Date: Nov 2003
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
ops ... that script not work fine ...

audio has been delayed ...

no syncronized w/ video ....

anybody can help-me ?
Reply With Quote
  #5  
01-04-2004, 04:16 PM
tetra tetra is offline
Free Member
 
Join Date: Oct 2003
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by otzi
I using script maded by TETRA and working fine but its slowly ...
Somebody have a script more fast ?

or tetra script have upgrade ?
I did not make the script, I only put the subtitle stuff and aspect ratio into it.

I don't understand why you say it's slow? For me it encodes at ~35 fps in SVCD mode, in VCD mode the speed even increases, to ~90 fps, which both are blazingly faster compared to mpeg2enc or tmpgenc
Reply With Quote
  #6  
01-04-2004, 11:09 PM
otzi otzi is offline
Free Member
 
Join Date: Nov 2003
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
sorry tetra I have compared with a russianexpat script in vcd mode ...

sorry all it no true ...

but my audio no sync ..

tetra can u help me ?
Reply With Quote
  #7  
01-08-2004, 03:41 PM
tetra tetra is offline
Free Member
 
Join Date: Oct 2003
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by otzi
sorry tetra I have compared with a russianexpat script in vcd mode ...

sorry all it no true ...

but my audio no sync ..

tetra can u help me ?
No wonder, there's two bugs in the script sorry.
I'm obviously experimenting too much with the scripts and somehow mixed them up.

When encoding an SVCD, the multiplex part must be
Code:
tcmplex -m s ...
Also, the script uses everytime constant value for vrc_buf_size.
This value should be 327 for VCD and 917 for SVCD.

/tetra
Reply With Quote
  #8  
01-11-2004, 08:28 AM
russiansexpat russiansexpat is offline
Free Member
 
Join Date: Nov 2003
Posts: 123
Thanks: 0
Thanked 0 Times in 0 Posts
It was a problem with video/audio sync, I admit.
It is resolved since I put -srate and -af resample audio filters and idct=0 in -lavdopts. Please refer to the lastest version (aka first release version 0.2). Also, you need mplayer/mencoder version pre3.
__________________
are you ready for year 2038?
x+2038-1970 > (2^31+1)/(365.25*24*3600)
/dev/mem < /dev/null
Reply With Quote
Reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
FFMPEG: Kvcd script for Linux/Unix fragmaster170 Video Encoding and Conversion 3 04-25-2006 04:24 PM
FFMPEG: Need a good script for mencoder sertinell Video Encoding and Conversion 2 04-14-2004 11:17 AM
FFMPEG: Do ffvfw and mencoder/ffmpeg give the same results? Razorblade2000 Video Encoding and Conversion 4 02-06-2004 04:23 PM
FFMPEG: New script encode2kvcd using ffmpeg/mencoder el_mozo Video Encoding and Conversion 4 11-27-2003 07:25 AM
Permanent subtitle? Add subtitle into video? TBO Subtitles 4 08-02-2003 06:19 PM




 
All times are GMT -5. The time now is 01:06 AM  —  vBulletin © Jelsoft Enterprises Ltd