You are not logged in.

#1 2009-04-11 18:55:35

tony5429
Member
Registered: 2006-03-28
Posts: 1,017

[SOLVED] How to Crop an MP4 Video via Command-line?

I have ffmpeg, mpg123, and mencoder. Does anyone know of a way I could use any of those to crop an mp4 video via command-line? I am trying to take off the black space above and below a video. Thanks in advance!

Last edited by tony5429 (2009-04-12 00:12:57)

Offline

#2 2009-04-11 19:46:38

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: [SOLVED] How to Crop an MP4 Video via Command-line?

I dunno if you can simply crop wo/ re-encoding..?


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#3 2009-04-12 00:08:58

celticmusicguy
Member
From: Zuni, VA, USA
Registered: 2008-07-24
Posts: 24

Re: [SOLVED] How to Crop an MP4 Video via Command-line?

I don't think it's possible to crop without re-encoding, but you can crop from the command line with ffmpeg and mencoder. Not sure about mpg123 - I think that's for playing audio but I could be wrong there.

Anyway, with ffmpeg you can do cropping by using -croptop, -cropbottom, -cropleft, and -cropright. So if you wanted to crop 16 pixels off of the top and the bottom, your command line would look something like this:

ffmpeg -i <input file> -croptop 16 -cropbottom 16 <video encoding options> <audio encoding options> <output file>

With mencoder you use the "crop" video filter, like this:

mencoder <input file> -o <output file> -vf crop=320:208:0:16 <other options>

where the "320:208:0:16" means that the resulting picture is 320 pixels wide, 208 pixels high, and the 0:16 is the x,y position of the cropped area.

These command lines are just really very basic examples - ffmpeg and mencoder have a LOT of options. Way too many to explain here. If you don't believe me, just try reading through the mencoder man page sometime. wink (There's an online version of it at: http://www.mplayerhq.hu/DOCS/man/en/mplayer.1.html)

Hope this helps!!


Solutions nearly always come from the direction you least expect, which means there's no point trying to look in that direction because it won't be coming from there.
-Douglas Adams

Offline

#4 2009-04-12 00:12:38

tony5429
Member
Registered: 2006-03-28
Posts: 1,017

Re: [SOLVED] How to Crop an MP4 Video via Command-line?

Thanks celticmusicguy! The mencoder command worked perfectly!

Offline

#5 2009-04-16 18:29:48

DrZaius
Member
Registered: 2008-01-02
Posts: 193

Re: [SOLVED] How to Crop an MP4 Video via Command-line?

I believe the video will have to be re-encoded, but you can still just copy the audio stream:

ffmpeg -i input.mp4 -croptop 16 -cropbottom 16 -acodec copy output.mp4

Offline

Board footer

Powered by FluxBB