Cropping
I just leaned about a very valuable feature of mplayer: you can graphically determine the crop region with -vf rectangle!
To do so, create a new config file with this:
RIGHT change_rectangle 2 10 LEFT change_rectangle 2 -10 UP change_rectangle 3 -10 DOWN change_rectangle 3 10 KP6 change_rectangle 0 10 KP4 change_rectangle 0 -10 KP8 change_rectangle 1 10 KP2 change_rectangle 1 -10
Then view the movie with
$ mplayer -vf rectangle -input conf=</path/to/conf> <movie_file>
You’ll see a white rectangle in the view area. Change the size with the keypad and the position with the cursor keys. The keypad down key enlarges the height, keypad down reduces it. Keypad left reduces the width, keypad right enlarges it.
Once you’re done, quit mplayer and use the rectangle geometry as crop parameter for ffmpeg:
$ ffmpeg -vf crop=<rectangle_data> ...
Splitting
Splitting isn’t as easy as it seems. You need 2 parameters:
- -ss hh:mm:ss
- -t hh:mm:ss
The latter is not a position in the file, but a duration! So, if you want to cut out everything from position 00:33:42 to 00:46:43, use -ss 00:33:42 -t 00:13:01 (33:42 + 13:02 = 46:43).
Also, -ss is a positional parameter. Use it as an input parameter, i.e. before -i if you don’t want silence and a black screen up front!
Example
Split out 13:02 minutes from position 33:42:
$ mplayer -ss 00:33:42 -t 00:13:02 -i <source> -acodec copy -vcodec copy out.file
Use the rectangle feature:
$ mplayer -vf rectangle -input conf=</path/to/conf> in.file
Reencode the split movie to mkv with the rectangle data:
$ ffmpeg -i <in.file> -acodec copy -vcodec libx264 -preset slow -threads 0 -x264opts fast_pskip=0:crf=21 <out.mkv>