how to reencode with ffmpeg (with limited x264)

4.2k views Asked by At

Until now I used this script to reencode my rips for my box (tv decoder):

^_^ ( ~ ) -> cat ~/++/src/convert.sh 
#! /bin/bash

name=$(path -r "$1") # it gives the file name without the extension

[ "$1" = *.mp4 ] && ffmpeg -i "$name".mp4 -vcodec copy -acodec copy "$name".mkv
x264 --preset veryfast --tune animation --crf 18 --vf resize:720,576,16:15 -o "$name".tmp.mkv "$name".mkv
mkvmerge -o "$name [freeplayer sd]".mkv "$name".tmp.mkv --no-video "$1"
rm -rf "$name".tmp.mkv
[ "$1" = *.mp4 ] && rm -rf "$name".mkv
exit 0

#EOF

It works on my ubuntu and archlinux laptops. But it doesn’t on my desktop witch runs fedora. Google says that the x264 package shiped by rpmfusion doesn,t support lavf and ffms2. And I cannot unistall it because smplayer (witch i like) needs it.

Ok, so I have to compile it. Google then says "you have to build ffmpeg, ffms2 tnen x264 ensuring that the flags are correctly refered." Well, didn’t work (ffms2 cannot find LIBAV - even when I am telling where - and x264 does’t configure with lavf...)

My question is: can I use ffmpeg alone to do what my script does. I have ffmpeg version 0.8.11, x264 0.116.2048 59cb2eb and gcc: 4.6.1 20110804 (Red Hat 4.6.1-7)

EDIT: Ok, I found that: ffmpeg -i input file -acodec copy -vcodec libx264 -preset veryfast -tune animation [that part I don’t have] output

1

There are 1 answers

0
Sarfraz On BEST ANSWER

I found it myself.

ffmpeg -i input -s 720x576 -aspect 4:3 -vcodec libx264 -preset veryfast -tune animation -crf 18 -acodec copy -scodec copy output

My script becomes:

#! /bin/bash
#
name=$(path -r "$1") # it gives the file name without the extension

ffmpeg -i "$1" -s 720x576 -aspect 4:3 -vcodec libx264 -preset veryfast -tune animation -crf 18 -acodec copy -scodec copy "$name".tmp.mkv
mkvmerge -o "$name [freeplayer sd]".mkv "$name".tmp.mkv --no-video "$1"
rm -rf "$name".tmp.mkv
exit 0
#
#EOF

And it now works with any container! you may change the tune and delete the "-scodec copy" part if you use it for other things than animation (well it will work either ways). you may also note that my tv is a pal 4:3 ratio one. That may change too.

See ya.