Previewing half-converted video file
Let's say I start an FFmpeg job that takes hours and hours:
$ ffmpeg -i large.mp4 out.mp4
Is there any way I can preview the finished part of out.mp4 while the rest is yet to be encoded?
Trying this complains "moov atom not found". If I am to speculate why, it would be because playback requires updated and correct header information to be present at the beginning of the file, and FFmpeg doesn't bother to do this while encoding files; it waits until it's completely finished.
video ffmpeg
add a comment |
Let's say I start an FFmpeg job that takes hours and hours:
$ ffmpeg -i large.mp4 out.mp4
Is there any way I can preview the finished part of out.mp4 while the rest is yet to be encoded?
Trying this complains "moov atom not found". If I am to speculate why, it would be because playback requires updated and correct header information to be present at the beginning of the file, and FFmpeg doesn't bother to do this while encoding files; it waits until it's completely finished.
video ffmpeg
Is using the MP4 container a requirement?
– dsstorefile1
Jan 13 at 13:07
@dsstorefile1: The output container is largely preferred to be MP4, since this allows for instant compatibility with portable Apple devices, plus Quicklook previewing in MacOS. I assume you are hinting to MKV, which I tried now and can confirm lets itself be instantly previewed during conversion (in VLC). But the question stands for MP4.
– forthrin
Jan 13 at 13:16
You could take a look at the tee muxer.
– llogan
Jan 14 at 19:12
@llogan: Very nice tip! Thanks! However, this forces you to play the movie throughout the entire conversion; You can't "jump in and out" of viewing it at your own prerogative.
– forthrin
Jan 14 at 20:17
add a comment |
Let's say I start an FFmpeg job that takes hours and hours:
$ ffmpeg -i large.mp4 out.mp4
Is there any way I can preview the finished part of out.mp4 while the rest is yet to be encoded?
Trying this complains "moov atom not found". If I am to speculate why, it would be because playback requires updated and correct header information to be present at the beginning of the file, and FFmpeg doesn't bother to do this while encoding files; it waits until it's completely finished.
video ffmpeg
Let's say I start an FFmpeg job that takes hours and hours:
$ ffmpeg -i large.mp4 out.mp4
Is there any way I can preview the finished part of out.mp4 while the rest is yet to be encoded?
Trying this complains "moov atom not found". If I am to speculate why, it would be because playback requires updated and correct header information to be present at the beginning of the file, and FFmpeg doesn't bother to do this while encoding files; it waits until it's completely finished.
video ffmpeg
video ffmpeg
asked Jan 13 at 12:47
forthrinforthrin
53331024
53331024
Is using the MP4 container a requirement?
– dsstorefile1
Jan 13 at 13:07
@dsstorefile1: The output container is largely preferred to be MP4, since this allows for instant compatibility with portable Apple devices, plus Quicklook previewing in MacOS. I assume you are hinting to MKV, which I tried now and can confirm lets itself be instantly previewed during conversion (in VLC). But the question stands for MP4.
– forthrin
Jan 13 at 13:16
You could take a look at the tee muxer.
– llogan
Jan 14 at 19:12
@llogan: Very nice tip! Thanks! However, this forces you to play the movie throughout the entire conversion; You can't "jump in and out" of viewing it at your own prerogative.
– forthrin
Jan 14 at 20:17
add a comment |
Is using the MP4 container a requirement?
– dsstorefile1
Jan 13 at 13:07
@dsstorefile1: The output container is largely preferred to be MP4, since this allows for instant compatibility with portable Apple devices, plus Quicklook previewing in MacOS. I assume you are hinting to MKV, which I tried now and can confirm lets itself be instantly previewed during conversion (in VLC). But the question stands for MP4.
– forthrin
Jan 13 at 13:16
You could take a look at the tee muxer.
– llogan
Jan 14 at 19:12
@llogan: Very nice tip! Thanks! However, this forces you to play the movie throughout the entire conversion; You can't "jump in and out" of viewing it at your own prerogative.
– forthrin
Jan 14 at 20:17
Is using the MP4 container a requirement?
– dsstorefile1
Jan 13 at 13:07
Is using the MP4 container a requirement?
– dsstorefile1
Jan 13 at 13:07
@dsstorefile1: The output container is largely preferred to be MP4, since this allows for instant compatibility with portable Apple devices, plus Quicklook previewing in MacOS. I assume you are hinting to MKV, which I tried now and can confirm lets itself be instantly previewed during conversion (in VLC). But the question stands for MP4.
– forthrin
Jan 13 at 13:16
@dsstorefile1: The output container is largely preferred to be MP4, since this allows for instant compatibility with portable Apple devices, plus Quicklook previewing in MacOS. I assume you are hinting to MKV, which I tried now and can confirm lets itself be instantly previewed during conversion (in VLC). But the question stands for MP4.
– forthrin
Jan 13 at 13:16
You could take a look at the tee muxer.
– llogan
Jan 14 at 19:12
You could take a look at the tee muxer.
– llogan
Jan 14 at 19:12
@llogan: Very nice tip! Thanks! However, this forces you to play the movie throughout the entire conversion; You can't "jump in and out" of viewing it at your own prerogative.
– forthrin
Jan 14 at 20:17
@llogan: Very nice tip! Thanks! However, this forces you to play the movie throughout the entire conversion; You can't "jump in and out" of viewing it at your own prerogative.
– forthrin
Jan 14 at 20:17
add a comment |
1 Answer
1
active
oldest
votes
Simply put, no. MP4 files cannot be viewed unless they're done encoding. As you correctly identified, in order to start playback, a player needs to parse the moov atom, which contains important info about what's to be played. For a description, you can have a look at the QuickTime File Format specification, which became the basis for MPEG-4 Part 14, or short, the MP4 format.
This atom can only be written once the media tracks are completely encoded. It's not that ffmpeg “doesn't bother" to write it—you just have to wait until all data is there to have all the information that is required.
The atom then gets written at the end of the container. For faster playback, you can move this atom to the beginning of the file (e.g., using qt-faststart or with the ffmpeg option -movflags +faststart). This, of course, can also only be done once encoding has finished.
That said, fragmented MP4s can be previewed up until a certain point, as Gyan suggests, by adding the following option:
-movflags +frag_keyframe+separate_moof+omit_tfhd_offset+empty_moov
What you could also do is switch over to a segmented encoding method, e.g. using the segment muxer. These create partial clips up to a predefined length, which means that you can start previewing the existing segments. You could then later join the segments back into one file with stream-copying.
Possible-ish: video.stackexchange.com/q/18177/1871
– Gyan
Jan 13 at 14:16
1
Good and well-written answer. PS! If you know the inner workings of the formats: Since incomplete MKV files play out of the box while MP4 files must be completed along with this "atom" thing, could it be considered an unnecessary and bad design decision in MP4? PPS! I would say the question is a duplicate of the indicated link, so feel free to mark it as such.
– forthrin
Jan 13 at 16:38
1
@forthrin Yes, it's not a very robust design. In fact, many times files get corrupted during recording if, for example, the camera shuts down before being able to write the moov atoms. Duplicates can only be marked on the same site, so there's not much we can do, but it's fine if the question stays here.
– slhck
Jan 13 at 18:45
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%2f1393762%2fpreviewing-half-converted-video-file%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
Simply put, no. MP4 files cannot be viewed unless they're done encoding. As you correctly identified, in order to start playback, a player needs to parse the moov atom, which contains important info about what's to be played. For a description, you can have a look at the QuickTime File Format specification, which became the basis for MPEG-4 Part 14, or short, the MP4 format.
This atom can only be written once the media tracks are completely encoded. It's not that ffmpeg “doesn't bother" to write it—you just have to wait until all data is there to have all the information that is required.
The atom then gets written at the end of the container. For faster playback, you can move this atom to the beginning of the file (e.g., using qt-faststart or with the ffmpeg option -movflags +faststart). This, of course, can also only be done once encoding has finished.
That said, fragmented MP4s can be previewed up until a certain point, as Gyan suggests, by adding the following option:
-movflags +frag_keyframe+separate_moof+omit_tfhd_offset+empty_moov
What you could also do is switch over to a segmented encoding method, e.g. using the segment muxer. These create partial clips up to a predefined length, which means that you can start previewing the existing segments. You could then later join the segments back into one file with stream-copying.
Possible-ish: video.stackexchange.com/q/18177/1871
– Gyan
Jan 13 at 14:16
1
Good and well-written answer. PS! If you know the inner workings of the formats: Since incomplete MKV files play out of the box while MP4 files must be completed along with this "atom" thing, could it be considered an unnecessary and bad design decision in MP4? PPS! I would say the question is a duplicate of the indicated link, so feel free to mark it as such.
– forthrin
Jan 13 at 16:38
1
@forthrin Yes, it's not a very robust design. In fact, many times files get corrupted during recording if, for example, the camera shuts down before being able to write the moov atoms. Duplicates can only be marked on the same site, so there's not much we can do, but it's fine if the question stays here.
– slhck
Jan 13 at 18:45
add a comment |
Simply put, no. MP4 files cannot be viewed unless they're done encoding. As you correctly identified, in order to start playback, a player needs to parse the moov atom, which contains important info about what's to be played. For a description, you can have a look at the QuickTime File Format specification, which became the basis for MPEG-4 Part 14, or short, the MP4 format.
This atom can only be written once the media tracks are completely encoded. It's not that ffmpeg “doesn't bother" to write it—you just have to wait until all data is there to have all the information that is required.
The atom then gets written at the end of the container. For faster playback, you can move this atom to the beginning of the file (e.g., using qt-faststart or with the ffmpeg option -movflags +faststart). This, of course, can also only be done once encoding has finished.
That said, fragmented MP4s can be previewed up until a certain point, as Gyan suggests, by adding the following option:
-movflags +frag_keyframe+separate_moof+omit_tfhd_offset+empty_moov
What you could also do is switch over to a segmented encoding method, e.g. using the segment muxer. These create partial clips up to a predefined length, which means that you can start previewing the existing segments. You could then later join the segments back into one file with stream-copying.
Possible-ish: video.stackexchange.com/q/18177/1871
– Gyan
Jan 13 at 14:16
1
Good and well-written answer. PS! If you know the inner workings of the formats: Since incomplete MKV files play out of the box while MP4 files must be completed along with this "atom" thing, could it be considered an unnecessary and bad design decision in MP4? PPS! I would say the question is a duplicate of the indicated link, so feel free to mark it as such.
– forthrin
Jan 13 at 16:38
1
@forthrin Yes, it's not a very robust design. In fact, many times files get corrupted during recording if, for example, the camera shuts down before being able to write the moov atoms. Duplicates can only be marked on the same site, so there's not much we can do, but it's fine if the question stays here.
– slhck
Jan 13 at 18:45
add a comment |
Simply put, no. MP4 files cannot be viewed unless they're done encoding. As you correctly identified, in order to start playback, a player needs to parse the moov atom, which contains important info about what's to be played. For a description, you can have a look at the QuickTime File Format specification, which became the basis for MPEG-4 Part 14, or short, the MP4 format.
This atom can only be written once the media tracks are completely encoded. It's not that ffmpeg “doesn't bother" to write it—you just have to wait until all data is there to have all the information that is required.
The atom then gets written at the end of the container. For faster playback, you can move this atom to the beginning of the file (e.g., using qt-faststart or with the ffmpeg option -movflags +faststart). This, of course, can also only be done once encoding has finished.
That said, fragmented MP4s can be previewed up until a certain point, as Gyan suggests, by adding the following option:
-movflags +frag_keyframe+separate_moof+omit_tfhd_offset+empty_moov
What you could also do is switch over to a segmented encoding method, e.g. using the segment muxer. These create partial clips up to a predefined length, which means that you can start previewing the existing segments. You could then later join the segments back into one file with stream-copying.
Simply put, no. MP4 files cannot be viewed unless they're done encoding. As you correctly identified, in order to start playback, a player needs to parse the moov atom, which contains important info about what's to be played. For a description, you can have a look at the QuickTime File Format specification, which became the basis for MPEG-4 Part 14, or short, the MP4 format.
This atom can only be written once the media tracks are completely encoded. It's not that ffmpeg “doesn't bother" to write it—you just have to wait until all data is there to have all the information that is required.
The atom then gets written at the end of the container. For faster playback, you can move this atom to the beginning of the file (e.g., using qt-faststart or with the ffmpeg option -movflags +faststart). This, of course, can also only be done once encoding has finished.
That said, fragmented MP4s can be previewed up until a certain point, as Gyan suggests, by adding the following option:
-movflags +frag_keyframe+separate_moof+omit_tfhd_offset+empty_moov
What you could also do is switch over to a segmented encoding method, e.g. using the segment muxer. These create partial clips up to a predefined length, which means that you can start previewing the existing segments. You could then later join the segments back into one file with stream-copying.
edited Jan 13 at 14:32
answered Jan 13 at 13:35
slhckslhck
160k47444466
160k47444466
Possible-ish: video.stackexchange.com/q/18177/1871
– Gyan
Jan 13 at 14:16
1
Good and well-written answer. PS! If you know the inner workings of the formats: Since incomplete MKV files play out of the box while MP4 files must be completed along with this "atom" thing, could it be considered an unnecessary and bad design decision in MP4? PPS! I would say the question is a duplicate of the indicated link, so feel free to mark it as such.
– forthrin
Jan 13 at 16:38
1
@forthrin Yes, it's not a very robust design. In fact, many times files get corrupted during recording if, for example, the camera shuts down before being able to write the moov atoms. Duplicates can only be marked on the same site, so there's not much we can do, but it's fine if the question stays here.
– slhck
Jan 13 at 18:45
add a comment |
Possible-ish: video.stackexchange.com/q/18177/1871
– Gyan
Jan 13 at 14:16
1
Good and well-written answer. PS! If you know the inner workings of the formats: Since incomplete MKV files play out of the box while MP4 files must be completed along with this "atom" thing, could it be considered an unnecessary and bad design decision in MP4? PPS! I would say the question is a duplicate of the indicated link, so feel free to mark it as such.
– forthrin
Jan 13 at 16:38
1
@forthrin Yes, it's not a very robust design. In fact, many times files get corrupted during recording if, for example, the camera shuts down before being able to write the moov atoms. Duplicates can only be marked on the same site, so there's not much we can do, but it's fine if the question stays here.
– slhck
Jan 13 at 18:45
Possible-ish: video.stackexchange.com/q/18177/1871
– Gyan
Jan 13 at 14:16
Possible-ish: video.stackexchange.com/q/18177/1871
– Gyan
Jan 13 at 14:16
1
1
Good and well-written answer. PS! If you know the inner workings of the formats: Since incomplete MKV files play out of the box while MP4 files must be completed along with this "atom" thing, could it be considered an unnecessary and bad design decision in MP4? PPS! I would say the question is a duplicate of the indicated link, so feel free to mark it as such.
– forthrin
Jan 13 at 16:38
Good and well-written answer. PS! If you know the inner workings of the formats: Since incomplete MKV files play out of the box while MP4 files must be completed along with this "atom" thing, could it be considered an unnecessary and bad design decision in MP4? PPS! I would say the question is a duplicate of the indicated link, so feel free to mark it as such.
– forthrin
Jan 13 at 16:38
1
1
@forthrin Yes, it's not a very robust design. In fact, many times files get corrupted during recording if, for example, the camera shuts down before being able to write the moov atoms. Duplicates can only be marked on the same site, so there's not much we can do, but it's fine if the question stays here.
– slhck
Jan 13 at 18:45
@forthrin Yes, it's not a very robust design. In fact, many times files get corrupted during recording if, for example, the camera shuts down before being able to write the moov atoms. Duplicates can only be marked on the same site, so there's not much we can do, but it's fine if the question stays here.
– slhck
Jan 13 at 18:45
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%2f1393762%2fpreviewing-half-converted-video-file%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
Is using the MP4 container a requirement?
– dsstorefile1
Jan 13 at 13:07
@dsstorefile1: The output container is largely preferred to be MP4, since this allows for instant compatibility with portable Apple devices, plus Quicklook previewing in MacOS. I assume you are hinting to MKV, which I tried now and can confirm lets itself be instantly previewed during conversion (in VLC). But the question stands for MP4.
– forthrin
Jan 13 at 13:16
You could take a look at the tee muxer.
– llogan
Jan 14 at 19:12
@llogan: Very nice tip! Thanks! However, this forces you to play the movie throughout the entire conversion; You can't "jump in and out" of viewing it at your own prerogative.
– forthrin
Jan 14 at 20:17