when I say trim I don’t mean to time trim a file, like getting rid of the last 2 minutes of the mkv file, but to picture trim every frame of the mkv file to get rid of black margins to both left and right of the actual image.
Files were originally recorded on 4:3 aspect ratio (some are movies from the 1950’s) but the encoder somehow created / copied huge black margins to both left and right of the actual image. I want to get rid of these.
Some of my files are 30 minutes long but others 2 hours.
if ffmpeg is the application I need, could anyone knowledgeable enough write the actual command?
can it be done for several files automatically?
Ffmpeg is totally capable of doing this. Something like
ffmpeg -i in.mkv -vf "crop=width:height:x:y" out.mkv
might work. You would need to specify the crop area (x:y), which you can get with ffmpeg’scropdetect
. Here’s an article about it. To automate this, I would use a for loop in a shell script, for more control, or just a one liner if width, height and x:y are the same for all:for file in *.mkv; do ffmpeg -i "${file}" -vf "crop=width:height:x:y" "cropped_${file}"; done
If people want to fart around with ffmpeg filters this site is great: https://ffmpeg.lav.io/
Handbrake has the option to autodetect black bars and crop them out. But you have to reencode the file, unfortunately.
Kinda unrelated to the question but i was actually looking for a linux native way to convert blu ray audio discs to seperate flac audio tracks after ripping them with makemkv. I could only find ffmpeg which seemed a bit daunting to me, but it looks like mkvtoolnix might be able to do what i want.
MKVToolNix has a great cropping feature that completely lossless because it just writes an information into the file how many pixels to leave out.
The massive problem since quite some time is that I’m not aware of any media player respecting this. VLC used to support it but a decade ago suddenly stopped: https://code.videolan.org/videolan/vlc/-/issues/13982
If you have the originals, maybe encode them again. HandBrake has a nice preview feature.
mpv still works.