user24169: I want to create one thumbnail consisting of the first frame of a video for arbitrary video files. I do it like this:
ffmpeg -i video.mkv -vf scale=w=300:h=300:force_original_aspect_ratio=decrease -frames:v 1 thumbnail.png

For performance considerations I was experimenting with only loading the first megabytes of a video instead of whole video files for this task.
In my experiments this works fine with some formats like mkv and mts and only sometimes with mp4 (I get errors - and no thumbnail, when the moov atom is not at the beginning of a file)
With what video file formats is it possible to generate thumbnails only from the first megabytes of a file, and with what formats is it not possible? Does it only depend on the container type or also on the codec? Can there be a reliable answer?

user32871: 
Can there be a reliable answer?

No.
As with almost everything is video. The real answer is: It depends.
With mp4, the moov must be at the beginning, AND the mdat must properly interleave tracks. For example, If the there more than one megabyte of audio before the video, Then it won't work even with the moov at the start.
For TS, there must be a SPS, a PPS and and IDR in the first megabyte. That is probable, but not guaranteed.
For Mkv Interleaving matters.
The codec, codec configuration, and even bitrate will also matter.
If the first keyframe is over 1Mb, no container will work.
If the codec is using periodic inter fresh, it would probably take more that 1Mb, unless the video bitrate is very low.
Writing all the permutations would take a book.

24169: <p>I want to create one thumbnail consisting of the first frame of a video for arbitrary video files. I do it like this:</p>
<pre><code>ffmpeg -i video.mkv -vf scale=w=300:h=300:force_original_aspect_ratio=decrease -frames:v 1 thumbnail.png
</code></pre>
<p>For performance considerations I was experimenting with only loading the first megabytes of a video instead of whole video files for this task.</p>
<p>In my experiments this works fine with some formats like <code>mkv</code> and <code>mts</code> and only sometimes with <code>mp4</code> (I get errors - and no thumbnail, when the <code>moov atom</code> is not at the beginning of a file)</p>
<p>With what video file formats is it possible to generate thumbnails only from the first megabytes of a file, and with what formats is it not possible? Does it only depend on the container type or also on the codec? Can there be a reliable answer?</p>
 32871: <blockquote>
<p>Can there be a reliable answer?</p>
</blockquote>
<p>No.</p>
<p>As with almost everything is video. The real answer is: It depends.</p>
<p>With mp4, the moov must be at the beginning, AND the mdat must properly interleave tracks. For example, If the there more than one megabyte of audio before the video, Then it won't work even with the moov at the start.</p>
<p>For TS, there must be a SPS, a PPS and and IDR in the first megabyte. That is probable, but not guaranteed.</p>
<p>For Mkv Interleaving matters.</p>
<p>The codec, codec configuration, and even bitrate will also matter.
If the first keyframe is over 1Mb, no container will work.</p>
<p>If the codec is using periodic inter fresh, it would probably take more that 1Mb, unless the video bitrate is very low.</p>
<p>Writing all the permutations would take a book.</p>
