[MPlayer-users] mplayer, mencoder and h.264 profiles

Krzysztof Duchnowski amidk75 at gmail.com
Mon Mar 29 17:33:26 CEST 2010


On 29.03.2010 02:12, Malte Gell wrote:

> if i have an h.264 video, can I identify the used profile with mplayer? Is it 
> true, that mencoder does not support the baseline format? I read this on the 
> web. My Nokia N97 is said to be only able to handle baseline, so I'd like to 
> convert videos to MPEG4 AVC baseline.

I am using it for android phone:

#!/bin/bash

FILE="$1"
FPS=$(mplayer -endpos 0 -ao null -vo null -identify "$FILE" |awk -F"="
'/ID_VIDEO_FPS/ {print $2}')
if [ "$FPS" = "23.976" ]; then FPS="24000/1001"; fi
AACQUANT="90"
X264CRF="16"
VIDEOFIFO="/tmp/fifo-video.y4m"
VIDEOMP4="/tmp/video.mp4"
AUDIOFIFO="/tmp/fifo-audio.wav"
AUDIOTMP="/tmp/tmp-audio.wav"
AUDIOWAV="/tmp/audio.wav"
AUDIOAAC="/tmp/audio.aac"
AUDIORATE="-1"
FILEOUT="$(echo "$FILE" |awk -F"." '{gsub("."$NF,"");print
$0"-[android].mp4"}')"
ENDPOS="-1"
SOXTMP="$HOME/Wideo/tmp"

[ -e $VIDEOFIFO ] && rm -f $VIDEOFIFO
mkfifo $VIDEOFIFO

[ -e $VIDEOMP4 ] || mplayer\
	"$FILE"\
	$([ $ENDPOS -gt 0 ] && echo "-endpos $ENDPOS")\
	-sws 10\
	-vf-add hqdn3d,scale=480:-2,expand=::::::16,harddup\
	-correct-pts\
	-benchmark\
	-ass\
	-ass-force-style
PlayResX=480,PlayResY=320,MarginV=25,MarginRight=50,MarginLeft=50\
	-ass-font-scale 2\
	-subpos 50\
	-sub subtitle.srt\
	-vo yuv4mpeg:file=$VIDEOFIFO\
	-ao pcm:fast:waveheader:file=$AUDIOTMP\
	1&>/dev/null &

[ -e $VIDEOMP4 ] || time x264\
 --profile baseline\
 --tune fastdecode\
 --keyint 300\
 --min-keyint 15\
 --crf $X264CRF\
 --level 4.1\
 --sar 1:1\
 --threads 3\
 --pass 1\
 --fps $FPS\
 -o $VIDEOMP4\
 $VIDEOFIFO
[ -e $VIDEOFIFO ] && rm -f $VIDEOFIFO


[ -e $AUDIOTMP ] || mplayer\
	"$FILE"\
	-novideo\
	-benchmark\
	-ao pcm:fast:waveheader:file=$AUDIOTMP

[ -e $AUDIOFIFO ] && TEMP=$AUDIOFIFO
[ -e $AUDIOTMP ] && TEMP=$AUDIOTMP
[ -e $TEMP ] && time sox -S -G --temp $SOXTMP $TEMP -c 2 $([ $AUDIORATE
-gt 0 ] && echo "-r $AUDIORATE") $AUDIOWAV gain -n -3 dither -s
[ -e $TEMP ] && rm -f $TEMP

[ -e $AUDIOWAV ] && time faac -q $AACQUANT -o $AUDIOAAC $AUDIOWAV
[ -e $AUDIOWAV ] && rm -f $AUDIOWAV

[ -e $VIDEOMP4 ] && MP4Box -new $FILEOUT -isma -nodrop -add $VIDEOMP4
-add $AUDIOAAC

[ -e $AUDIOAAC ] && rm -f $AUDIOAAC
[ -e $VIDEOMP4 ] && rm -f $VIDEOMP4

exit 0


-- 
Krzysztof 'DK75' Duchnowski
GetFirefox - http://www.mozilla.com/firefox/
Konfiguracja UTF-8 dla czytników - http://evil.pl/pip/utf/


More information about the MPlayer-users mailing list