i want to split videos at/under 4GB without re-encoding it ( Eg 6 GB video should give 4 GB & 2 GB splits , 9 should give 4 GB , 4 GB & 1 GB splits )
. i have been trying to find a reliable solution from past week all over internet but everywhere its just mentioned how to split through duration, about file size its too little info and doesn't really work . I am not from this field , never knew something so simple would be so uncommon and difficult to find . As a last resort , i tried stuffs like taking the whole duration & size of video as a base and splitting based upon that but the sizes were too off ( i guess due to inconsistent bitrate throughout the video ) . Can someone around here please help me out , i have higher hopes as this is a video specific forum
Here are some important points :
1) I don't want any loss in audio or video quality in the splits generated ( without re-encoding anything ) . Each of the splits should be individually playable
2) Each of the splits should start with a new keyframe & should retain audio tracks and subtitles
3) I do understand that the splits might not be exact 4 GB due to splitting at keyframe but 4 GB should be the max limit , ie it could be little lesser than 4 GB if it has to
4) If i merge/concatenate these splits , i should be able to generate the original file perfectly
5) I don't have any particular choice in tools to be used , whatever works best . Only thing is it should be doable in linux cli ( i have to do this on quite a lot of videos so i would be doing it on linux cli looping through each video )
+ Reply to Thread
Results 1 to 26 of 26
-
Last edited by xd003; 1st Jul 2022 at 04:39.
-
Do you have this (4GB) constraint because:
1. You need to put the file onto a single sided DVD?
2. You are saving to a FAT32 drive?
3. You're reading some out-dated guide?
4. Something else? I'm curious -
Last edited by xd003; 1st Jul 2022 at 07:16.
-
What containers do the video use (ex: mp4, mkv, etc) ?
-
Most of them are mkv but some are mp4 as well
If you are asking this because there are multiple cli tools which handle a particular container best ( as againt a single tool that handles all like ffmpeg ) , i am fine by using them individually . i can make the bash script use x cli tool for *.mkv & y tool for *.mp4 videos ( Just assuming ) -
That limit (free ?) could well be 4 gb. Not multiples of 4 gb
TBH Forget about on-line storage in this scenario. Yes, it can be done (for example mymp4box can split a video - I guess only .mp4 - in to whatever size you desire but once the video is split you will be 'annoyed' by that restriction. -
Yes its for 24 hours , i will be uploading them daily with 2 of my mega account until i transfer it all . i have seen mymp4box but does it tick all the points i have mentioned ? i used this https://github.com/c0decracker/video-splitter as well but the generated splits had the subtitles & an additonal audio track missing for some reason "_"
-
-
If all you are trying to do is temp store them, you don't need to worry about how it splits (& recombines) as long as it is a totally lossless, symmetrical process and is reproducible.
So use zip file segmenting, or some other splitting/combining tool - gsplit, hjsplit, peazip.
@jagabo beat me to it
ScottLast edited by Cornucopia; 1st Jul 2022 at 08:55.
-
thanks for the reply but i am intending to generate splits which are individually playable on their own . On another note , i did gave mkvmerge a try , it does have a split option with size flag exactly as i need , only thing is i am not so sure if it fulfills the points i have mentioned . If someone can confirm, that would be really great . i mean it does generate the splits well , audio tracks and subs are retained & ofc works over cli . I just need to know 1) if it causes any quality loss & 2) if each split starts with new keyframe & 3) If those splits could be merged to obtain the original file flawlessly
Last edited by xd003; 1st Jul 2022 at 10:25.
-
I can't help with linux but ffmpeg should be able to do this.
Except not by size as far as I know.
It would split by duration.
Also to keep the subtitles the format would need to be .mkv
At least for me most .mp4 subtitles don't work well with ffmpeg.
First half:
Code:ffmpeg -i video.mkv -ss 00:00:00 -to 01:02:00 -c copy cut.mkv
Code:ffmpeg -i video.mkv -ss 01:02:00 -to 01:45:00 -c copy cut.mkv
Above is just an example
If -c copy doesn't work you may has to use these:
Code:-c:v copy -c:a copy -c:s copy
I hope there is a way you can use it with linux.
I also don't know ifeach split starts with new keyframeLast edited by cholla; 1st Jul 2022 at 11:01.
-
BTW I do not see any Mega option for a daily 4 gb limit. The free account has 20 gb of storage.
Even then I do not see any option, either free or paid, for direct playback of stored media (I have seen one, other than Google Drive, that did but forget its name now)
As I said, and sorry for the repeat, a pointless excercise expecially if you have more than one audio track and subs. -
I have been working on this with ffmpeg .
Mostly to see if I could do it.
I was able to get ffmpeg to extract the first 4GB of a audio/video file.
What ffmpeg didn't do was go on to create a second audio/video of the rest of the video.
Does anyone know how to do this with ffmpeg ?
Where ffmpeg would start creating the second file where the first file stopped.
This is the code I used:
Code:ffmpeg -i input -fs 4G -c copy output
I have it in my toolbox. -
I've seen it done using ffprobe to get the runtime of the first part then using that value as the starting point of the next part. Something like this:
Code:ffmpeg -i "source.mp4" -fs 300M -c copy "part1.mp4" ffprobe.exe -v quiet -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 -select_streams v:0 "part1.mp4" >duration.txt set /p duration=<duration.txt REM del duration.txt echo duration = %duration% ffmpeg -ss %duration% -i "source.mp4" -fs 300M -c copy "part2.mp4" pause
-
-
Last edited by JVRaines; 7th Jul 2022 at 22:19.
-
Thanks jagabo Your sample code got me close enough to create the code I needed.
The part1 file has to be done first.
When I tried it all at once I got only a small file for part1.
Then after the second part of the code done the file to be created is there but has to be Entered .
This one uses the 00:00:00:00 hour minute second format for duration.
Code:ffmpeg -i source.mkv -fs 4G -c copy part1.mkv ffprobe -v trace -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 -sexagesimal -select_streams v:0 part1.mkv >duration.txt set /p duration=<duration.txt REM del duration.txt echo duration = %duration% ffmpeg -ss %duration% -i source.mkv -c copy part2.mkv
Code:ffmpeg -i source.mkv -fs 4G -c copy part1.mkv ffprobe -v trace -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 -select_streams v:0 part1.mkv >duration.txt set /p duration=<duration.txt REM del duration.txt echo duration = %duration% ffmpeg -ss %duration% -i source.mkv -c copy part2.mkv
I watched the video & it was seamless as far as I could tell.
Maybe you have a way to check with some software.
I also did not need -fs for the second part2.mkv but I was working with about a 6GB .mkv file.
Although I used -fs 4G the part1.mkv is 3.73GB.
I'm sure I could have used -fs 5G for a larger file.
I just wanted some left for the part2.mkv
I used mkvtoolnix GUI to join part1 & part2. -
If your source is over 8 GB it will require more than two 4GB segments. That's when you will need additional logic.
I appended the segments with MkvMergeGUI then stepped through the transition frame by frame.
That's the difference between GB (ffmpeg) and 4GiB (Windows). 4,000,000,000 / 1024 / 1024 / 1024 = 3.72529... -
Again thanks for the help jagabo.
The OP asked about:6 GB video should give 4 GB & 2 GB splits
I don't have any & the ones I've seen are much smaller.
I looked for the MkvMergeGUI & I couldn't find a download for it.
It seems to have been replaced by the mkvtoonix-GUI.
I knew this but wanted to make the OP aware of it.
I plan to try a -fs 4.2G & see if that works.
Similar Threads
-
Combining default window size (output size + fit to video aspect ratio)
By dogeboy in forum Software PlayingReplies: 3Last Post: 23rd Oct 2021, 23:42 -
Video Split Does not split at exact point
By Nothingissimple in forum EditingReplies: 2Last Post: 2nd Oct 2020, 20:58 -
How to split a .TS video file based on time (not file size!) ?
By Michael REMY in forum EditingReplies: 4Last Post: 19th Sep 2020, 18:32 -
Need help writing an ffmpeg script to batch split many video files by size
By manav in forum Newbie / General discussionsReplies: 11Last Post: 6th Aug 2020, 17:37 -
Lossless encoding without increasing size
By Megafox in forum Newbie / General discussionsReplies: 10Last Post: 20th Sep 2018, 16:56