This is a improved/combined version of posts from an earlier thread that could no longer be updated due to having been imported from the old forum.
There are a lot of ways to download videos from Youtube and other sites, I generally use the Video DownloadHelper browser extension or the Internet Download Manager browser extension/desktop app, 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, rotated so it's not sideways, or have its aspect ratio corrected, those can usually be done losslessly, without needing re-encode the actual video stream (which decreases quality due to recompression and can bloat the filesize above GWM's 25MB upload limit).
Trimming/Combining Videos
Most videos can be trimmed or have segments cut out & combined losslessly, as long as the cut points are done on keyframes (which are usually spaced every few seconds, depending on how the video was encoded). A good free program to do this is Avidemux (which supports MP4s). You just have to make sure the "Video Output" dropdown is set to "Copy" mode, and use the next/previous keyframe buttons at the bottom to navigate to the edit points closest to what you want. The "Output Format" should also be set to "MP4 Muxer" if you're editing an MP4. This page lists a bunch of other free alternative programs.
Personally I like the cutting interface in the program Machete, but it requires the $20 paid version to work with MP4s.
The same programs can be used to join multiple smaller segments of the same video together losslessly if they were exported as separate files, or were divided into multiple segments on the original source (common for longer videos in Instagram Stories). That would be done using File>Append in Avidemux, for instance.
Fixing the Aspect Ratio
Sometimes you'll run across a video with an incorrect aspect ratio, it happens pretty commonly with clips originally taken from television or some other non-digital native source. Here's an example that was uploaded to the site previously:
Obviously, it's squashed horizontally from what it should look like. It's possible to fix it losslessly by setting correct aspect ratio flags in the file's metadata, which is a part of the file that tells video players how it should be displayed, without actually re-encoding the video stream.
I like to use FFmpeg Batch for this, a very handy graphical frontend for the FFmpeg tool that lets you use all its functions without having to type out a command line each time (it comes with its own version of FFmpeg so you don't need to download anything else). In it, make sure to put "mp4" in the "Format" box if that's what you're working with.
The first step is to determine what the correct aspect ratio should be for the video, basically a matter of playing around with it in any video player that lets you adjust the aspect ratio manually until it looks correct (be sure to set it back to auto afterwards so you can tell when the video is actually fixed). It's most commonly going to be 4:3 or 16:9, sometimes you'll run into something more exotic from this list. In this case, the correct ratio is 16:9.
There are actually two commands to set the aspect ratio in metadata using FFmpeg, I'll give the simpler one first:
-c copy -aspect 16:9
This would be copied and pasted into the "Parameters" box in FFmpeg Batch, and could be renamed and saved as a new preset. The 16:9 can be changed to 4:3 or 3:2 or whatever else is needed.
Depending on the nature of the original video and how its metadata was set up, the second command might be needed as well (for MP4s), it's a little harder to use:
Note the "640/456" part. The way it works is that you put the current horizontal resolution of the video to the right of the slash (in this case the video is 456x360, so 456), and to the left of the slash put what the horizontal resolution should be if the video were stretched to the correct aspect ratio (that was figured out earlier), based on the current vertical resolution. An online aspect ratio calculator like this makes that easy. In this case I pick 16:9 for the ratio in the calculator, put the original vertical resolution of 360 as "Pixels height", and then it tells me the corrected horizontal resolution should be 640, so that goes before the slash in the command.
Because these two commands are setting the aspect ratio in different places in the metadata, which may or may not be obeyed depending on the original video and which browser/video player you're going to be playing the fixed one in, nowadays I just use a combined command to set it in both places at once to make sure it plays back correctly in everything:
For lossless rotation of videos filmed sideways and such, the best thing I've found is the abovementioned free program FFmpeg Batch. The default rotation presets it comes with will re-encode the video (which we're trying to avoid) but you can instead use the Parameters:
-c copy
with the Pre-input setting:
-display_rotation:v:0 90
which seems to rotate fine without messing with the actual video data. The "90" (90 degree counterclockwise rotation) can be changed to "-90" or "180" depending on how the video needs to be rotated. Again if you're working with an MP4 file make sure the Format field is set to "mp4".
Here's what that looks like on the FFmpeg Batch interface. "Rotate 90 (pre-input)" is just the name I gave these settings when I saved them as a preset:
(The original version of this post had a section on using FFmpeg Batch for cropping videos, but that's a non-lossless function so I'd rather include it in a separate post along with stuff like codec conversion)
This is a improved/combined version of posts from an earlier thread that could no longer be updated due to having been imported from the old forum.
There are a lot of ways to download videos from Youtube and other sites, I generally use the Video DownloadHelper browser extension or the Internet Download Manager browser extension/desktop app, 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, rotated so it's not sideways, or have its aspect ratio corrected, those can usually be done losslessly, without needing re-encode the actual video stream (which decreases quality due to recompression and can bloat the filesize above GWM's 25MB upload limit).
Trimming/Combining Videos
Most videos can be trimmed or have segments cut out & combined losslessly, as long as the cut points are done on keyframes (which are usually spaced every few seconds, depending on how the video was encoded). A good free program to do this is Avidemux (which supports MP4s). You just have to make sure the "Video Output" dropdown is set to "Copy" mode, and use the next/previous keyframe buttons at the bottom to navigate to the edit points closest to what you want. The "Output Format" should also be set to "MP4 Muxer" if you're editing an MP4. This page lists a bunch of other free alternative programs.
Personally I like the cutting interface in the program Machete, but it requires the $20 paid version to work with MP4s.
The same programs can be used to join multiple smaller segments of the same video together losslessly if they were exported as separate files, or were divided into multiple segments on the original source (common for longer videos in Instagram Stories). That would be done using File>Append in Avidemux, for instance.
Fixing the Aspect Ratio
Sometimes you'll run across a video with an incorrect aspect ratio, it happens pretty commonly with clips originally taken from television or some other non-digital native source. Here's an example that was uploaded to the site previously:
Obviously, it's squashed horizontally from what it should look like. It's possible to fix it losslessly by setting correct aspect ratio flags in the file's metadata, which is a part of the file that tells video players how it should be displayed, without actually re-encoding the video stream.
I like to use FFmpeg Batch for this, a very handy graphical frontend for the FFmpeg tool that lets you use all its functions without having to type out a command line each time (it comes with its own version of FFmpeg so you don't need to download anything else). In it, make sure to put "mp4" in the "Format" box if that's what you're working with.
The first step is to determine what the correct aspect ratio should be for the video, basically a matter of playing around with it in any video player that lets you adjust the aspect ratio manually until it looks correct (be sure to set it back to auto afterwards so you can tell when the video is actually fixed). It's most commonly going to be 4:3 or 16:9, sometimes you'll run into something more exotic from this list. In this case, the correct ratio is 16:9.
There are actually two commands to set the aspect ratio in metadata using FFmpeg, I'll give the simpler one first:
-c copy -aspect 16:9
This would be copied and pasted into the "Parameters" box in FFmpeg Batch, and could be renamed and saved as a new preset. The 16:9 can be changed to 4:3 or 3:2 or whatever else is needed.
Depending on the nature of the original video and how its metadata was set up, the second command might be needed as well (for MP4s), it's a little harder to use:
-c copy -bsf:v "h264_metadata=sample_aspect_ratio=640/456"
Note the "640/456" part. The way it works is that you put the current horizontal resolution of the video to the right of the slash (in this case the video is 456x360, so 456), and to the left of the slash put what the horizontal resolution should be if the video were stretched to the correct aspect ratio (that was figured out earlier), based on the current vertical resolution. An online aspect ratio calculator like this makes that easy. In this case I pick 16:9 for the ratio in the calculator, put the original vertical resolution of 360 as "Pixels height", and then it tells me the corrected horizontal resolution should be 640, so that goes before the slash in the command.
Here's the corrected video:
Because these two commands are setting the aspect ratio in different places in the metadata, which may or may not be obeyed depending on the original video and which browser/video player you're going to be playing the fixed one in, nowadays I just use a combined command to set it in both places at once to make sure it plays back correctly in everything:
-c copy -aspect 16:9 -bsf:v "h264_metadata=sample_aspect_ratio=640/456"
Here's another combined example like that, this is one is for correcting a 720x480 video to 4:3, commonly needed for video files ripped from DVDs:
-c copy -aspect 4:3 -bsf:v "h264_metadata=sample_aspect_ratio=640/720"
Correcting Video Rotation
For lossless rotation of videos filmed sideways and such, the best thing I've found is the abovementioned free program FFmpeg Batch. The default rotation presets it comes with will re-encode the video (which we're trying to avoid) but you can instead use the Parameters:
-c copy
with the Pre-input setting:
-display_rotation:v:0 90
which seems to rotate fine without messing with the actual video data. The "90" (90 degree counterclockwise rotation) can be changed to "-90" or "180" depending on how the video needs to be rotated. Again if you're working with an MP4 file make sure the Format field is set to "mp4".
Here's what that looks like on the FFmpeg Batch interface. "Rotate 90 (pre-input)" is just the name I gave these settings when I saved them as a preset:
(The original version of this post had a section on using FFmpeg Batch for cropping videos, but that's a non-lossless function so I'd rather include it in a separate post along with stuff like codec conversion)