VideoHelp Forum

+ Reply to Thread
Results 1 to 26 of 26
Thread
  1. Member
    Join Date
    Jul 2022
    Location
    India
    Search Comp PM
    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 )
    Last edited by xd003; 1st Jul 2022 at 04:39.
    Quote Quote  
  2. 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
    Quote Quote  
  3. Try TSMuxer.
    I am not sure if 4.) works 100%, but worth a try.
    Quote Quote  
  4. Member
    Join Date
    Jul 2022
    Location
    India
    Search Comp PM
    Originally Posted by video.baba View Post
    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
    i am trying to transfer content from my expiring vps to the mega account , they have this limit around 4-5 GB so 4 GB split should be sufficient to get me through
    Last edited by xd003; 1st Jul 2022 at 07:16.
    Quote Quote  
  5. What containers do the video use (ex: mp4, mkv, etc) ?
    Quote Quote  
  6. Member
    Join Date
    Jul 2022
    Location
    India
    Search Comp PM
    Originally Posted by butterw View Post
    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 )
    Quote Quote  
  7. Member DB83's Avatar
    Join Date
    Jul 2007
    Location
    United Kingdom
    Search Comp PM
    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.
    Quote Quote  
  8. Member
    Join Date
    Jul 2022
    Location
    India
    Search Comp PM
    Originally Posted by DB83 View Post
    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 "_"
    Quote Quote  
  9. Member
    Join Date
    Jul 2022
    Location
    India
    Search Comp PM
    Originally Posted by Quint View Post
    Try TSMuxer.
    I am not sure if 4.) works 100%, but worth a try.
    Do you have any guide or command on how to do it ? Can't seem to find it
    Quote Quote  
  10. ZIP or RAR archives can be set to split at specified sizes.
    Quote Quote  
  11. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    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

    Scott
    Last edited by Cornucopia; 1st Jul 2022 at 08:55.
    Quote Quote  
  12. Member
    Join Date
    Jul 2022
    Location
    India
    Search Comp PM
    Originally Posted by Cornucopia View Post
    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

    Scott
    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.
    Quote Quote  
  13. I'm a Super Moderator johns0's Avatar
    Join Date
    Jun 2002
    Location
    canada
    Search Comp PM
    mkvmerge will split on duration size so it will hit close to 4gb and also merge back the files it split flawlessly.
    I think,therefore i am a hamster.
    Quote Quote  
  14. 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
    Second half:
    Code:
    ffmpeg -i video.mkv -ss 01:02:00 -to 01:45:00 -c copy cut.mkv
    You need to match the end time to the video you are spliting.
    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 use Windows & this works for me.
    I hope there is a way you can use it with linux.
    I also don't know if
    each split starts with new keyframe
    using ffmpeg like this.
    Last edited by cholla; 1st Jul 2022 at 11:01.
    Quote Quote  
  15. I'm a Super Moderator johns0's Avatar
    Join Date
    Jun 2002
    Location
    canada
    Search Comp PM
    Just realized i meant to say mkvmerge will split on size as well as duration.
    I think,therefore i am a hamster.
    Quote Quote  
  16. Member DB83's Avatar
    Join Date
    Jul 2007
    Location
    United Kingdom
    Search Comp PM
    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.
    Quote Quote  
  17. Member
    Join Date
    Jul 2022
    Location
    India
    Search Comp PM
    Originally Posted by DB83 View Post
    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.
    Its the daily upload limit of 5 gb
    Quote Quote  
  18. 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 know that this can be done with mkvtoolnix that uses mkvmerge.
    I have it in my toolbox.
    Quote Quote  
  19. WinRar
    Discord codehound#0348
    Quote Quote  
  20. Originally Posted by cholla View Post
    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 ?
    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
    To make this generally useful you would have to do the split in a loop, generate incrementing numbers for the frame names, and adding the runtimes for each segment. When I appended the two parts back together the join wasn't seamless. A few frames were duplicated. I seem to recall that one needs to specify a frame time one or two frames before the actual I frame for ffmpeg to trim accurately.
    Quote Quote  
  21. Member
    Join Date
    Feb 2006
    Location
    England
    Search PM
    Originally Posted by jagabo View Post
    ZIP or RAR archives can be set to split at specified sizes.
    He said he wanted to be able to play the individual parts. That won’t happen in zips. Please read the full post before commenting.
    Quote Quote  
  22. Member
    Join Date
    Aug 2010
    Location
    San Francisco, California
    Search PM
    Originally Posted by jagabo View Post
    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
    The reason this isn't seamless is that when doing codec-copy, FFmpeg will seek backwards to the nearest I-frame.
    Last edited by JVRaines; 7th Jul 2022 at 22:19.
    Quote Quote  
  23. Originally Posted by jagabo View Post
    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
    To make this generally useful you would have to do the split in a loop, generate incrementing numbers for the frame names, and adding the runtimes for each segment. When I appended the two parts back together the join wasn't seamless. A few frames were duplicated. I seem to recall that one needs to specify a frame time one or two frames before the actual I frame for ffmpeg to trim accurately.
    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
    This one the duration is in seconds:
    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
    No loop required.
    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.
    Quote Quote  
  24. Originally Posted by cholla View Post
    No loop required.
    If your source is over 8 GB it will require more than two 4GB segments. That's when you will need additional logic.

    Originally Posted by cholla View Post
    I watched the video & it was seamless as far as I could tell.
    Maybe you have a way to check with some software.
    I appended the segments with MkvMergeGUI then stepped through the transition frame by frame.

    Originally Posted by cholla View Post
    Although I used -fs 4G the part1.mkv is 3.73GB.
    That's the difference between GB (ffmpeg) and 4GiB (Windows). 4,000,000,000 / 1024 / 1024 / 1024 = 3.72529...
    Quote Quote  
  25. Again thanks for the help jagabo.


    Originally Posted by jagabo View Post
    If your source is over 8 GB it will require more than two 4GB segments. That's when you will need additional logic.
    The OP asked about:
    6 GB video should give 4 GB & 2 GB splits
    I guess there could be a blu ray rip that was converted to .mkv & still be 50GB.
    I don't have any & the ones I've seen are much smaller.

    Originally Posted by jagabo View Post
    I appended the segments with MkvMergeGUI then stepped through the transition frame by frame.
    I looked for the MkvMergeGUI & I couldn't find a download for it.
    It seems to have been replaced by the mkvtoonix-GUI.

    Originally Posted by jagabo View Post
    That's the difference between GB (ffmpeg) and 4GiB (Windows). 4,000,000,000 / 1024 / 1024 / 1024 = 3.72529...
    I knew this but wanted to make the OP aware of it.
    I plan to try a -fs 4.2G & see if that works.
    Quote Quote  
  26. Originally Posted by cholla View Post
    I looked for the MkvMergeGUI & I couldn't find a download for it.
    It seems to have been replaced by the mkvtoonix-GUI.
    Sorry, yes, I used mkvtoolnix-gui.
    Quote Quote  



Similar Threads