Log in | Register
Forum > Site Discussion > Thread

Editing and rotating videos losslessly

Aug 26, 2019 - permalink
There are a lot of ways to download videos from Youtube and other sites, I generally use the Video DownloadHelper Firefox extension or the Internet Download Manager desktop app/extension myself, depending on the site (Instagram videos are a special case- see this thread).

After downloading, if the video needs to be cut down in length, combined with other segments, or rotated correctly, I like to do it without lossy re-encoding of the video stream if possible, since that lowers the original video quality.

For lossless rotation of videos filmed sideways and such, the best thing I've found is the free program FFmpeg Batch, which is basically a graphical frontend for the FFmpeg command-line suite, and quite powerful (it comes with its own version of FFmpeg so you don't need to download anything else).  The default rotation parameters it comes with also do format conversion, but I found out you can use the parameters:

-metadata:s:v rotate="-90" -codec copy

instead, which seems to work fine without messing with the original data.  The "-90" (90 degree clockwise rotation) can be changed to "-180" or "-270" depending on how far the video needs to be rotated.  If you're working with .mp4 files, make sure the format field is set to mp4 also.

FFmpeg Batch can be used to do pretty much anything FFmpeg can, including non-lossless stuff like cropping, example parameters for cropping a video: 

-filter:v "crop=640:420:0:0" -crf 10

where 640x420 is the final size you want and 0:0 (x:y) is the starting point, top-left; it would be 640:420:0:200 if you wanted to start the crop box 200 pixels down, for instance.  The "-crf 10" part sets a Constant Rate Factor of 10 which should be nearly lossless quality, and is a useful thing to add for any function that isn't inherently lossless, i.e. not the rotation command above.

Trimming/Combining Videos-
For losslessly trimming down the length of a video or combining multiple videos into one (the latter is useful for Instagram Stories, where often a single video is spread into multiple 15-second clips), I like the program Machete.  It's paid, but only costs $20 (there's a free version, but it doesn't work with mp4 files).  The only limitation is that you have to cut the videos at the keyframe points, which aren't always exactly where you want them, but they're usually close enough.  A good free alternative to Machete is Avidemux, just be sure it's set to copy mode, use the keyframe buttons to select the edit points, and have the output format set to MP4 (if that's what you're editing).  This page lists a bunch of other alternative programs.

EDIT:  Added a free alternative to Machete for trimming, and more detail in the cropping section.
Aug 26, 2019 - permalink
Thanks, stickied
Jan 04, 2021 - permalink

Another app worth checking out is Handbrake, which is available for macOS, Linux and Windows. It is free and open source.

Jan 04, 2021 - permalink

I tried Handbrake a while ago, but from what I remember it always re-encodes and doesn't really do lossless conversions even when it should be possible (i.e. moving a video stream from an .mkv container format to .mp4, etc)

Jan 05, 2021 - permalink

That's true, though it does afford many people a relatively easy way convert. Tools like ffmpeg will offer better options, but the need for command-line knowledge will put it out of the reach of many people.

« first < prev Page 1 of 1 next > last »