You are not logged in.
I have an .mp4 video and .ass subtitles. How would I hard encode the subtitles on to the mp4 file so I can view it on my iPod with subtitles?
Last edited by zowki (2009-10-28 23:24:30)
How's my programming? Call 1-800-DEV-NULL
Offline
bump
How's my programming? Call 1-800-DEV-NULL
Offline
Offline
Okay, it's a bit dirty, but hey. Basically, it plays video from mplayer, and pipes the output (which should now include the .ass file) to x264 via fifo. It also encodes audio. This is for my PSP though, so you might need some different settings, etc.
#!/bin/bash
##
### PSPMP4: A simple video encoding tool for PSP video
##
#
###
## Main directory for where your PSP encodes will be stored
#
MP4DIR="/home/maister/psp-encodes"
#
##
###
if [ ! -d "$MP4DIR"/tmp ]
then
mkdir "$MP4DIR"/tmp
fi
function help()
{
echo "Usage: `basename $0` --threads/-t | --input/-i | --crf/-q (video quality, lower = better. default 22) | --abitrate/-ab (audio bitrate) | --output/-o (basename only) | --size/-s width:height | -x264 \"--options for x264 here\" | -mplayer \"-options for mplayer here\""
echo ""
echo "Example: `basename $0` -i 720p.mkv -o Episode5 -b 800 -ab 160"
echo ""
echo "This script provides sane defaults for encoding PSP video, and should suit most video clips. It is sufficient to just supply an input. A recent version of x264 is required, as this script uses the baseline profile, which is only supported in newer git-versions."
}
## Default values
TAG=`date +%Y%m%d-%T`
FILENAME=""
#BITRATE=250
CRF=22
AB=128
THREADS=auto
SCALE=480:270
##
if [ -z "$1" ]
then
help
exit 1
fi
while [ -n "$1" ]
do
case "$1" in
--threads | -t )
shift
THREADS="$1"
shift
;;
--input | -i )
shift
FILENAME="$1"
shift
;;
-ab | --abitrate )
shift
AB="$1"
shift
;;
-s | --size )
shift
SCALE="$1"
shift
;;
-x264 )
shift
X264OPTS="$1"
shift
;;
-mplayer )
shift
MPLAYEROPTS="$1"
shift
;;
--output | -o )
shift
TAG="$1"
shift
;;
--rate | -r )
shift
RATE="$1"
shift
;;
--crf | -q )
shift
CRF="$1"
shift
;;
* )
help
exit 1
;;
esac
done
# Creates fifo-pipes for audio and video
mkfifo "$MP4DIR"/tmp/video$TAG.y4m
mkfifo "$MP4DIR"/tmp/audio$TAG.wav
# Encodes audio
faac -b $AB -w "$MP4DIR"/tmp/audio$TAG.wav &
mplayer $MPLAYEROPTS -vo null -vc null -ao pcm:file="$MP4DIR"/tmp/audio$TAG.wav:fast -nocorrect-pts "$FILENAME" &
sleep 2
x264 --profile main --deblock 1:1 --crf $CRF --level 3 --b-adapt 2 --partitions p8x8,b8x8,i4x4 --no-8x8dct --me umh --threads $THREADS --output "$MP4DIR"/tmp/video$TAG.264 "$MP4DIR"/tmp/video$TAG.y4m &
mplayer -vo yuv4mpeg:file="$MP4DIR"/tmp/video$TAG.y4m -benchmark -vf scale=$SCALE -vc ffh264, $MPLAYEROPTS -nosound "$FILENAME"
sleep 2
#Muxing into PSP-compatible MP4
ffmpeg -y -vcodec copy -acodec copy -i "$MP4DIR"/tmp/video$TAG.264 -i "$MP4DIR"/tmp/audio$TAG.m4a -f psp "$MP4DIR/$TAG.mp4"
rm "$MP4DIR"/tmp/video$TAG*
rm "$MP4DIR"/tmp/audio$TAG*
Offline
If it's piping Mplayer's output then it would take as long as the video's lengh right? I have a large batch of videos to convert so it might take days.
How's my programming? Call 1-800-DEV-NULL
Offline
if you want hardcoded subs, you have to reencode, no way around that.
He hoped and prayed that there wasn't an afterlife. Then he realized there was a contradiction involved here and merely hoped that there wasn't an afterlife.
Douglas Adams
Offline
As an addition to what Rasi said (which is true), I found Avidemux2 to be a great tool for this stuff. I even use it on OSX at work, and at home I use it to convert high quality videos for my PSP. Never needed to add subtitles as I am fairly fluent in english, but I know it has the option to do so, and I've seen it work, it does a good job.
edit:
have a look at this http://www.youtube.com/watch?v=dxtxNGX6tJQ and this for subtitles http://www.youtube.com/watch?v=mNt6mEQ658s
Last edited by Lich (2009-10-28 10:20:14)
Archlinux | ratpoison + evilwm | urxvtc | tmux
Offline
Will try avidemux and report back if it works.
Edit: Avidemux did what I wanted. Thanks!
Last edited by zowki (2009-10-28 23:23:57)
How's my programming? Call 1-800-DEV-NULL
Offline