I am very new to using ffmpeg and I am in desperate need of help. I have several videos that I am trying to split into one minute segments all at once, so that I can format them from mkv to mp4. I would like to split these videos using direct stream copy, but I am not very familiar with how to write out the correct code to do this and how I need to have my videos labeled. I do know that they all need to be in the same folder as ffmpeg. I would greatly appreciate any help, also can somebody please walk me through on how to make this a .bat file.
+ Reply to Thread
Results 1 to 11 of 11
This can, theoretically, be done but it has been a problem for many requesting this to get correct. Again. Basically, you have 3 types of frames or picture in a video. I, B, and P. I Frames are the only ones that are a complete picture or image. The others are the differences between the frame before, after, or both. FFMpeg likes to split at I-Frames and these are not typically at 1 minute intervals so you would be trying to cut at a B or a P frame image which is not a complete picture with nothing to reference to in preceding frames. Cutting with COPY is VERY difficult for this reason.
It may or may not work depending on the format, codec involved, point at cut and a lot of other factors. What you will usually get is a non-playable segment, a segment that freeze frames for several seconds, a segment that is not the minute you want and other problems.
If, as I understand your request, you have MKV videos and you wish to break into 1 minute MP4's, then letting it re-code the cut segments into an MP4 would make it easier to obtain what you wish. It is possible to repackage some MKV videos tp MP4 without re-coding but at 1 minute intervals may give undesirable results.
If someone else here knows of a simple way to do this, I would also like to know this procedure. In the mean time you can try ffmpeg to extract , say, the second minute to see if it works:
FFMPEG -ss 00:01:00.000 -i <"video.mkv"> -t 01:00.000 -c copy <"Output_video.mp4">
-i <video.mkv> means input the video you mean to cut. Do not use the < >. The simply mean replace with a video name of your choice such as "My Video.MKV"
-t 01:00.000 means time to copy 1 minute.
-c copy means copy both audio and video streams
<"Output_video.mp4"> means replace with an output name of your choice such as "My Output Video.MKV"
If it works change the -ss to 00:02:00.000 and try the next cut. Do not use the < >. If you have good luck (or not) let us know and someone can assist further or help with a batch file to accomplish wht you need..
After testing a video cut from 2:30-3:30 and another cut at 3:30-4:30. I got 2 playable videos. However, they overlap by a frame or 2 since the frames do not start on an even time boundary since my test video is 29.970 FPS and each frame is 0.033367 seconds long. I have shown the results of the Open GOP video I used and the times of the frames that correspond on the output video to the first start time of 02:30.000 (150 seconds) and 03:30 (210 seconds). Notice the first video output is 1800 frames (0-1799). If you add 1799 to the frame number cut Point of the original video (Frame 4496) you get 6295 or the second frame of the second minute.
If this is acceptable, it seems like it shouldn't be too hard to come up with a batch file that would do this for you by someone better at batch files than I am. What happens when you convert or repack them to an MP4 with no leading I-Frame, I do not know. I use Potplayer and these 2 videos play without an abnormalities that I can see. The durations are 1 minute 2 seconds and 1 minute 1 second.
[Attachment 45565 - Click to enlarge]
There is more frame types and sometimes cut is not possible even on I frame... sadly to say but life is more complicated.
FFmpegSource2("C:\Users\Bud\Desktop\FramesCuttingJoining\Beta Test\temp\CGOP.mp4", atrack=-1).Crop(0,0,-0,-2).LanczosResize(720,404) ScriptClip(Last, """Subtitle("[ "+Chr(FFPICT_TYPE)+" ]", size=(Height*56.0/720), align=2)""", after_frame=true) Subtitle("C:\Users\Bud\Desktop\FramesCuttingJoining\Beta Test\temp\CGOP.mp4", x=720, y=202, font="Arial", size=24, text_color=$ff0000, align=3) ShowFrameNumber(scroll=true, x=10, y=27, font="Arial", size=24, text_color=$ff0000) ShowTime(x=72, y=44, font="Arial", size=24, text_color=$ff0000) ShowSMPTE(fps=29.97, x=68, y=61, font="Arial", size=24, text_color=$ff0000)
B: Bi-dir predicted
S: S(GMC)-VOP MPEG4
i: Switching Intra
p: Switching Predicted
b: FF_BI_TYPE (no good explanation available)
[Attachment 45572 - Click to enlarge]
Wrong forum. Moving to Newbie/General Forum.
mkvmerge has a --split duration option , and mp4box has a -split time_sec option
So in theory you can either batch remux to mp4 then batch split; or batch split, then batch remux to mp4
But as mentioned above, splitting with direct stream copy is almost never accurate because of the way typical files are encoded. Splitting can only be done on IDR frames (or true keyframes). As a result you sometimes have overlapped/repeated segments. At the very best, the cuts won't be exactly 1 min
You can do this by command line too
But there are batch mkvtoolnix helpers. e.g
You can create a json file , and there are step by step instructions included