<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Muhammad Darwis</title>
    <description>The latest articles on DEV Community by Muhammad Darwis (@muhammad_darwis_7).</description>
    <link>https://dev.to/muhammad_darwis_7</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3823523%2Fcbf06dc8-410f-4ad0-9a7a-0f879c07c9e2.png</url>
      <title>DEV Community: Muhammad Darwis</title>
      <link>https://dev.to/muhammad_darwis_7</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/muhammad_darwis_7"/>
    <language>en</language>
    <item>
      <title>How I Converted 1,000+ CCTV .media Files to MP4 Using FFmpeg and a Bash Script</title>
      <dc:creator>Muhammad Darwis</dc:creator>
      <pubDate>Sat, 14 Mar 2026 07:44:29 +0000</pubDate>
      <link>https://dev.to/muhammad_darwis_7/how-i-converted-1000-cctv-media-files-to-mp4-using-ffmpeg-and-a-bash-script-3kdi</link>
      <guid>https://dev.to/muhammad_darwis_7/how-i-converted-1000-cctv-media-files-to-mp4-using-ffmpeg-and-a-bash-script-3kdi</guid>
      <description>&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;My neighbor's car got scratched. They had CCTV footage — 3 days of recordings on a microSD card.&lt;/p&gt;

&lt;p&gt;When we checked the files, every single one had a .media extension. No video player could open them. Most converter apps either choked on bulk files or wanted a subscription.&lt;/p&gt;

&lt;p&gt;I suspected these were just regular video containers with a renamed extension — common with budget CCTV brands.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 1: Test with FFmpeg
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ffmpeg &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s2"&gt;"/path/to/0000.media"&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; copy test_output.mp4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It worked. H.264 video wrapped in a .media container. FFmpeg read it without issues.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 2: Understand the File Structure
&lt;/h2&gt;

&lt;p&gt;The microSD had a nested folder structure — thousands of 10-second .media chunks across subfolders.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 3: The Script
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;

&lt;span class="nv"&gt;INPUT_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/path/to/cctv"&lt;/span&gt;
&lt;span class="nv"&gt;OUTPUT_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/path/to/cctv_generated/output"&lt;/span&gt;
&lt;span class="nv"&gt;MERGED_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/path/to/cctv_generated/merged"&lt;/span&gt;
&lt;span class="nv"&gt;CONCAT_LIST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/path/to/cctv_generated/concat_list.txt"&lt;/span&gt;
&lt;span class="nv"&gt;MERGED_OUTPUT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$MERGED_DIR&lt;/span&gt;&lt;span class="s2"&gt;/merged_final.mp4"&lt;/span&gt;

&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$MERGED_DIR&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$CONCAT_LIST&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

find &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$INPUT_DIR&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-name&lt;/span&gt; &lt;span class="s2"&gt;"*.media"&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; | &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nb"&gt;read&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; f&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
  &lt;/span&gt;&lt;span class="nv"&gt;rel&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$f&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | &lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="s2"&gt;"s|&lt;/span&gt;&lt;span class="nv"&gt;$INPUT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/||"&lt;/span&gt; | &lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="s1"&gt;'s|/|_|g'&lt;/span&gt; | &lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="s1"&gt;'s|\.media||'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
  &lt;span class="nv"&gt;out&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;rel&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.mp4"&lt;/span&gt;

  ffmpeg &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$f&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; copy &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$out&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; 2&amp;gt;/dev/null

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$out&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$out&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"file '&lt;/span&gt;&lt;span class="nv"&gt;$out&lt;/span&gt;&lt;span class="s2"&gt;'"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$CONCAT_LIST&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;else
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"⚠️  Skipping (failed): &lt;/span&gt;&lt;span class="nv"&gt;$f&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;fi
done

&lt;/span&gt;ffmpeg &lt;span class="nt"&gt;-f&lt;/span&gt; concat &lt;span class="nt"&gt;-safe&lt;/span&gt; 0 &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$CONCAT_LIST&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; copy &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$MERGED_OUTPUT&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"✅ Done! Merged output: &lt;/span&gt;&lt;span class="nv"&gt;$MERGED_OUTPUT&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Why -c copy?
&lt;/h2&gt;

&lt;p&gt;Instead of re-encoding (which takes hours), &lt;code&gt;-c copy&lt;/code&gt; copies the raw stream directly into the new container.&lt;/p&gt;

&lt;p&gt;For 1,000 files this means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Minutes instead of hours&lt;/li&gt;
&lt;li&gt;Zero quality loss&lt;/li&gt;
&lt;li&gt;Negligible CPU usage&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Result
&lt;/h2&gt;

&lt;p&gt;~1,000 files converted and merged into a single &lt;strong&gt;34-hour MP4&lt;/strong&gt;. The whole process finished in under 15 minutes on a Mac Mini M-series.&lt;/p&gt;

&lt;p&gt;A few files had &lt;code&gt;moov atom not found&lt;/code&gt; errors — these were corrupt/incomplete recordings from the CCTV, safely skipped.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj1z4t0zpryvzi9sn20gu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj1z4t0zpryvzi9sn20gu.png" alt=" " width="800" height="60"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The Bigger Takeaway
&lt;/h2&gt;

&lt;p&gt;Most "bulk video converter" websites? They're just wrappers around FFmpeg on a backend server. You're paying for a UI around a free, 20-year-old open-source CLI tool.&lt;/p&gt;

&lt;p&gt;Next time you hit a file format problem — check if FFmpeg handles it first. It probably does.&lt;/p&gt;

&lt;p&gt;FFmpeg docs: &lt;a href="https://www.ffmpeg.org/" rel="noopener noreferrer"&gt;https://www.ffmpeg.org/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ffmpeg</category>
      <category>bash</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
