java - split video without knowing file duration -


i want make chunks of video each chunks not more 3 minutes using ffmpeg.i have read command of ffmpeg.

ffmpeg -i output.mp4 -ss 0 -t 180 -c copy outputvideosegment.mp4 

i using in code like

 string command = "ffmpeg -i videos/testing.vob  -ss 0 -t 180 -c copy outputvideosegment.mp4";              processbuilder processbuilder = new processbuilder("/bin/sh", "-c", command);             try {                 process process = processbuilder.start();                 process.waitfor(); // wait process builder finish                                     // process             } catch (exception exception) {                 log.error("exception occured in making chunks due " + exception.getcause());             } 

the above command working fine , spliting video 3 min, in case have read file dont know duration of file.do need run above command inside loop or other way.please help.

the segment duration 180s if have keyframe present each 180s.

you can use -c copy if input video has keyframes @ splitting points.

if doesn't must re-encode , add them before splitting:

ffmpeg -i <input> -g 250 -sc_threshold 0 -f segment -segment_time 180 segment_%02d.mp4 

where:

  • -g 250 [frames] adds keyframe every 250 frames (10s @ 25 fps)
  • -sc_threshold = 0 avoids inserting keyframes on scene-change
  • -segment_time 180 [s] creates segments of specified duration , must multiple of keyframe interval

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -