<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Arturo Didonna on Medium]]></title>
        <description><![CDATA[Stories by Arturo Didonna on Medium]]></description>
        <link>https://medium.com/@arturo.didonna?source=rss-9331a5af6100------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*mXXa51Cf_wf_uTiX.jpg</url>
            <title>Stories by Arturo Didonna on Medium</title>
            <link>https://medium.com/@arturo.didonna?source=rss-9331a5af6100------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 19:28:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@arturo.didonna/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[VLC says “Broken or missing Index”? What a cut-off AVI looks like inside, and the free fix]]></title>
            <link>https://medium.com/@arturo.didonna/vlc-says-broken-or-missing-index-what-a-cut-off-avi-looks-like-inside-and-the-free-fix-225ec738d6f5?source=rss-9331a5af6100------2</link>
            <guid isPermaLink="false">https://medium.com/p/225ec738d6f5</guid>
            <category><![CDATA[video-production]]></category>
            <category><![CDATA[dashcam]]></category>
            <category><![CDATA[data-recovery]]></category>
            <category><![CDATA[ffmpeg]]></category>
            <category><![CDATA[video-editing]]></category>
            <dc:creator><![CDATA[Arturo Didonna]]></dc:creator>
            <pubDate>Tue, 01 Dec 2026 10:52:23 GMT</pubDate>
            <atom:updated>2026-12-01T10:52:23.727Z</atom:updated>
            <content:encoded><![CDATA[<h4>A Motion JPEG recording interrupted on purpose: what the recorder never got to write, what players make of it, and one FFmpeg command that writes a new index.</h4><p><em>This story was written with the assistance of an AI writing program. Every command and output below comes from test files made for this article, run with FFmpeg 4.4.2, mpv 0.34.1 and VLC 3.0.24 on Linux.</em></p><p>Many older compact cameras and budget dashcams record AVI files with Motion JPEG video. If the battery dies, the card is pulled out or the camera freezes during a recording, the file stays on the card with a normal-looking size, but VLC warns that its index is “broken or missing” and that seeking will not work correctly, and other players may show a wrong length. To see exactly what is missing, and what can be done about it for free, a recording was cut off on purpose.</p><h3>The test</h3><p>FFmpeg recorded a 1280×720, 30 fps test pattern with a tone in real time, as Motion JPEG video with uncompressed 16-bit PCM audio (mono, 16 kHz) in an AVI file. Two copies ran side by side. One stopped normally after 20 seconds; the other was killed with kill -9 after 20 seconds, which gives it no chance to finish the file, just like a power cut.</p><pre>ffmpeg -re -f lavfi -i testsrc2=size=1280x720:rate=30 -f lavfi -i sine=frequency=440:sample_rate=16000 -c:v mjpeg -q:v 4 -pix_fmt yuvj420p -c:a pcm_s16le -ac 1 rec_cut.avi</pre><p>The finished file is 32,726,090 bytes, the interrupted one 31,719,424. A camera uses its own recording code, not FFmpeg’s, so some details can differ (one is noted below), but the file format is the same.</p><h3>What an AVI writes last</h3><p>An AVI file is a sequence of labelled blocks. A header block (hdrl) describes the streams; a movi block holds the video frames and audio chunks one after another; at the end comes idx1, the index, with one 16-byte entry per chunk saying where it is. The total size, the number of frames and the length of each stream are only known when the recording stops, so they are filled in at the end, together with the index. A short Python script (at the end of this article) prints those fields:</p><pre>$ python3 aviwalk.py rec_ok.avi rec_cut.avi<br>== rec_ok.avi<br>file size          : 32,726,090 bytes<br>RIFF &#39;AVI &#39;        : declared size 32,726,082<br>  avih             : total frames 600, flags 0x910 (HASINDEX=yes)<br>  strh &#39;vids&#39;      : length 600 (scale 1, rate 30)<br>  strh &#39;auds&#39;      : length 320000 (scale 1, rate 16000)<br>  LIST &#39;INFO&#39;      : declared size 26<br>  JUNK             : 1,016 bytes<br>  LIST &#39;movi&#39;      : declared size 32,701,496<br>  idx1 (index)     : 913 entries<br>== rec_cut.avi<br>file size          : 31,719,424 bytes<br>RIFF &#39;AVI &#39;        : declared size 4,294,967,295<br>  avih             : total frames 0, flags 0x910 (HASINDEX=yes)<br>  strh &#39;vids&#39;      : length 0 (scale 1, rate 30)<br>  strh &#39;auds&#39;      : length 0 (scale 1, rate 16000)<br>  LIST &#39;INFO&#39;      : declared size 26<br>  JUNK             : 1,016 bytes<br>  LIST &#39;movi&#39;      : declared size 4,294,967,295</pre><p>The interrupted file has no index at all. Its frame count and stream lengths are 0, and its two sizes are 4,294,967,295 (hex FFFFFFFF), the placeholder FFmpeg writes when it starts a file. The header still says it has an index. Some recorders leave zeros there instead: a copy with both sizes set to 0 gave a byte-for-byte identical result with the fix below.</p><h3>What players make of it</h3><pre>$ ffprobe -v error -show_entries format=duration -of default=nw=1 rec_cut.avi<br>duration=N/A<br> <br>$ ffprobe -v warning -count_packets -show_entries stream=codec_type,nb_read_packets -of csv=p=0 rec_cut.avi<br>[avi @ 0x...] Packet corrupt (stream = 0, dts = 582).<br>video,583<br>audio,304</pre><p>The length is unknown, yet 583 video frames and 304 audio chunks can be read: 19.4 of the 20 seconds. FFmpeg doesn’t need the index for that; it reads the chunks one after another. Only the last frame is damaged, because it was cut in half when the process died.</p><p>Players have to guess. mpv reported a length of 1.088 seconds for this file, yet it could jump to 15 seconds and it played to 19.37 seconds. VLC logged cannot find idx1 chunk, no index defined. That is the situation its “Broken or missing Index” question is about, and the question is honest about its limits: “VLC won&#39;t repair your file but can temporary fix this problem by building an index in memory.” The file on disk stays as it is, so the next player, phone, TV or editor gets the same broken file.</p><h3>The free fix: copy the streams into a new AVI</h3><pre>$ ffmpeg -hide_banner -v warning -fflags +discardcorrupt -i rec_cut.avi -c copy fixed.avi<br>Guessed Channel Layout for Input Stream #0.1 : mono<br>[avi @ 0x...] Packet corrupt (stream = 0, dts = 582), dropping it.</pre><p>-c copy copies every JPEG frame and every audio chunk unchanged, with no re-encoding and no loss of quality, and FFmpeg’s AVI writer fills in the sizes, the counts and a new index when it finishes. -fflags +discardcorrupt drops the last, half-written frame. Without it the copy keeps that frame (583 frames), and decoding the result reports overread 8 at the end.</p><pre>$ python3 aviwalk.py fixed.avi<br>== fixed.avi<br>file size          : 31,724,708 bytes<br>RIFF &#39;AVI &#39;        : declared size 31,724,700<br>  avih             : total frames 582, flags 0x910 (HASINDEX=yes)<br>  strh &#39;vids&#39;      : length 582 (scale 1, rate 30)<br>  strh &#39;auds&#39;      : length 311296 (scale 1, rate 16000)<br>  LIST &#39;INFO&#39;      : declared size 26<br>  JUNK             : 1,016 bytes<br>  LIST &#39;movi&#39;      : declared size 31,700,546<br>  idx1 (index)     : 886 entries<br> <br>$ ffprobe -v error -show_entries format=duration -of default=nw=1 fixed.avi<br>duration=19.400000<br> <br>$ ffmpeg -hide_banner -v error -i fixed.avi -f null -</pre><p>582 frames, 19.4 seconds, an index with 886 entries, and the last command, which decodes every frame, printed nothing: not a single error. mpv now reports 19.4 seconds as well.</p><h3>Over 1 GB: the length is wrong rather than missing</h3><p>Recordings larger than about 1 GB use the AVI 2.0 (OpenDML) extension. In a second test, a 1920×1080 recording at higher quality was killed once it passed 1.4 GB. FFmpeg had finished the first part of the file (declared size 1,074,055,740 bytes) and carried on in a new section called AVIX:</p><pre>$ python3 aviwalk.py big_cut.avi<br>== big_cut.avi<br>file size          : 1,401,735,748 bytes<br>RIFF &#39;AVI &#39;        : declared size 1,074,055,740<br>  avih             : total frames 8584, flags 0x910 (HASINDEX=yes)<br>  strh &#39;vids&#39;      : length 8584 (scale 1, rate 30)<br>  indx (super index): 1 entries in use<br>  strh &#39;auds&#39;      : length 4578304 (scale 1, rate 16000)<br>  indx (super index): 1 entries in use<br>  LIST &#39;INFO&#39;      : declared size 26<br>  JUNK             : 1,016 bytes<br>  LIST &#39;movi&#39;      : declared size 1,073,836,898<br>  idx1 (index)     : 13,054 entries<br>RIFF &#39;AVIX&#39;        : declared size 4,294,967,295<br>  LIST &#39;movi&#39;      : declared size 4,294,967,295</pre><p>The first part was finished properly, with its own index and a frame count of 8,584. The second part has no index and placeholder sizes. So this file doesn’t look empty; it looks shorter. ffprobe and mpv both reported 286.13 seconds (4:46), while 11,201 frames, 373.4 seconds (6:13), can be read. The last 87 seconds seem to be missing until you play or seek past 4:46 (mpv could jump to 350 seconds).</p><p>The same -c copy command gave a file of 373.37 seconds with all 11,201 frames, an index for each part, the real size of the AVIX section, and the total for the whole file in the AVI 2.0 header (dmlh: 11,201 frames). Decoding it from start to finish reported no errors.</p><h3>Damage in the middle: five frames lost, one damaged silently</h3><p>A flaky card or a bad copy can also leave a hole inside a file. 256 KB of zeros were written into a copy of the interrupted recording at byte 15,000,000:</p><pre>$ ffprobe -v warning -count_packets -show_entries stream=codec_type,nb_read_packets -of csv=p=0 hole.avi<br>[avi @ 0x...] Packet corrupt (stream = 0, dts = 577).<br>video,578<br>audio,301</pre><p>The five frames that started inside the hole (frames 275 to 279) and three audio chunks were gone. In Motion JPEG every frame is a complete picture, so the loss stops there: reading resumed with the next intact chunk. The repaired copy has 577 frames and 19.23 seconds, and decoding it reports no errors.</p><p>Two details are worth knowing. First, frame 274 started before the hole and ended inside it. It decoded without any error message, but the lower third of the picture was a flat pink area. A clean decode doesn’t prove that every frame looks right, so look at the spot where frames went missing. Second, an AVI doesn’t store a time for each frame: a frame’s time is its position in the stream. After the hole everything moves earlier, the video by 5 frames (0.167 s) and the sound by 3 chunks of 1,024 samples (0.192 s), so in this test picture and sound ended up 25 milliseconds apart.</p><p>The same hole in the complete recording, which still had its index, cost the same: 595 of 600 frames and 310 of 313 audio chunks were left. An index says where the chunks were; it can’t bring back what was overwritten.</p><h3>When a new index isn’t enough</h3><ul><li><strong>The start of the file is damaged.</strong> The header describes the streams. With its first 12,000 bytes overwritten with zeros, the test file was rejected: Invalid data found when processing input.</li><li><strong>The file is 0 KB, all zeros or full of another file’s data</strong>, which can happen after a failed recovery. There is nothing to index.</li><li><strong>The video isn’t Motion JPEG.</strong> Xvid, DivX and H.264 store most frames as changes from earlier ones, so damage in the middle can spoil the frames that follow until the next keyframe. Those codecs weren’t part of this test.</li></ul><h3>Before you start</h3><p>Copy the file from the card to your computer and work on the copy. Don’t keep recording on the same card if other clips may need recovery, and don’t let a converter overwrite the original.</p><h3>The script</h3><p>It only reads the file and prints the fields shown above. It doesn’t handle every AVI variant; it’s a quick look at what a recorder left behind.</p><pre>#!/usr/bin/env python3<br>&quot;&quot;&quot;Print the fields of an AVI file that are filled in only when the recording stops.&quot;&quot;&quot;<br>import struct<br>import sys<br> <br> <br>def chunks(f, start, end):<br>    &quot;&quot;&quot;Yield (fourcc, declared_size, data_offset) for the chunks between start and end.&quot;&quot;&quot;<br>    pos = start<br>    while pos + 8 &lt;= end:<br>        f.seek(pos)<br>        hdr = f.read(8)<br>        if len(hdr) &lt; 8:<br>            return<br>        fourcc, size = hdr[:4].decode(&quot;latin-1&quot;), struct.unpack(&quot;&lt;I&quot;, hdr[4:])[0]<br>        yield fourcc, size, pos + 8<br>        if size == 0:          # size never written: we cannot know where the chunk ends<br>            return<br>        pos += 8 + size + (size &amp; 1)<br> <br> <br>def main(path):<br>    with open(path, &quot;rb&quot;) as f:<br>        f.seek(0, 2)<br>        filesize = f.tell()<br>        print(f&quot;file size          : {filesize:,} bytes&quot;)<br>        for fourcc, size, off in chunks(f, 0, filesize):<br>            f.seek(off)<br>            form = f.read(4).decode(&quot;latin-1&quot;)<br>            print(f&quot;{fourcc} &#39;{form}&#39;        : declared size {size:,}&quot;)<br>            if fourcc != &quot;RIFF&quot;:<br>                continue<br>            for c, s, o in chunks(f, off + 4, min(off + size, filesize) if size else filesize):<br>                f.seek(o)<br>                if c == &quot;LIST&quot;:<br>                    kind = f.read(4).decode(&quot;latin-1&quot;)<br>                    if kind == &quot;hdrl&quot;:<br>                        hdrl(f, o + 4, o + s)<br>                    elif kind == &quot;movi&quot;:<br>                        print(f&quot;  LIST &#39;movi&#39;      : declared size {s:,}&quot;)<br>                    else:<br>                        print(f&quot;  LIST &#39;{kind}&#39;      : declared size {s:,}&quot;)<br>                elif c == &quot;idx1&quot;:<br>                    print(f&quot;  idx1 (index)     : {s // 16:,} entries&quot;)<br>                else:<br>                    print(f&quot;  {c}             : {s:,} bytes&quot;)<br> <br> <br>def hdrl(f, start, end):<br>    for c, s, o in chunks(f, start, end):<br>        f.seek(o)<br>        if c == &quot;avih&quot;:<br>            v = struct.unpack(&quot;&lt;10I&quot;, f.read(40))<br>            print(f&quot;  avih             : total frames {v[4]}, flags 0x{v[3]:x} (HASINDEX={&#39;yes&#39; if v[3] &amp; 0x10 else &#39;no&#39;})&quot;)<br>        elif c == &quot;LIST&quot;:<br>            kind = f.read(4).decode(&quot;latin-1&quot;)<br>            if kind in (&quot;strl&quot;, &quot;odml&quot;):<br>                hdrl(f, o + 4, o + s)<br>        elif c == &quot;strh&quot;:<br>            d = f.read(48)<br>            kind = d[:4].decode(&quot;latin-1&quot;)<br>            scale, rate, _start, length = struct.unpack(&quot;&lt;4I&quot;, d[20:36])<br>            print(f&quot;  strh &#39;{kind}&#39;      : length {length} (scale {scale}, rate {rate})&quot;)<br>        elif c == &quot;dmlh&quot;:<br>            print(f&quot;  dmlh (OpenDML)   : total frames {struct.unpack(&#39;&lt;I&#39;, f.read(4))[0]}&quot;)<br>        elif c == &quot;indx&quot;:<br>            d = f.read(24)<br>            used = struct.unpack(&quot;&lt;I&quot;, d[4:8])[0]<br>            print(f&quot;  indx (super index): {used} entries in use&quot;)<br> <br> <br>if __name__ == &quot;__main__&quot;:<br>    for p in sys.argv[1:]:<br>        print(f&quot;== {p}&quot;)<br>        main(p)</pre><p><em>Disclosure: I built FrameRescue, an online service that rebuilds AVI files for people who would rather not use the command line. For Motion JPEG AVIs, including files over 1 GB, it writes a new AVI with every frame copied unchanged and a new index; it also handles Xvid and DivX AVIs under 1 GB. Each result is decoded before it is offered. Uploading and the preview are free; downloading a repaired file costs €5. Guide: </em><a href="https://framerescue.com/repair-avi-file/"><em>https://framerescue.com/repair-avi-file/</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=225ec738d6f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Check an SD card for broken videos with one script]]></title>
            <link>https://medium.com/@arturo.didonna/check-an-sd-card-for-broken-videos-with-one-script-2e3958a13f92?source=rss-9331a5af6100------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e3958a13f92</guid>
            <category><![CDATA[bash]]></category>
            <category><![CDATA[data-recovery]]></category>
            <category><![CDATA[video-editing]]></category>
            <category><![CDATA[ffmpeg]]></category>
            <dc:creator><![CDATA[Arturo Didonna]]></dc:creator>
            <pubDate>Sat, 28 Nov 2026 09:42:18 GMT</pubDate>
            <atom:updated>2026-11-28T14:19:41.190Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RP8-SnG-PVDDEjQm" /></figure><p><em>This article was written with the help of an AI assistant. Every command and every output below comes from a test I ran on 28 November 2026 with FFmpeg 4.4.2 on Linux, using synthetic clips made for this article.</em></p><p>Update, 28 November: Jason F pointed out in the responses that an MP4 with its index at the front (written with -movflags +faststart, as many phone apps and editors do) that was cut short came out as DAMAGED INSIDE. The script now has a sixth result, TRUNCATED, based on the “partial file” error and on the frames the index promises vs the frames that decode. The updated script and test results are in the original post: https://brokenvideonotes.hashnode.dev/check-a-whole-sd-card-for-broken-videos-with-one-script-and-what-each-result-means</p><p>After a shoot where something went wrong (a battery died, a card was pulled out, a drone lost power) you usually have dozens of clips and no idea which ones are damaged. Opening them one by one in a player is slow and misleading: some players skip errors silently, others refuse a file that is mostly fine.</p><p>Here is a small script that decodes every clip in a folder and sorts it into one of five states, plus what to do for each.</p><h3>Why ffprobe alone is not enough</h3><p>ffprobe reads the container header. That catches a file with no index, but not a file whose header is fine and whose data is broken. In my test, a 20-second clip with 200,000 random bytes written into the middle still reported a perfect duration:</p><pre>$ ffprobe -v error -show_entries format=duration -of csv=p=0 VID_0004.MP4 20.000000</pre><p>Only decoding the whole file reveals the problem:</p><pre>$ ffmpeg -nostdin -v error -i VID_0004.MP4 -f null - [aac @ 0x63c4b4cd4180] Reserved bit set. [aac @ 0x63c4b4cd4180] Prediction is not allowed in AAC-LC. Error while decoding stream #0:1: Invalid data found when processing input [h264 @ 0x63c4b4db5440] Invalid NAL unit size (-1113147752 &gt; 9301). ...</pre><p>So the script does both: ffprobe for the duration, then a full decode to a null output (-f null -), counting the error lines.</p><pre>#!/usr/bin/env bash # checkcard.sh: decode every video in a folder and report which ones are damaged. # Usage: ./checkcard.sh /path/to/DCIM shopt -s nullglob nocaseglob dir=&quot;${1:-.}&quot; for f in &quot;$dir&quot;/*.{mp4,mov,mkv,ts,mts,avi}; do size=$(stat -c%s &quot;$f&quot;) if [ &quot;$size&quot; -eq 0 ]; then printf &#39;%-14s EMPTY (0 bytes)\n&#39; &quot;$(basename &quot;$f&quot;)&quot;; continue fi dur=$(ffprobe -v error -show_entries format=duration -of csv=p=0 &quot;$f&quot; 2&gt;/dev/null) errs=$(ffmpeg -nostdin -v error -i &quot;$f&quot; -f null - 2&gt;&amp;1) n=$(printf &#39;%s&#39; &quot;$errs&quot; | grep -c .) if printf &#39;%s&#39; &quot;$errs&quot; | grep -q &#39;moov atom not found&#39;; then status=&quot;NO INDEX (moov atom not found)&quot; elif [ -z &quot;$dur&quot; ] || [ &quot;$dur&quot; = &quot;N/A&quot; ]; then status=&quot;NO DURATION ($n error lines)&quot; elif [ &quot;$n&quot; -gt 0 ]; then status=&quot;DAMAGED INSIDE ($n error lines, header says ${dur%.*}s)&quot; else status=&quot;OK (${dur%.*}s)&quot; fi printf &#39;%-14s %s\n&#39; &quot;$(basename &quot;$f&quot;)&quot; &quot;$status&quot; done</pre><p>Run it on a <strong>copy</strong> of the card, never on the card itself. -nostdin stops FFmpeg from eating the loop&#39;s input, and nocaseglob catches both .MP4 and .mp4. On macOS, replace stat -c%s with stat -f%z.</p><p>I made seven clips (1280×720, 30 fps, H.264 + AAC) and damaged them in the ways real cards get damaged:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kbtVmN0OGIgbfU_E" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VUxl67l3rj8D4YOX" /></figure><p>VID_0001, VID_0002</p><p>healthy, 20 s each</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_bfvF2f4yRoOAP4A" /></figure><p>VID_0003</p><p>healthy 20 s clip cut at 60% of its bytes (the index at the end is lost, like a battery dying)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9MMubGrlD-DscP1a" /></figure><p>VID_0004</p><p>healthy clip with 200,000 random bytes written in the middle</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*B8Sy-xlBGhCjzsTP" /></figure><p>VID_0006.mkv</p><p>MKV recording killed with kill -9 after 8 seconds (like OBS crashing)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PXSRW63fG97i_fK7" /></figure><p>VID_0007</p><p>MP4 recording killed with kill -9 after 8 seconds</p><p>The result, in 2.5 seconds for all seven files:</p><pre>$ ./checkcard.sh card VID_0001.MP4 OK (20s) VID_0002.MP4 OK (20s) VID_0003.MP4 NO INDEX (moov atom not found) VID_0004.MP4 DAMAGED INSIDE (106 error lines, header says 20s) VID_0005.MP4 EMPTY (0 bytes) VID_0007.MP4 NO INDEX (moov atom not found) VID_0006.mkv NO DURATION (2 error lines)</pre><p>Decoding is the slow part: the time grows with resolution and clip length, so a full card of 4K footage takes much longer than this test.</p><p><strong>OK.</strong> Nothing to do. If the clip still doesn’t play on your phone or TV, it’s a codec support problem (often HEVC), not damage.</p><p><strong>EMPTY (0 bytes).</strong> The camera created the file but never wrote data to it. There is nothing inside to repair. If the card was formatted or the file deleted, a file-carving tool such as PhotoRec run on a full image of the card is the only chance.</p><p><strong>NO DURATION (MKV).</strong> Typical of OBS and other recorders that crash: the data is there, but the duration and the index (Cues) are written only when recording stops. A plain remux usually fixes it:</p><pre>$ ffmpeg -i VID_0006.mkv -c copy VID_0006_remux.mkv [matroska,webm @ 0x56bd372e2240] File ended prematurely $ ffprobe -v error -show_entries format=duration -of csv=p=0 VID_0006_remux.mkv 5.921000</pre><p>The remuxed file has a duration and decodes without errors. Of the 8 seconds the recorder ran, 5.9 s were on disk when it was killed: the rest was still in memory buffers. That loss is normal and no tool can bring it back.</p><p><strong>NO INDEX (moov atom not found).</strong> The most common case after a dead battery or a pulled card. MP4 and MOV keep their index (the moov box) at the end of the file, written when you press stop. Without it no player knows where the frames are, even though they are all there. The free tool for this is <a href="https://github.com/anthwlock/untrunc">untrunc</a>, which rebuilds the index using a healthy clip recorded with <strong>the same camera and the same settings</strong> as a reference:</p><pre>$ untrunc -s VID_0001.MP4 VID_0003.MP4 ... Warning: Bytes NOT matched: 25.3KiB (0.5818%) Info: saving VID_0003.MP4_fixed-s1.MP4 $ ffprobe -v error -show_entries format=duration -of csv=p=0 VID_0003.MP4_fixed-s1.MP4 12.000000</pre><p>The cut file had 60% of its bytes, and untrunc got 12 of the 20 seconds back. The killed MP4 recording (VID_0007) came back with 6.5 seconds. The reference matters: shoot a few seconds with the same device, resolution, frame rate and codec before you try.</p><p><strong>DAMAGED INSIDE.</strong> The header is fine but part of the data is not. First copy the file from the card again: a bad card reader or a USB hiccup during the copy can cause this. If the damage is really in the file, you can cut the broken section out with a lossless cutter such as LosslessCut, or re-encode the clip. Re-encoding my damaged test clip ( ffmpeg -i VID_0004.MP4 -c:v libx264 -c:a aac VID_0004_reenc.mp4) gave a 20-second file that decodes with zero errors. Expect a glitch or a jump where the damage was.</p><ul><li>Copy the whole card before doing anything else, and work on the copy.</li><li>Don’t record until the battery dies: the clip in progress is the one that loses its index.</li><li>After a crash, record a short healthy clip with the same settings right away. It’s the reference that repair tools need.</li><li>Format the card in the camera, not on the computer.</li></ul><p><em>Disclosure: I built </em><a href="https://framerescue.com/fix-video-0-seconds/"><em>FrameRescue</em></a><em>, an online tool that rebuilds the index of MP4, MOV and MKV files cut off by a dead battery or a crash. The check and preview are free and downloading a repaired file costs €5. The free steps above are worth trying first.</em></p><p><em>Originally published at </em><a href="https://brokenvideonotes.hashnode.dev/check-a-whole-sd-card-for-broken-videos-with-one-script-and-what-each-result-means"><em>https://brokenvideonotes.hashnode.dev</em></a><em> on November 28, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e3958a13f92" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OBS crashed in the middle of a recording? Here’s what is left in the MKV, and how to get it back]]></title>
            <link>https://medium.com/@arturo.didonna/obs-crashed-in-the-middle-of-a-recording-heres-what-is-left-in-the-mkv-and-how-to-get-it-back-8a6dc668b8d6?source=rss-9331a5af6100------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a6dc668b8d6</guid>
            <category><![CDATA[ffmpeg]]></category>
            <category><![CDATA[live-streaming]]></category>
            <category><![CDATA[video-editing]]></category>
            <category><![CDATA[obs-studio]]></category>
            <dc:creator><![CDATA[Arturo Didonna]]></dc:creator>
            <pubDate>Fri, 27 Nov 2026 17:02:52 GMT</pubDate>
            <atom:updated>2026-11-28T14:30:27.608Z</atom:updated>
            <content:encoded><![CDATA[<h4>A test recording killed on purpose: what survives, what a crash really breaks, and the free fix that works most of the time.</h4><p><em>This story was written with the assistance of an AI writing program. The commands and outputs below were run on test files made for this article, with FFmpeg 4.4.2.</em></p><p>OBS Studio’s own advice is to record to MKV, because an MKV “will not corrupt the whole file” if the recording doesn’t stop properly. That’s reassuring, but what does it mean in practice when OBS freezes, the PC shuts down or the disk fills up? The file is there, it has a normal size, and yet players show the wrong length, editors refuse it, or seeking doesn’t work. To see exactly what a crash leaves behind, a recording was interrupted on purpose.</p><h3>The test</h3><p>FFmpeg recorded a 720p, 30 fps test pattern with a tone in real time, using the same kind of settings as a typical OBS recording: x264 at 6 Mbps with a keyframe every 2 seconds, and AAC audio. Two copies ran side by side, one writing an MKV and one writing a standard MP4. After 25 seconds both processes were killed with kill -9, which gives them no chance to finish the file, just like a crash or a power cut.</p><pre>ffmpeg -re -f lavfi -i testsrc2=size=1280x720:rate=30 -f lavfi -i sine=frequency=440:sample_rate=48000 -c:v libx264 -preset veryfast -g 60 -pix_fmt yuv420p -b:v 6M -c:a aac -b:a 160k rec.mkv</pre><p>Both files ended up at about 18 MB (18,087,936 bytes for the MKV, 18,087,984 for the MP4).</p><h3>The MP4: all the video, no way in</h3><pre>$ ffprobe rec.mp4<br>[mov,mp4,m4a,3gp,3g2,mj2 @ 0x...] moov atom not found<br>rec.mp4: Invalid data found when processing input</pre><p>A standard MP4 writes its index, the moov atom, only when the recording stops. Without it nothing can find the frames, so the 18 MB of video are unreadable, and a simple copy with ffmpeg -i rec.mp4 -c copy fails with the same error. Getting this back means rebuilding the index from scratch, which is a different and much harder job (more on that at the end).</p><p>Update, 28 November: in the responses, Jason F added that people who record with plain FFmpeg can protect an MP4 in a similar way with -movflags frag_keyframe+empty_moov, which writes the index in small pieces at every keyframe instead of once at the end. I tried it: a recording made that way and killed with kill -9 after 6 seconds still opened, and ffmpeg -i rec.mp4 -c copy gave a playable 1.7-second file, while the same recording as a plain MP4 did not open at all. You still lose the piece that was being written, much like the last MKV cluster below.</p><h3>The MKV: nearly everything is still readable</h3><pre>$ ffprobe -v error -show_entries format=duration,size -of default=nw=1 rec.mkv<br>duration=N/A<br>size=18087936</pre><pre>$ ffprobe -v error -count_packets -show_entries stream=codec_type,nb_read_packets -of csv=p=0 rec.mkv<br>[matroska,webm @ 0x...] File ended prematurely<br>video,711<br>audio,1109</pre><p>The file has no duration and ends abruptly, but 711 video frames and 1,109 audio packets can be read: 23.7 seconds of the 25 that were recorded. Only the last second or so, which was still being prepared in memory when the process died, never reached the disk.</p><p>The reason is the way Matroska is written. The video and audio go into the file as a sequence of self-contained blocks called clusters (12 of them here, one every 2 seconds, starting at each keyframe). The parts that describe the whole file are filled in at the end:</p><ul><li><strong>Segment size:</strong> written as “unknown” at the start (the bytes 01 ff ff ff ff ff ff ff) and normally replaced with the real size when recording stops.</li><li><strong>Duration:</strong> missing from the header of the interrupted file.</li><li><strong>Cues:</strong> the index that lets a player jump to any point, written at the end. The interrupted file has none.</li></ul><h3>What that looks like in a player</h3><p>Players have to guess. mpv played the interrupted file and could seek to 20 seconds, but it reported a length of 21 seconds for a recording that is really 23.8 seconds long. Other players show 0:00 or a progress bar that doesn’t work, and some editors refuse to import a file without a duration and index. None of that means the footage is gone.</p><h3>The free fix: rewrite the file</h3><p>Copying the streams into a new file, without re-encoding, makes the muxer write everything that was missing:</p><pre>$ ffmpeg -v error -i rec.mkv -c copy fixed.mkv<br>[matroska,webm @ 0x...] File ended prematurely</pre><pre>$ ffprobe -v error -show_entries format=duration -of default=nw=1 fixed.mkv<br>duration=23.787000</pre><p>The new file has a real duration, a known segment size and an index, and it contains the same 711 video frames and 1,109 audio packets. The same command with fixed.mp4 as the output gives an MP4 of 23.787 seconds, if that’s what your editor wants. In OBS itself, File › Remux Recordings does this copy for you, and MKVToolNix can also rewrite an MKV; those two weren’t part of this test.</p><h3>Damage in the middle costs up to one cluster</h3><p>Crashes aren’t the only problem: a flaky drive or a bad copy can leave a hole inside the file. To test that, 256 KB of zeros were written into a copy of the recording at byte 9,000,000.</p><pre>$ ffprobe -v error -count_packets -show_entries stream=codec_type,nb_read_packets -of csv=p=0 mid.mkv<br>[matroska,webm @ 0x...] 0x00 at pos 9020108 (0x89a2cc) invalid as first byte of an EBML number<br>[matroska,webm @ 0x...] File ended prematurely<br>video,646<br>audio,1006</pre><p>The hole held about a third of a second of data, but 65 video frames and 103 audio packets were lost, about 2.2 seconds: when the reader hits garbage it skips to the start of the next cluster. Rewriting this file with the same -c copy command still produced a 23.787-second MKV that plays, with a jump where the hole was, and decoding it reported a single error. In an MKV, local damage stays local.</p><h3>When a rewrite isn’t enough</h3><ul><li>The file is 0 KB or a few KB: nothing was written, and there is nothing to repair.</li><li>The start of the file is damaged (open it in a hex viewer: a beginning made of zeros is a bad sign). The header describes the tracks, and without it FFmpeg may not recognise the file at all.</li><li>The recording is a standard MP4 or MOV. The index has to be rebuilt from a healthy recording made with the same settings, which is what tools such as untrunc do.</li></ul><h3>Avoiding it next time</h3><p>Keep recording to MKV, or to Hybrid MP4 on OBS 30.2 and later, and let OBS remux to MP4 automatically when you stop (Settings › Advanced). Leave free space on the recording drive: a full disk ends a recording as abruptly as a crash.</p><p><em>Disclosure: I built FrameRescue, an online service that repairs MKV recordings cut off by a crash, a power cut or a full disk when a simple rewrite doesn’t work: it removes the cut-off end and damaged pieces and copies the rest into an MP4. Uploading and the preview are free; downloading a repaired file costs €5. Guide: </em><a href="https://framerescue.com/repair-obs-recording/"><em>https://framerescue.com/repair-obs-recording/</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a6dc668b8d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your phone died while recording. Here’s what happened to the video, and how to get it back]]></title>
            <link>https://medium.com/@arturo.didonna/your-phone-died-while-recording-heres-what-happened-to-the-video-and-how-to-get-it-back-58217c5af417?source=rss-9331a5af6100------2</link>
            <guid isPermaLink="false">https://medium.com/p/58217c5af417</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[data-recovery]]></category>
            <category><![CDATA[video-production]]></category>
            <dc:creator><![CDATA[Arturo Didonna]]></dc:creator>
            <pubDate>Tue, 24 Nov 2026 17:23:10 GMT</pubDate>
            <atom:updated>2026-11-24T17:23:10.925Z</atom:updated>
            <content:encoded><![CDATA[<h4>A clip that won’t play has usually lost its index, not its footage. A ten-minute check, a free fix, and the cases nobody can rescue.</h4><p><em>This story was written with the assistance of an AI writing program. The commands and outputs below were run on test files made for this article.</em></p><p>The battery hits zero halfway through a recording, a drone crashes, a dashcam loses power, someone pulls the SD card too early. Afterwards there is a file with a normal size that no player will open, or that shows 0:00. Most of the time the video is still in there. What’s missing is a small part written at the very end.</p><h3>What actually goes wrong</h3><p>An MP4 or MOV file has two parts that matter here. The <strong>mdat</strong> part holds the compressed video and audio, and it is written continuously while you record. The <strong>moov</strong> part is the index: where every frame is, how long the video lasts, which codec settings to use. Most cameras and phones write it only when you press stop, because until then they don’t know the final layout.</p><p>If the power goes off before that moment, you get a file full of footage with no index. Players and editors give up, and ffmpeg says so plainly:</p><pre>[mov,mp4,m4a,3gp,3g2,mj2 @ 0x...] moov atom not found<br>broken.mp4: Invalid data found when processing input</pre><p>To check this, a 60-second recording was started with ffmpeg and killed after 6 seconds with SIGKILL, which gives the program no chance to tidy up, much like a power cut. The result was a 1.5 MB file with exactly that error, even though the frames were inside.</p><h3>Ten-minute triage</h3><ol><li><strong>Stop recording onto the same card or phone storage.</strong> New recordings can overwrite what you are trying to save, especially on dashcams, which record in a loop.</li><li><strong>Find the file.</strong> On Android 11 and later, an unfinished recording is often left in DCIM/Camera as a hidden file whose name starts with .pending-. Turn on “show hidden files” in your file manager, or connect the phone to a computer. Android deletes these files on its own, by default about a week later, so copy it now. On an iPhone, check Recents and the Hidden album in Photos; with the built-in Camera app the clip is sometimes simply gone after a sudden shutdown. GoPro, DJI and other cameras leave the file on the card, and some try to repair the last clip when you switch them on again with the same card, so let the camera try first.</li><li><strong>Copy it as it is.</strong> Don’t open it in an editor, convert it, or send it through a messaging app: those re-encode or re-save the file. Work only on copies.</li><li><strong>Check the size.</strong> Record one minute with the same device and settings, note how many MB it takes, and multiply by the length you expected. If the broken file is about that size, the footage is there. A 0-byte file is empty, and nothing can be recovered from it.</li><li><strong>Record a short healthy clip</strong> with the same device and the same settings: resolution, frame rate, codec (H.264 or HEVC), lens or mode. You’ll need it for the repair.</li></ol><h3>The free fix: untrunc</h3><p>Since the frames are already in the file, the job is to rebuild the index around them. The open-source tool <a href="https://github.com/anthwlock/untrunc">untrunc</a> (the maintained fork by anthwlock) does exactly this. It learns how your device writes its files from the healthy clip, then walks through the broken one frame by frame. Healthy file first, broken file second:</p><pre>untrunc healthy.mp4 broken.mp4</pre><p>On the 6-second test file it reported:</p><pre>Info: Found 296 packets ( mp4a: 180 avc1: 116 avc1-keyframes: 1 )<br>Info: Duration of avc1: 3s 866ms  (3866 ms)<br>Info: saving broken.mp4_fixed.mp4</pre><p>The repaired file played and decoded to the end. It was 3.9 seconds long, not 6: part of the gap is ffmpeg’s start-up time, and the rest had not been written to disk yet when the process was killed. Real devices also hold the last moments in memory, so expect the final seconds before a shutdown to be missing.</p><p>A few things decide whether untrunc works for you:</p><ul><li>The healthy clip must come from the same device with the same settings, copied straight from the device. A clip that went through WhatsApp or social media has been re-encoded and won’t match.</li><li>Windows users can download ready-made builds from the project’s releases page. On Linux it builds from source, and on a Mac expect some trial and error.</li><li>If it stops early, try again with the -s option, and check the result from beginning to end: a file that opens is not necessarily complete, and the sound can drift out of sync.</li></ul><h3>What nobody can recover</h3><ul><li>A 0-byte file, or one filled with zeros: the data was never written.</li><li>Seconds that were still in the device’s memory when it lost power.</li><li>Clips that a dashcam or camera has already overwritten.</li><li>Deleted videos. That is data recovery (PhotoRec and similar tools), a different problem from a file that exists but won’t open.</li></ul><p>If you record with your own software, you can avoid the whole problem: fragmented MP4 (in ffmpeg, -movflags +frag_keyframe+empty_moov with a short keyframe interval) keeps the finished parts playable even if the recording stops abruptly.</p><p><strong>Disclosure:</strong> I built FrameRescue, an online service that does this repair in the browser. Uploading and the preview are free, and downloading a repaired file costs €5. If you’d rather not build untrunc, or you don’t have a healthy clip from the same device, it’s here: <a href="https://framerescue.com/phone-died-while-recording-video/">framerescue.com</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58217c5af417" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>