0

So I have a ~400GB .mkv file I wanted to upload to YouTube, unfortunately for me YouTube has a 256GB limit. So I Googled if I could split the file with FFMPEG and found the following article (FFMPEG Splitting MP4 with Same Quality), to sum up I ran the following command (I'm on Windows):

%UserProfile%\Downloads\ffmpeg-5.1.1-full_build\bin\ffmpeg.exe -i largefile.mp4 -t 02:30:23 -c copy smallfile1.mkv -ss 02:30:23 -c copy smallfile2.mkv

Reading the text from the last post it appears both of the time stamps needed to be the same, for part 1 it would be the end time, for part 2 it would be the start time.

This was taking forever, it was doing smallfile1.mkv first and it was getting maybe 1 GB every 20 minutes or so, all while putting my CPU at 100% usage. My rough math is it would have taken 137 hours for the first file to complete. Ain't nobody got time for that!

So next I found this post (https://stackoverflow.com/questions/18444194/cutting-the-videos-based-on-start-and-end-time-using-ffmpeg) and ended up making 2 commands:

%UserProfile%\Downloads\ffmpeg-5.1.1-full_build\bin\ffmpeg.exe -ss 00:00:00 -to 02:30:23 -i largefile.mp4 -c copy smallfile1.mkv

and

%UserProfile%\Downloads\ffmpeg-5.1.1-full_build\bin\ffmpeg.exe -ss 02:30:20 -to 05:04:31 -i largefile.mp4 -c copy smallfile2.mkv

But this was much faster, it maxed out my HDD usage but not my CPU (I have 2 drives so my computer was usable while this was running), I knew it was working right away because I had 1 GB in only a matter of seconds. It was about 30 minutes of conversion per file and I was ready to start uploading.

What did I do wrong in the first one? Why would it be so inefficient and take dramatically longer? I could have likely stitched these together with 1 command simply by running

%UserProfile%\Downloads\ffmpeg-5.1.1-full_build\bin\ffmpeg.exe -ss 00:00:00 -to 02:30:23 -i largefile.mp4 -c copy smallfile1.mkv && %UserProfile%\Downloads\ffmpeg-5.1.1-full_build\bin\ffmpeg.exe -ss 02:30:20 -to 05:04:31 -i largefile.mp4 -c copy smallfile2.mkv

(notice the space && space in-between the 2 commands) but I was alright on keeping an eye on the progress while I worked on other things.

I skipped this in my explanation but while troubleshooting this I tried converting this to a .mp4 (in hopes to keep the same quality) which seemed to work, the file size was pretty similar and looked about the same quality. Here's the link (https://askubuntu.com/questions/50433/how-to-convert-mkv-file-into-mp4-file-losslessly) and the following command:

%UserProfile%\Downloads\ffmpeg-5.1.1-full_build\bin\ffmpeg.exe -i input.mkv -codec copy output.mp4

My final splits I also converted to .mp4 but while I was testing it was about the same speed if not faster to specify my output files as .mkv. Trying the original command with my full file converted to .mp4 and by converting from .mkv to .mp4 also does the same high CPU slow progress.

I have my solution for the future but I'm really curious why the other one didn't work so I can make my life easier in the future.

Edit: Formatting.

1 Answer 1

0

You should read this: https://trac.ffmpeg.org/wiki/Seeking

The behavior of -ss is quite different if it is before or after -i

4
  • Probably you are right, this is the culprit. Still, if the link breaks then the answer will be just a hint saying the problem has something to do with -ss, but not explaining it at all. Therefore you should cite the relevant part(s) of the linked article or explain in your words what exactly this "quite different behavior" means (edit the answer). Commented Sep 13, 2022 at 7:34
  • @PierU Thanks for the article, I read up on this and did more googling, I'm curious if my way is the only practical way to do it, it appears every site that shows splitting a video in 2 parts has the -ss in the wrong spot. I tried %UserProfile%\Downloads\ffmpeg-5.1.1-full_build\bin\ffmpeg.exe" -ss 00:00:00 -to 02:30:26 -i LargeFile.mkv SmallFile1.mkv -ss 02:30:26 -to 05:04:31 -c copy SmallFile2.mkv and it still maxes out my CPU, oh well.
    – Pizzaazzip
    Commented Sep 14, 2022 at 3:04
  • @Pizzaazzip in your last command you have still a -ssafter the -i, which implies a full decoding of the input file.
    – PierU
    Commented Sep 14, 2022 at 5:50
  • @Pizzaazzip to split the file into two chunks with a single command you may investigate the segmentfeature of ffmpeg.
    – PierU
    Commented Sep 14, 2022 at 5:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .