I Learned How to Split/Convert Videos Using the Command Line

in voilk •  5 months ago

    So, yesterday, I wanted to look for an application to manipulate video files without dropping the quality. There are more than a few options on Windows, but I'm using Linux right now.

    I could use a Video Editor and crop out the parts I don't need, but either the quality will decrease or the size will increase and I didn't want that.

    In my search, I found a way to do it using the Terminal (Command Line) by using the FFMPEG libraries. I already have those installed on my machine because many multimedia applications need them.

    So, to split a video file, all I need is to use the following formula:

      ffmpeg -i INPUT.mkv -ss 00:00 -t 20:00 -c copy OUTPUT.mp4
    

    Explanation:

    -i INPUT : The name of the input file in the working directory. Many file types are supported.
    HH:MM:SS.S : Start time for the segment I want to cut. You can also write the time in seconds but I find it easier to format it like this.
    -t HH:MM:SS.S : Length of the new video, starting from the start time above.
    -c copy : Copies the codec of the original file. Changing the codec might be preferable sometimes, but this is enough for my usecase.
    OUTPUT : Name of the file to be created.

    The best thing about this method is that it doesn't only extract the part(s) I need from videos without decreasing quality. It also allows me to convert videos between different file types. I record videos as .mkv files using OBS because that's the most stable file type while recording, but when I need to upload them, some websites only take .mp4 files.

    There are many things I could do using ffmpeg and I just started learning it. But this experience made me less afraid of learning video conversion using the command line. I'll probably do more of this from now on.

    What do you think?

    If this post has been useful to you, I'd love to hear your opinion in the comments section.


    P.S: I have to thank Stackoverflow and Reddit for the information I put here.

    Posted Using InLeo Alpha

      Authors get paid when people like you upvote their post.
      If you enjoyed what you read here, create your account today and start earning FREE VOILK!