Is there any way to trim video except using FFMPEG and MP4Parser?
I have used FFMPEG for video trimming but it's taking too much time for video processing.
String complexCommand = {"-ss", "" + startMs / 1000, "-y", "-i", yourRealPath, "-t", "" + (endMs - startMs) / 1000,"-vcodec", "mpeg4", "-b:v", "2097152", "-b:a", "48000", "-ac", "2", "-ar", "22050", filePath};
also used MP4Parser for same but some time I'm getting issue. used below lib for that.
com.googlecode.mp4parser:isoparser:1.1.21
Is there any other way available to trim video?
like my video duration is 20:00 and trim video between 06:00-09:00 duration.
android android-ffmpeg mp4parser
add a comment |
I have used FFMPEG for video trimming but it's taking too much time for video processing.
String complexCommand = {"-ss", "" + startMs / 1000, "-y", "-i", yourRealPath, "-t", "" + (endMs - startMs) / 1000,"-vcodec", "mpeg4", "-b:v", "2097152", "-b:a", "48000", "-ac", "2", "-ar", "22050", filePath};
also used MP4Parser for same but some time I'm getting issue. used below lib for that.
com.googlecode.mp4parser:isoparser:1.1.21
Is there any other way available to trim video?
like my video duration is 20:00 and trim video between 06:00-09:00 duration.
android android-ffmpeg mp4parser
add a comment |
I have used FFMPEG for video trimming but it's taking too much time for video processing.
String complexCommand = {"-ss", "" + startMs / 1000, "-y", "-i", yourRealPath, "-t", "" + (endMs - startMs) / 1000,"-vcodec", "mpeg4", "-b:v", "2097152", "-b:a", "48000", "-ac", "2", "-ar", "22050", filePath};
also used MP4Parser for same but some time I'm getting issue. used below lib for that.
com.googlecode.mp4parser:isoparser:1.1.21
Is there any other way available to trim video?
like my video duration is 20:00 and trim video between 06:00-09:00 duration.
android android-ffmpeg mp4parser
I have used FFMPEG for video trimming but it's taking too much time for video processing.
String complexCommand = {"-ss", "" + startMs / 1000, "-y", "-i", yourRealPath, "-t", "" + (endMs - startMs) / 1000,"-vcodec", "mpeg4", "-b:v", "2097152", "-b:a", "48000", "-ac", "2", "-ar", "22050", filePath};
also used MP4Parser for same but some time I'm getting issue. used below lib for that.
com.googlecode.mp4parser:isoparser:1.1.21
Is there any other way available to trim video?
like my video duration is 20:00 and trim video between 06:00-09:00 duration.
android android-ffmpeg mp4parser
android android-ffmpeg mp4parser
edited Jan 1 at 11:49
Akash Patel
asked Jan 1 at 9:12
Akash PatelAkash Patel
231113
231113
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Your example above is re-encoding the video based on the commands you give it. If you do NOT need to re-encode the video you can use the stream copy option, which directly copies the input stream to the output stream. Note that you are not strictly guaranteed to get precise beginning behavior, as you may not have the I-frame or equivalent you need at that exact point, or the codec my have to jump forward or backwards to find one. This method is extremely fast because there's no coding work to be done, it's just a copy from one (file) to another. On my 2018-class laptop it took me ~1.5 seconds to clip out 3 minutes of a video...
$ time ffmpeg -hide_banner -y -i input.mpg -ss 6:00 -t 3:00 -c:v copy output.mpg
[mpeg @ 0000024ffd46a740] start time for stream 0 is not set in estimate_timings_from_pts
Input #0, mpeg, from 'input.mpg':
Duration: 00:29:57.45, start: 0.516689, bitrate: 4108 kb/s
Stream #0:0[0x1bf]: Data: dvd_nav_packet
Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, progressive), 1280x720 [SAR 1:1 DAR 16:9], 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
[mpeg @ 0000024ffd47d500] VBV buffer size not set, using default size of 230KB
If you want the mpeg file to be compliant to some specification
Like DVD, VCD or others, make sure you set the correct buffer size
Output #0, mpeg, to 'output.mpg':
Metadata:
encoder : Lavf58.25.100
Stream #0:0: Video: mpeg2video (Main), yuv420p(tv, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 59.94 fps, 59.94 tbr, 90k tbn, 59.94 tbc
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mpeg @ 0000024ffd47d500] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
frame=10780 fps=0.0 q=-1.0 Lsize= 88314kB time=00:02:59.98 bitrate=4019.5kbits/s speed= 379x
video:87826kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.556108%
real 0m1.546s
user 0m0.000s
sys 0m0.000s
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53994256%2fis-there-any-way-to-trim-video-except-using-ffmpeg-and-mp4parser%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your example above is re-encoding the video based on the commands you give it. If you do NOT need to re-encode the video you can use the stream copy option, which directly copies the input stream to the output stream. Note that you are not strictly guaranteed to get precise beginning behavior, as you may not have the I-frame or equivalent you need at that exact point, or the codec my have to jump forward or backwards to find one. This method is extremely fast because there's no coding work to be done, it's just a copy from one (file) to another. On my 2018-class laptop it took me ~1.5 seconds to clip out 3 minutes of a video...
$ time ffmpeg -hide_banner -y -i input.mpg -ss 6:00 -t 3:00 -c:v copy output.mpg
[mpeg @ 0000024ffd46a740] start time for stream 0 is not set in estimate_timings_from_pts
Input #0, mpeg, from 'input.mpg':
Duration: 00:29:57.45, start: 0.516689, bitrate: 4108 kb/s
Stream #0:0[0x1bf]: Data: dvd_nav_packet
Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, progressive), 1280x720 [SAR 1:1 DAR 16:9], 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
[mpeg @ 0000024ffd47d500] VBV buffer size not set, using default size of 230KB
If you want the mpeg file to be compliant to some specification
Like DVD, VCD or others, make sure you set the correct buffer size
Output #0, mpeg, to 'output.mpg':
Metadata:
encoder : Lavf58.25.100
Stream #0:0: Video: mpeg2video (Main), yuv420p(tv, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 59.94 fps, 59.94 tbr, 90k tbn, 59.94 tbc
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mpeg @ 0000024ffd47d500] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
frame=10780 fps=0.0 q=-1.0 Lsize= 88314kB time=00:02:59.98 bitrate=4019.5kbits/s speed= 379x
video:87826kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.556108%
real 0m1.546s
user 0m0.000s
sys 0m0.000s
add a comment |
Your example above is re-encoding the video based on the commands you give it. If you do NOT need to re-encode the video you can use the stream copy option, which directly copies the input stream to the output stream. Note that you are not strictly guaranteed to get precise beginning behavior, as you may not have the I-frame or equivalent you need at that exact point, or the codec my have to jump forward or backwards to find one. This method is extremely fast because there's no coding work to be done, it's just a copy from one (file) to another. On my 2018-class laptop it took me ~1.5 seconds to clip out 3 minutes of a video...
$ time ffmpeg -hide_banner -y -i input.mpg -ss 6:00 -t 3:00 -c:v copy output.mpg
[mpeg @ 0000024ffd46a740] start time for stream 0 is not set in estimate_timings_from_pts
Input #0, mpeg, from 'input.mpg':
Duration: 00:29:57.45, start: 0.516689, bitrate: 4108 kb/s
Stream #0:0[0x1bf]: Data: dvd_nav_packet
Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, progressive), 1280x720 [SAR 1:1 DAR 16:9], 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
[mpeg @ 0000024ffd47d500] VBV buffer size not set, using default size of 230KB
If you want the mpeg file to be compliant to some specification
Like DVD, VCD or others, make sure you set the correct buffer size
Output #0, mpeg, to 'output.mpg':
Metadata:
encoder : Lavf58.25.100
Stream #0:0: Video: mpeg2video (Main), yuv420p(tv, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 59.94 fps, 59.94 tbr, 90k tbn, 59.94 tbc
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mpeg @ 0000024ffd47d500] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
frame=10780 fps=0.0 q=-1.0 Lsize= 88314kB time=00:02:59.98 bitrate=4019.5kbits/s speed= 379x
video:87826kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.556108%
real 0m1.546s
user 0m0.000s
sys 0m0.000s
add a comment |
Your example above is re-encoding the video based on the commands you give it. If you do NOT need to re-encode the video you can use the stream copy option, which directly copies the input stream to the output stream. Note that you are not strictly guaranteed to get precise beginning behavior, as you may not have the I-frame or equivalent you need at that exact point, or the codec my have to jump forward or backwards to find one. This method is extremely fast because there's no coding work to be done, it's just a copy from one (file) to another. On my 2018-class laptop it took me ~1.5 seconds to clip out 3 minutes of a video...
$ time ffmpeg -hide_banner -y -i input.mpg -ss 6:00 -t 3:00 -c:v copy output.mpg
[mpeg @ 0000024ffd46a740] start time for stream 0 is not set in estimate_timings_from_pts
Input #0, mpeg, from 'input.mpg':
Duration: 00:29:57.45, start: 0.516689, bitrate: 4108 kb/s
Stream #0:0[0x1bf]: Data: dvd_nav_packet
Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, progressive), 1280x720 [SAR 1:1 DAR 16:9], 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
[mpeg @ 0000024ffd47d500] VBV buffer size not set, using default size of 230KB
If you want the mpeg file to be compliant to some specification
Like DVD, VCD or others, make sure you set the correct buffer size
Output #0, mpeg, to 'output.mpg':
Metadata:
encoder : Lavf58.25.100
Stream #0:0: Video: mpeg2video (Main), yuv420p(tv, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 59.94 fps, 59.94 tbr, 90k tbn, 59.94 tbc
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mpeg @ 0000024ffd47d500] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
frame=10780 fps=0.0 q=-1.0 Lsize= 88314kB time=00:02:59.98 bitrate=4019.5kbits/s speed= 379x
video:87826kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.556108%
real 0m1.546s
user 0m0.000s
sys 0m0.000s
Your example above is re-encoding the video based on the commands you give it. If you do NOT need to re-encode the video you can use the stream copy option, which directly copies the input stream to the output stream. Note that you are not strictly guaranteed to get precise beginning behavior, as you may not have the I-frame or equivalent you need at that exact point, or the codec my have to jump forward or backwards to find one. This method is extremely fast because there's no coding work to be done, it's just a copy from one (file) to another. On my 2018-class laptop it took me ~1.5 seconds to clip out 3 minutes of a video...
$ time ffmpeg -hide_banner -y -i input.mpg -ss 6:00 -t 3:00 -c:v copy output.mpg
[mpeg @ 0000024ffd46a740] start time for stream 0 is not set in estimate_timings_from_pts
Input #0, mpeg, from 'input.mpg':
Duration: 00:29:57.45, start: 0.516689, bitrate: 4108 kb/s
Stream #0:0[0x1bf]: Data: dvd_nav_packet
Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, progressive), 1280x720 [SAR 1:1 DAR 16:9], 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
[mpeg @ 0000024ffd47d500] VBV buffer size not set, using default size of 230KB
If you want the mpeg file to be compliant to some specification
Like DVD, VCD or others, make sure you set the correct buffer size
Output #0, mpeg, to 'output.mpg':
Metadata:
encoder : Lavf58.25.100
Stream #0:0: Video: mpeg2video (Main), yuv420p(tv, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 59.94 fps, 59.94 tbr, 90k tbn, 59.94 tbc
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mpeg @ 0000024ffd47d500] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
frame=10780 fps=0.0 q=-1.0 Lsize= 88314kB time=00:02:59.98 bitrate=4019.5kbits/s speed= 379x
video:87826kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.556108%
real 0m1.546s
user 0m0.000s
sys 0m0.000s
answered Jan 1 at 16:11
ljwobkerljwobker
291314
291314
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53994256%2fis-there-any-way-to-trim-video-except-using-ffmpeg-and-mp4parser%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown