Jump to content

Recommended Posts

arrbee99
Posted

Am trying to crop a mkv video using this -

REM Testing for loop
FOR %%m in (*.mkv) do (
REM Cut from all sides
ffmpeg -i "%%m" -vf "crop=1800:900;120:180" -c:a copy "%%~nm_cut_all.mkv"
echo ====================================================
)

Its supposed to crop from all sides. The mkv is 1920x1080. Its saved as a windows.bat file. When I run it it seems to run, pops up a window which disappears super quick and creates a new file with nothing in it. So, no success. Any ideas why not please (apart from me not knowing what I'm doing) ?

arrbee99
Posted

...and I've just spotted the (accidental) semicolon.

Posted

You good now?

arrbee99
Posted

Yes, seems to work well.

I do wonder though about the above if it does more than just remove bits round the edge, as the resulting files are so much smaller - generally they're less than half the size after going from 1920x1080 to (in the latest version) 1670x920.

Posted

Have you tried playing these files back through different clients to see if there is any bad side effects?

arrbee99
Posted

Only the briefest of skim throughs, and only in vlc. They seemed fine, but I just wonder. Like I say maybe 45% of original size, and apparently the same reduction for bitrate, but same resolution and framerate. I don't exactly expect bluray quality and they're pretty decent.

Its like it decides to compress them. Just hoping for an explanation or a 'thats completely standard' really...

crusher11
Posted

Well yeah, you're re-encoding. No other way to crop. But there are no encoding parameters given so I assume it's just throwing in defaults, which likely aren't as good as the original compression depending on the source.

 

arrbee99
Posted

Hmmm. So cropping automatically re-encodes. I guess the -c:a copy in the first post only copies the audio ? I can't use -c copy to copy video ?

crusher11
Posted (edited)

No, because there's no way to copy it. It's editing the picture, and therefore has to do a new video encode.

-c:v copy would copy the video if you were doing an edit that could be done losslessly, but you aren't.

Edited by crusher11
  • Like 1
Posted (edited)

Load one of the cropped videos up onside the original and look at the Media Info section of both.  How much difference do you see in the bitrate?

You could also use MediaInfo program as well outside of Emby if you have that.

But as crusher11 mentioned you're only copying audio, no subs, chapters or anything else as well as re-encoding the video with nothing specified.

Edited by cayars
arrbee99
Posted
14 minutes ago, crusher11 said:

No, because there's no way to copy it. It's editing the picture, and therefore has to do a new video encode.

-c:v copy would copy the video if you were doing an edit that could be done losslessly, but you aren't.

Oh well. Such is life. Thanks for the info 😀

arrbee99
Posted
4 minutes ago, cayars said:

Load one of the cropped videos up onside the original and look at the Media Info section of both.  How much difference do you see in the bitrate?

You could also use MediaInfo program as well outside of Emby if you have that.

They vary a bit but its roughly 3800kb/s to 1800kb/s.

Seems to be just the way it is. I'll survive...

Posted

Quite a bit of a difference.  The new files is using less than half the bitrate of the original.

BTW, why do you want to crop the videos?

arrbee99
Posted
3 minutes ago, cayars said:

Quite a bit of a difference.  The new files is using less than half the bitrate of the original.

BTW, why do you want to crop the videos?

True. Maybe I could try using that crf thing, or maybe its not worth the effort.

Doing a bit of, erm, home recording and I haven't found a way, yet, to record exactly the bit of the window I want, so I need to remove some borders.

Posted

From decades of playing with video, my personal advise is don't change the video from standard resolutions as some clients won't like this and do weird things you don't expect unless you know exactly how to author the video and set aspect ratios, etc

With that said, if these videos will only be used in Emby then test watching them in every client you have access to before committing to crop all your videos.
Just a case of better safe than sorry.

 

  • Like 1
arrbee99
Posted

Yep, they're just for Emby and I'll see how they go. They've just passed the vlc test so far...

  • Like 1
crusher11
Posted
6 hours ago, arrbee99 said:

They vary a bit but its roughly 3800kb/s to 1800kb/s.

Seems to be just the way it is. I'll survive...

Or you could throw in some encoding settings? 

arrbee99
Posted

I probably could if I knew what I was doing.

Do you mean crf ? doesn't that depend on whether its x264 or x265 or something. If I look in MediaInfo it says Video Format: AVC and Codec ID: V_MPEG4/ISO/AVC if that counts for anything.

crusher11
Posted

Well, you can encode it to whatever you like.

 

crusher11
Posted
ffmpeg -i "%%m" -vf "crop=1800:900;120:180" -c:a copy -c:v libx264 -preset slow -crf 18 -pix_fmt yuv420p -x264opts level=4.1:ref=4:colormatrix=bt709 "%%~nm_cut_all.mkv"

And as above this won't copy subtitles, chapters, etc.

arrbee99
Posted

Thank you. I'll give it a go 😀

arrbee99
Posted

Bit rate for cropped version is much higher now thanks. Bit of a struggle to spot much of a difference tbh so far. So do I want to keep that extra info or not...quite probably. I think.

  • 1 month later...
Posted
On 7/28/2021 at 5:52 PM, crusher11 said:

ffmpeg -i "%%m" -vf "crop=1800:900;120:180" -c:a copy -c:v libx264 -preset slow -crf 18 -pix_fmt yuv420p -x264opts level=4.1:ref=4:colormatrix=bt709 "%%~nm_cut_all.mkv"

And as above this won't copy subtitles, chapters, etc.

Seeing as I know nowt about the various media formats and containers and thingies, regarding the above, would anyone happen to know if I can use it as is for mp4 videos, or does it need to be changed (apart from the .mkv bit at the end of course) pleasey.

Posted

Excellente. Thank you.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...