Black frames at beginning of video file when file cut
I use ffmpeg to cut a video file.
The format i use is this:
ffmpeg -i input.avi -ss 00:06:30 -to 00:07:15 -c copy output.avi
Unfortunately this leaves some black frames in the beginning of my output video, so i lose certain parts of the video. In one video i tried, this went on for one second, in another, the black frames lasted 4 seconds.
The funny thing is that when i used the same command, exactly the same amount of black frame exists for the same video. Meaning, no matter how many times i did this for my second video, in all outputs, the output video will be blank for the first 4 seconds!
The sound works great though!
Here are some other command formats i tried and did NOT work:
ffmpeg -ss 00:01:00 -i video.mp4 -to 00:02:00 -c copy cut.mp4
ffmpeg -ss 00:01:00 -i video.mp4 -to 00:02:00 -c copy -copyts cut.mp4
I thout i found my solution with the command i used, but then this problem occured
EDIT: I figured out that if i don't use the -c copy
flag, then i do not have the black frames:
ffmpeg -i input.avi -ss 00:06:30 -to 00:07:15 output.avi
However, with this method, the quality of my output video is significantly lower than the input video, or the output video from the previous methods. So i am back at square one.
audio video ffmpeg cut
add a comment |
I use ffmpeg to cut a video file.
The format i use is this:
ffmpeg -i input.avi -ss 00:06:30 -to 00:07:15 -c copy output.avi
Unfortunately this leaves some black frames in the beginning of my output video, so i lose certain parts of the video. In one video i tried, this went on for one second, in another, the black frames lasted 4 seconds.
The funny thing is that when i used the same command, exactly the same amount of black frame exists for the same video. Meaning, no matter how many times i did this for my second video, in all outputs, the output video will be blank for the first 4 seconds!
The sound works great though!
Here are some other command formats i tried and did NOT work:
ffmpeg -ss 00:01:00 -i video.mp4 -to 00:02:00 -c copy cut.mp4
ffmpeg -ss 00:01:00 -i video.mp4 -to 00:02:00 -c copy -copyts cut.mp4
I thout i found my solution with the command i used, but then this problem occured
EDIT: I figured out that if i don't use the -c copy
flag, then i do not have the black frames:
ffmpeg -i input.avi -ss 00:06:30 -to 00:07:15 output.avi
However, with this method, the quality of my output video is significantly lower than the input video, or the output video from the previous methods. So i am back at square one.
audio video ffmpeg cut
"Unfortunately this leaves some black frames in the beginning of my output video" – how are you trying to view the video? Also, please show the full, uncut command line output as well.
– slhck
Jun 26 '17 at 12:32
add a comment |
I use ffmpeg to cut a video file.
The format i use is this:
ffmpeg -i input.avi -ss 00:06:30 -to 00:07:15 -c copy output.avi
Unfortunately this leaves some black frames in the beginning of my output video, so i lose certain parts of the video. In one video i tried, this went on for one second, in another, the black frames lasted 4 seconds.
The funny thing is that when i used the same command, exactly the same amount of black frame exists for the same video. Meaning, no matter how many times i did this for my second video, in all outputs, the output video will be blank for the first 4 seconds!
The sound works great though!
Here are some other command formats i tried and did NOT work:
ffmpeg -ss 00:01:00 -i video.mp4 -to 00:02:00 -c copy cut.mp4
ffmpeg -ss 00:01:00 -i video.mp4 -to 00:02:00 -c copy -copyts cut.mp4
I thout i found my solution with the command i used, but then this problem occured
EDIT: I figured out that if i don't use the -c copy
flag, then i do not have the black frames:
ffmpeg -i input.avi -ss 00:06:30 -to 00:07:15 output.avi
However, with this method, the quality of my output video is significantly lower than the input video, or the output video from the previous methods. So i am back at square one.
audio video ffmpeg cut
I use ffmpeg to cut a video file.
The format i use is this:
ffmpeg -i input.avi -ss 00:06:30 -to 00:07:15 -c copy output.avi
Unfortunately this leaves some black frames in the beginning of my output video, so i lose certain parts of the video. In one video i tried, this went on for one second, in another, the black frames lasted 4 seconds.
The funny thing is that when i used the same command, exactly the same amount of black frame exists for the same video. Meaning, no matter how many times i did this for my second video, in all outputs, the output video will be blank for the first 4 seconds!
The sound works great though!
Here are some other command formats i tried and did NOT work:
ffmpeg -ss 00:01:00 -i video.mp4 -to 00:02:00 -c copy cut.mp4
ffmpeg -ss 00:01:00 -i video.mp4 -to 00:02:00 -c copy -copyts cut.mp4
I thout i found my solution with the command i used, but then this problem occured
EDIT: I figured out that if i don't use the -c copy
flag, then i do not have the black frames:
ffmpeg -i input.avi -ss 00:06:30 -to 00:07:15 output.avi
However, with this method, the quality of my output video is significantly lower than the input video, or the output video from the previous methods. So i am back at square one.
audio video ffmpeg cut
audio video ffmpeg cut
edited Jun 26 '17 at 10:26
user1584421
asked Jun 26 '17 at 10:06
user1584421user1584421
1014
1014
"Unfortunately this leaves some black frames in the beginning of my output video" – how are you trying to view the video? Also, please show the full, uncut command line output as well.
– slhck
Jun 26 '17 at 12:32
add a comment |
"Unfortunately this leaves some black frames in the beginning of my output video" – how are you trying to view the video? Also, please show the full, uncut command line output as well.
– slhck
Jun 26 '17 at 12:32
"Unfortunately this leaves some black frames in the beginning of my output video" – how are you trying to view the video? Also, please show the full, uncut command line output as well.
– slhck
Jun 26 '17 at 12:32
"Unfortunately this leaves some black frames in the beginning of my output video" – how are you trying to view the video? Also, please show the full, uncut command line output as well.
– slhck
Jun 26 '17 at 12:32
add a comment |
2 Answers
2
active
oldest
votes
Make sure that you are using a recent version of ffmpeg by downloading a static build, for example. There have been some major changes a while ago which affect how stream cutting works.
Here's the important difference between the commands that you ran:
When specifying
-c copy
, ffmpeg will cut the video without modifying the actual bitstream. In other words, it will take the frames as-is and copy them to the output file. In some cases (simply put, when the starting time does not correspond to an I-frame), ffmpeg needs to include some more frames that are needed to properly decode the first frame to be displayed. Those will get a negative timestamp, so they shouldn't be shown.When you leave out
-c copy
, ffmpeg will re-encode the video with whatever encoder (mpeg4
,libx264
, ...) is the default for the chosen output format (AVI or MP4 in your case). These encoders may have default quality or bitrate settings that make the output look bad. When re-encoding, you should therefore know what target quality you want to set.
If cutting with stream copying does not work for you, and if you have to re-encode the video, you may as well use a recent and efficient video codec (H.264) and container (MP4), and copy the audio stream:
ffmpeg -ss 00:10:45 -i input.avi -c:v libx264 -crf 18 -to 00:11:45 -c:a copy output.mp4
Here, the CRF option controls the output quality. Values between 18 and 28 are "normal", lower values are better. The -ss
option can be an input option (i.e., one that appears before -i
) which makes everything faster.
For more information, read the Seeking guide on the FFmpeg Wiki.
What do you mean by "the-ss
can be an input option" here?
– Hashim
Jan 12 at 0:58
1
@Hashim See updated post
– slhck
Jan 12 at 11:05
add a comment |
For anyone having the same problem, i finally managed to solve it with this:
ffmpeg -i input.avi -qscale 0 -ss 00:10:45 -to 00:11:45 output.avi
1
While this does solve the problem you're experiencing. it is not recommended. Here you are re-encoding the video and creating an unnecessarily large output file while doing so.
– slhck
Jun 26 '17 at 12:33
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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%2fsuperuser.com%2fquestions%2f1222801%2fblack-frames-at-beginning-of-video-file-when-file-cut%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Make sure that you are using a recent version of ffmpeg by downloading a static build, for example. There have been some major changes a while ago which affect how stream cutting works.
Here's the important difference between the commands that you ran:
When specifying
-c copy
, ffmpeg will cut the video without modifying the actual bitstream. In other words, it will take the frames as-is and copy them to the output file. In some cases (simply put, when the starting time does not correspond to an I-frame), ffmpeg needs to include some more frames that are needed to properly decode the first frame to be displayed. Those will get a negative timestamp, so they shouldn't be shown.When you leave out
-c copy
, ffmpeg will re-encode the video with whatever encoder (mpeg4
,libx264
, ...) is the default for the chosen output format (AVI or MP4 in your case). These encoders may have default quality or bitrate settings that make the output look bad. When re-encoding, you should therefore know what target quality you want to set.
If cutting with stream copying does not work for you, and if you have to re-encode the video, you may as well use a recent and efficient video codec (H.264) and container (MP4), and copy the audio stream:
ffmpeg -ss 00:10:45 -i input.avi -c:v libx264 -crf 18 -to 00:11:45 -c:a copy output.mp4
Here, the CRF option controls the output quality. Values between 18 and 28 are "normal", lower values are better. The -ss
option can be an input option (i.e., one that appears before -i
) which makes everything faster.
For more information, read the Seeking guide on the FFmpeg Wiki.
What do you mean by "the-ss
can be an input option" here?
– Hashim
Jan 12 at 0:58
1
@Hashim See updated post
– slhck
Jan 12 at 11:05
add a comment |
Make sure that you are using a recent version of ffmpeg by downloading a static build, for example. There have been some major changes a while ago which affect how stream cutting works.
Here's the important difference between the commands that you ran:
When specifying
-c copy
, ffmpeg will cut the video without modifying the actual bitstream. In other words, it will take the frames as-is and copy them to the output file. In some cases (simply put, when the starting time does not correspond to an I-frame), ffmpeg needs to include some more frames that are needed to properly decode the first frame to be displayed. Those will get a negative timestamp, so they shouldn't be shown.When you leave out
-c copy
, ffmpeg will re-encode the video with whatever encoder (mpeg4
,libx264
, ...) is the default for the chosen output format (AVI or MP4 in your case). These encoders may have default quality or bitrate settings that make the output look bad. When re-encoding, you should therefore know what target quality you want to set.
If cutting with stream copying does not work for you, and if you have to re-encode the video, you may as well use a recent and efficient video codec (H.264) and container (MP4), and copy the audio stream:
ffmpeg -ss 00:10:45 -i input.avi -c:v libx264 -crf 18 -to 00:11:45 -c:a copy output.mp4
Here, the CRF option controls the output quality. Values between 18 and 28 are "normal", lower values are better. The -ss
option can be an input option (i.e., one that appears before -i
) which makes everything faster.
For more information, read the Seeking guide on the FFmpeg Wiki.
What do you mean by "the-ss
can be an input option" here?
– Hashim
Jan 12 at 0:58
1
@Hashim See updated post
– slhck
Jan 12 at 11:05
add a comment |
Make sure that you are using a recent version of ffmpeg by downloading a static build, for example. There have been some major changes a while ago which affect how stream cutting works.
Here's the important difference between the commands that you ran:
When specifying
-c copy
, ffmpeg will cut the video without modifying the actual bitstream. In other words, it will take the frames as-is and copy them to the output file. In some cases (simply put, when the starting time does not correspond to an I-frame), ffmpeg needs to include some more frames that are needed to properly decode the first frame to be displayed. Those will get a negative timestamp, so they shouldn't be shown.When you leave out
-c copy
, ffmpeg will re-encode the video with whatever encoder (mpeg4
,libx264
, ...) is the default for the chosen output format (AVI or MP4 in your case). These encoders may have default quality or bitrate settings that make the output look bad. When re-encoding, you should therefore know what target quality you want to set.
If cutting with stream copying does not work for you, and if you have to re-encode the video, you may as well use a recent and efficient video codec (H.264) and container (MP4), and copy the audio stream:
ffmpeg -ss 00:10:45 -i input.avi -c:v libx264 -crf 18 -to 00:11:45 -c:a copy output.mp4
Here, the CRF option controls the output quality. Values between 18 and 28 are "normal", lower values are better. The -ss
option can be an input option (i.e., one that appears before -i
) which makes everything faster.
For more information, read the Seeking guide on the FFmpeg Wiki.
Make sure that you are using a recent version of ffmpeg by downloading a static build, for example. There have been some major changes a while ago which affect how stream cutting works.
Here's the important difference between the commands that you ran:
When specifying
-c copy
, ffmpeg will cut the video without modifying the actual bitstream. In other words, it will take the frames as-is and copy them to the output file. In some cases (simply put, when the starting time does not correspond to an I-frame), ffmpeg needs to include some more frames that are needed to properly decode the first frame to be displayed. Those will get a negative timestamp, so they shouldn't be shown.When you leave out
-c copy
, ffmpeg will re-encode the video with whatever encoder (mpeg4
,libx264
, ...) is the default for the chosen output format (AVI or MP4 in your case). These encoders may have default quality or bitrate settings that make the output look bad. When re-encoding, you should therefore know what target quality you want to set.
If cutting with stream copying does not work for you, and if you have to re-encode the video, you may as well use a recent and efficient video codec (H.264) and container (MP4), and copy the audio stream:
ffmpeg -ss 00:10:45 -i input.avi -c:v libx264 -crf 18 -to 00:11:45 -c:a copy output.mp4
Here, the CRF option controls the output quality. Values between 18 and 28 are "normal", lower values are better. The -ss
option can be an input option (i.e., one that appears before -i
) which makes everything faster.
For more information, read the Seeking guide on the FFmpeg Wiki.
edited Jan 12 at 11:05
answered Jun 26 '17 at 12:45
slhckslhck
160k47444466
160k47444466
What do you mean by "the-ss
can be an input option" here?
– Hashim
Jan 12 at 0:58
1
@Hashim See updated post
– slhck
Jan 12 at 11:05
add a comment |
What do you mean by "the-ss
can be an input option" here?
– Hashim
Jan 12 at 0:58
1
@Hashim See updated post
– slhck
Jan 12 at 11:05
What do you mean by "the
-ss
can be an input option" here?– Hashim
Jan 12 at 0:58
What do you mean by "the
-ss
can be an input option" here?– Hashim
Jan 12 at 0:58
1
1
@Hashim See updated post
– slhck
Jan 12 at 11:05
@Hashim See updated post
– slhck
Jan 12 at 11:05
add a comment |
For anyone having the same problem, i finally managed to solve it with this:
ffmpeg -i input.avi -qscale 0 -ss 00:10:45 -to 00:11:45 output.avi
1
While this does solve the problem you're experiencing. it is not recommended. Here you are re-encoding the video and creating an unnecessarily large output file while doing so.
– slhck
Jun 26 '17 at 12:33
add a comment |
For anyone having the same problem, i finally managed to solve it with this:
ffmpeg -i input.avi -qscale 0 -ss 00:10:45 -to 00:11:45 output.avi
1
While this does solve the problem you're experiencing. it is not recommended. Here you are re-encoding the video and creating an unnecessarily large output file while doing so.
– slhck
Jun 26 '17 at 12:33
add a comment |
For anyone having the same problem, i finally managed to solve it with this:
ffmpeg -i input.avi -qscale 0 -ss 00:10:45 -to 00:11:45 output.avi
For anyone having the same problem, i finally managed to solve it with this:
ffmpeg -i input.avi -qscale 0 -ss 00:10:45 -to 00:11:45 output.avi
answered Jun 26 '17 at 10:42
user1584421user1584421
1014
1014
1
While this does solve the problem you're experiencing. it is not recommended. Here you are re-encoding the video and creating an unnecessarily large output file while doing so.
– slhck
Jun 26 '17 at 12:33
add a comment |
1
While this does solve the problem you're experiencing. it is not recommended. Here you are re-encoding the video and creating an unnecessarily large output file while doing so.
– slhck
Jun 26 '17 at 12:33
1
1
While this does solve the problem you're experiencing. it is not recommended. Here you are re-encoding the video and creating an unnecessarily large output file while doing so.
– slhck
Jun 26 '17 at 12:33
While this does solve the problem you're experiencing. it is not recommended. Here you are re-encoding the video and creating an unnecessarily large output file while doing so.
– slhck
Jun 26 '17 at 12:33
add a comment |
Thanks for contributing an answer to Super User!
- 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%2fsuperuser.com%2fquestions%2f1222801%2fblack-frames-at-beginning-of-video-file-when-file-cut%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
"Unfortunately this leaves some black frames in the beginning of my output video" – how are you trying to view the video? Also, please show the full, uncut command line output as well.
– slhck
Jun 26 '17 at 12:32