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.
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 12 of 12
Thread
-
-
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:
Code: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.. -
UPDATE:
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.
Code: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)
I: Intra
P: Predicted
B: Bi-dir predicted
S: S(GMC)-VOP MPEG4
i: Switching Intra
p: Switching Predicted
b: FF_BI_TYPE (no good explanation available)
?: Unknown
[Attachment 45572 - Click to enlarge] -
Wrong forum. Moving to Newbie/General Forum.
Moderator redwudz -
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 -
Thanks for the help poisondeathray. How do I use mkvmerge, because I am unfamiliar with that portion of mkvtoolnix?
-
In mkvtoolnix, the output tab, look under splitting. You can use split mode : after output duration
You can do this by command line too
But there are batch mkvtoolnix helpers. e.g
https://github.com/Serede/mkvtoolnix-batch
You can create a json file , and there are step by step instructions included -
You can also view the command line the mkvtoolnix gui uses -- a good way to learn the command line syntax. Multiplexer -> Show Command Line.
-
There also is a good documentation about mkvtoolnix command line options over at https://mkvtoolnix.download/doc/mkvmerge.html which might come handy.
users currently on my ignore list: deadrats, Stears555 -
Hi, how can I find out the name of my device for the -init_hw_device parameter in FFmpeg?
I want to activate Vulkan video filters. In the documentation (https://ffmpeg.org/ffmpeg-filters.html#Vulkan-Video-Filters ) it is written:
Running Vulkan filters requires you to initialize a hardware device and to pass that device to all filters in any filter graph.
-init_hw_device vulkan[=name][:device[,key=value...]]
How do I find out the device name?
I have a Gigabyte GTX 1070 8GB graphics card.
Similar Threads
-
ffmpeg help
By loa909 in forum Newbie / General discussionsReplies: 6Last Post: 22nd Jan 2017, 06:02 -
Help in FFMPEG
By Recidivist in forum Video Streaming DownloadingReplies: 1Last Post: 27th Sep 2016, 10:43 -
(Willing to pay)ffmpeg Need help downloading live stream ffmpeg and rtmp
By grabyea in forum Video Streaming DownloadingReplies: 0Last Post: 10th Apr 2016, 16:54 -
FFMPEG QUESTION :How do I take 10bit jpeg with FFMPEG?
By Jamaika in forum Video ConversionReplies: 10Last Post: 6th Jul 2015, 13:41 -
MPG2Cut2 to FFMPEG MP4 vs FFMPEG MPG2 to MP4 AviDemux
By RedPenguin in forum Video ConversionReplies: 4Last Post: 29th Apr 2015, 12:16