Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 12th April 2010, 22:40   #1  |  Link
mynewusername
Registered User
 
Join Date: Apr 2010
Posts: 9
How to split x264 encoded video into segments?

Hi,

First off, this is my first post on the forums. So hello everyone. I have been a long time reader but until now I have always been able to find answers to my questions without needing to start a new thread.

Here is my problem:

I have unsuccessfully been trying to split some video files I encoded with x264 into individual segments. I want to end up with a video segment for each keyframe where each segment is independent of other segments.
(I.e. if the video file has 300 keyframes in it I want 300 segments.)

Since I have not been able to achieve this so I figured I would ask on the forum. The files are going to be distributed over the internet and splitting them up like this makes distribution easier for my project.

Can anyone point me towards something that can help me with this? It doesn't necessarily have to be a splitting method. If it is possible to directly encode the segments split up already then I wouldn't be opposed to re-encoding them. I actually tried encoding the segments separately to begin with, but I kept getting overlap at the cuts.

Thanks =)

edit:
The final video needs to be in an mp4 container, so it would be best if someone knows a tool that can do this with a mp4 container directly

Last edited by Guest; 13th April 2010 at 03:33. Reason: rule 12
mynewusername is offline   Reply With Quote
Old 12th April 2010, 23:19   #2  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
You could try using mkvtoolnix. Load the file into mmg and set splitting to "1K" "after this size" in the "global" tab. I haven't actually tried this, but it just might work.

/edit: OK, made a short test and the GUI doesn't allow it. Set it to anything, copy the command line into cmd and edit it manually to 1K.

Last edited by sneaker_ger; 12th April 2010 at 23:23.
sneaker_ger is offline   Reply With Quote
Old 12th April 2010, 23:43   #3  |  Link
mynewusername
Registered User
 
Join Date: Apr 2010
Posts: 9
thanks, ill give it a shot. the command line is preferable to me anyways.
mynewusername is offline   Reply With Quote
Old 13th April 2010, 00:04   #4  |  Link
mynewusername
Registered User
 
Join Date: Apr 2010
Posts: 9
Quote:
Originally Posted by sneaker_ger View Post
You could try using mkvtoolnix. Load the file into mmg and set splitting to "1K" "after this size" in the "global" tab. I haven't actually tried this, but it just might work.

/edit: OK, made a short test and the GUI doesn't allow it. Set it to anything, copy the command line into cmd and edit it manually to 1K.
thats a nice tool I haven't seen before. Thanks for that
mynewusername is offline   Reply With Quote
Old 13th April 2010, 04:17   #5  |  Link
mynewusername
Registered User
 
Join Date: Apr 2010
Posts: 9
I have never used the mkv container before. I used the mkvtoolnix tool that you recommended and it splits great when you use a 1kb filesize. I cannot get ffmpeg to convert it back to a mp4 container.

ffmpeg -i "split.mkv" -vcodec copy -acodec copy split.mp4
gives me av_interleaved_write_frame(): Error while opening file

Here is the ffmpeg -i output on the source mp4:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'orig.mp4':
Duration: 00:04:51.43, start: 0.000000, bitrate: 791 kb/s
Stream #0.0(und): Video: h264, yuv420p, 432x240, 29.97 tb(r)
Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, s16


And here is the ffmpeg -i output on the split.mkv that I am trying to turn back into a mp4:

Input #0, matroska, from 'split.mkv':
Duration: 00:00:00.97, start: 0.000000, bitrate: N/A
Stream #0.0: Video: h264, yuv420p, 432x240, 29.97 tb(r)
Stream #0.1: Audio: aac, 48000 Hz, stereo, s16

The stream info seems to be the same so I don't see why the copy doesn't work.


I need the final output files to be in the mp4 container with h.264 video so I can play them in the browser.

Any tips?

I wish mp4box would work with a small filesize like this, but it doesn't. It seems to mess up if the input filesize or duration to split on is less than the next keyframe and outputs a corrupt file. So if you set it to do the filesize of 1kb it just keeps putting out corrupted files. I stepped away from my computer and came back with 10000 corrupted clips to delete =(.
mynewusername is offline   Reply With Quote
Old 13th April 2010, 06:18   #6  |  Link
roozhou
Registered User
 
Join Date: Apr 2008
Posts: 1,181
Quote:
Originally Posted by mynewusername View Post
I have never used the mkv container before. I used the mkvtoolnix tool that you recommended and it splits great when you use a 1kb filesize. I cannot get ffmpeg to convert it back to a mp4 container.
Use ffmpeg fromthis thread. Official ffmpeg builds do not support mkv->mp4 muxing.

If you are not using windows, apply my patch in that post to ffmpeg's code and make your own build.
roozhou is offline   Reply With Quote
Reply

Tags
"split on keyframe", h.264, split, splitting, x264

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 00:25.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.