Answers.Body: <p>What you're asking for is called <a href="https://en.wikipedia.org/wiki/Inpainting" rel="nofollow noreferrer">Inpainting</a> and is difficult enough for still images. The result is passable to distracting depending on the size and transparency of the text, the surrounding image, and compression. I found only one mention of inpainting at video stack exchange <a href="https://video.stackexchange.com/questions/1981/sources-to-learn-more-about-audio-video-compression-codecs-algorithms-etc/10536?s=1%7C9.4386#10536">here</a>. You can see a demonstration of the algorithm <a href="https://www.webinpaint.com/" rel="nofollow noreferrer">here</a>.</p>
  
  <p>Using ffmpeg and mathematica, the following procedure is a quick and dirty solution. The result can be better than blurring, again depending on the characteristics of the video.</p>
  
  <p>Export frames:</p>
  
  <pre><code>ffmpeg -i vid.mp4 D:\data\vid\frames-%06d.png
  </code></pre>
  
  <p>Create a text mask using the average of every 100 frames or so.</p>
  
  <pre><code>fnames = FileNames["D:/data/vid/frames-*.jpg"];
  mfnames = fnames[[1 ;; All ;; Floor[0.005*Length[fnames]]]];
  imgs = Import /@ mfnames;
  mimg = Mean[imgs]
  mask = Dilation[Binarize[mimg, {0.37, 1}], 1]
  </code></pre>
  
  <p>Note: the parameters in Binarize will need to be tweaked for every video.</p>
  
  <p>If the video contains a fixed camera or other parts similar in color to the text throughout its entire length, you must exclude those parts by multiplying by a 2nd mask (the numbers are positions of the lower left and upper right corners of a rectangle that surround the text to be removed):</p>
  
  <pre><code>Image[Graphics[{
  {Black, Rectangle[{0, 0}, ImageDimensions[mask]]},
  {White, Rectangle @@ {{377.84411276948595`, 
      161.72470978441106`}, {163.44941956882255`, 
      127.76119402985057`}}},
  }, PlotRangePadding -&gt; None],
  ImageSize -&gt; ImageDimensions[mask]];
  mask = mask*%
  </code></pre>
  
  <p>Apply inpaint algorithm:</p>
  
  <pre><code>Inpaint[Import[fnames[[1]]], mask]
  </code></pre>
  
  <p>This line processes all frames and saves them to a new directory:</p>
  
  <pre><code>Export[FileNameJoin[MapAt[# &lt;&gt; ".output" &amp;, FileNameSplit[#], -2]], 
      Inpaint[Import[#], mask]] &amp; /@ fnames
  </code></pre>
  
  <p>Or if you want it done 1000 times faster use this C++ code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;thread&gt;
  #include &lt;opencv2/opencv.hpp&gt;
  #include &lt;boost/filesystem.hpp&gt;
  
  // args: D:\data\text_remove\frames_full  D:\data\text_remove\frames_full\mask.png
  
  using namespace std;
  namespace fs = boost::filesystem;
  
  
  void process_files(const vector&lt;string&gt;&amp; infile, const vector&lt;string&gt;&amp; outfile, const cv::Mat&amp; mask, int i0, int i1)
  {
      for (int i = i0; i &lt; i1; ++i)
      {
          cv::Mat img = cv::imread(infile[i]);
  
          if (img.empty())
          {
              cout &lt;&lt; "process_files(): imread(): " &lt;&lt; "[" &lt;&lt; i0 &lt;&lt; "," &lt;&lt; i1 &lt;&lt; ")  : " &lt;&lt; i1 - i0 &lt;&lt; endl;
              break;
          }
  
          cv::Mat out;
          cv::inpaint(img, mask, out, 3, cv::INPAINT_NS);
  
          cv::imwrite(outfile[i], out);
      }
  }
  
  void threaded_process_files(const vector&lt;string&gt;&amp; in, const vector&lt;string&gt;&amp; out, const cv::Mat&amp; mask, int threads)
  {
      int step = in.size() / threads;
      int rem = in.size() % threads;
  
      vector&lt;thread&gt; pool;
  
      for (int i = 0; i &lt; (threads - 1); ++i)
      {
          int i0 = i * step;
          int i1 = (i + 1) * step;
          pool.push_back(thread(process_files, in, out, mask, i0, i1));
      }
  
      int i0 = (threads - 1) * step;
      int i1 = in.size();
      pool.push_back(thread(process_files, in, out, mask, i0, i1));
  
      for (auto&amp; th : pool)
          th.join();
  }
  
  int main(int argc, char** argv)
  {
      if (argc &lt; 2)
      {
          cout &lt;&lt; "argv &lt; 2: Missing input directory" &lt;&lt; endl;
          return EXIT_FAILURE;
      }
  
      if (argc &lt; 3)
      {
          cout &lt;&lt; "argv &lt; 3: Missing mask image" &lt;&lt; endl;
          return EXIT_FAILURE;
      }
  
      cv::Mat mask(cv::imread(argv[2], cv::IMREAD_GRAYSCALE));
  
      if (mask.empty())
      {
          cout &lt;&lt; "imread(): failed to read mask" &lt;&lt; endl;
          return EXIT_FAILURE;
      }
  
      cout &lt;&lt; "mask image: " &lt;&lt; mask.size() &lt;&lt; endl;
  
      fs::path infile(argv[1]);
      fs::path ifstem = infile.stem();
      fs::path ifleaf = infile.leaf();
      fs::path ifparent = infile.parent_path();
  
      if (!fs::is_directory(infile))
      {
          cout &lt;&lt; infile &lt;&lt; " is not a directory" &lt;&lt; endl;
          return EXIT_FAILURE;
      }
  
      string fstr = ifleaf.string() + ".output";
      fs::path outdir = ifparent / fstr;
  
      if (!fs::exists(outdir))
      {
          if (!fs::create_directory(outdir))
          {
              cout &lt;&lt; "create_directory() failed on: " &lt;&lt; outdir &lt;&lt; endl;
              return EXIT_FAILURE;
          }
      }
  
      vector&lt;string&gt; fnames;
      vector&lt;string&gt; fnames_out;
  
      clock_t t0 = clock();
  
      cout &lt;&lt; "Scanning directory images" &lt;&lt; endl;
  
      int i = 0;
      for (fs::directory_iterator di(infile); di != fs::directory_iterator(); ++di)
      {
          fs::path fpath = di-&gt;path();
          fs::path leaf = fpath.leaf();
          fs::path fpath_new = outdir / leaf;
  
          fnames.push_back(fpath.string());
      }
  
      cout &lt;&lt; (double)(clock() - t0) / CLOCKS_PER_SEC &lt;&lt; endl;
      cout &lt;&lt; "Processing images" &lt;&lt; endl;
      t0 = clock();
  
      threaded_process_files(fnames, fnames_out, mask, 16);
  
      clock_t t1 = clock();
      double dt = (double)(t1 - t0) / CLOCKS_PER_SEC;
      cout &lt;&lt; dt &lt;&lt; endl;
      cout &lt;&lt; dt / fnames.size() &lt;&lt; endl;
  
      return EXIT_SUCCESS;
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-18T18:20:25.307Z
Answers.LastActivityDate: 2018-06-18T20:47:21.970Z
Answers.LastEditDate: 2018-06-18T20:47:21.970Z
Answers.UserDisplayName: user6552
Answers.Body: <p>Remove? No.</p>
  
  <p>Best thing to do would be to remove the text from the original video project and re-render.</p>
  
  <p>Barring that, you could cover it.</p>
  
  <p>What I would do (and have done before) is pull the video into After Effects and cover it with a small area of blur.  Once the blur is applied, pull the brightness down enough so that it blends with the surrounding area.</p>
  
  <p>Alternative (and possibly better since the video would probably allow it) is to do essentially the same thing as above only to cover the small area with a dark rectangle shape in After Effects.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-18T11:03:20.417Z
Answers.Text: Or copy the video layer, mask a small section near to the text and then move it down to cover the text. That way you'd get the texture and match the grain in the original source. You could also use the clone brush, just as you would in photoshop.
Answers.UserDisplayName: stib
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-17T17:26:28.483Z
Answers.LastActivityDate: 2017-01-17T17:26:28.483Z
Answers.UserDisplayName: Joe
Body: <p>I have a video with text on the side of it and I want to remove it. The good thing is that the video has no changes in that area of the screen for the rest of the video. Meaning that the movement in the video is on the right side of the video while the left side, which has the text has no animation what so ever. Is it possible to remove that text. </p>
  
  <p>Here is a link to the video also, the text is the "press any button" thing. </p>
  
  <p><div class="youtube-embed"><div>
                  <iframe width="640px" height="395px" src="https://www.youtube.com/embed/r7MdK7X_lo4?start=0"></iframe>
              </div></div> </p>
  
  <p>Thank you!</p>
  
Tags: <editing>
Title: Remove static text from video?
UserDisplayName: USF
ThreadText: # Remove static text from video?
  
  (Asked by: username_0 on 2017-01-17)
  
  I have a video with text on the side of it and I want to remove it. The good thing is that the video has no changes in that area of the screen for the rest of the video. Meaning that the movement in the video is on the right side of the video while the left side, which has the text has no animation what so ever. Is it possible to remove that text.
  
  Here is a link to the video also, the text is the "press any button" thing.
  
  Thank you!
  
  **Tags:** editing
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-06-18. Score: 2
  
  What you're asking for is called [Inpainting](https://en.wikipedia.org/wiki/Inpainting) and is difficult enough for still images. The result is passable to distracting depending on the size and transparency of the text, the surrounding image, and compression. I found only one mention of inpainting at video stack exchange [here](https://video.stackexchange.com/questions/1981/sources-to-learn-more-about-audio-video-compression-codecs-algorithms-etc/10536?s=1%7C9.4386#10536). You can see a demonstration of the algorithm [here](https://www.webinpaint.com/).
  
  Using ffmpeg and mathematica, the following procedure is a quick and dirty solution. The result can be better than blurring, again depending on the characteristics of the video.
  
  Export frames:
  
  ```
  ffmpeg -i vid.mp4 D:\data\vid\frames-%06d.png
  
  ```
  
  Create a text mask using the average of every 100 frames or so.
  
  ```
  fnames = FileNames["D:/data/vid/frames-*.jpg"];
  mfnames = fnames[[1 ;; All ;; Floor[0.005*Length[fnames]]]];
  imgs = Import /@ mfnames;
  mimg = Mean[imgs]
  mask = Dilation[Binarize[mimg, {0.37, 1}], 1]
  
  ```
  
  Note: the parameters in Binarize will need to be tweaked for every video.
  
  If the video contains a fixed camera or other parts similar in color to the text throughout its entire length, you must exclude those parts by multiplying by a 2nd mask (the numbers are positions of the lower left and upper right corners of a rectangle that surround the text to be removed):
  
  ```
  Image[Graphics[{
  {Black, Rectangle[{0, 0}, ImageDimensions[mask]]},
  {White, Rectangle @@ {{377.84411276948595`, 
      161.72470978441106`}, {163.44941956882255`, 
      127.76119402985057`}}},
  }, PlotRangePadding -> None],
  ImageSize -> ImageDimensions[mask]];
  mask = mask*%
  
  ```
  
  Apply inpaint algorithm:
  
  ```
  Inpaint[Import[fnames[[1]]], mask]
  
  ```
  
  This line processes all frames and saves them to a new directory:
  
  ```
  Export[FileNameJoin[MapAt[# <> ".output" &, FileNameSplit[#], -2]], 
      Inpaint[Import[#], mask]] & /@ fnames
  
  ```
  
  Or if you want it done 1000 times faster use this C++ code:
  
  ```
  #include <iostream>
  #include <vector>
  #include <thread>
  #include <opencv2/opencv.hpp>
  #include <boost/filesystem.hpp>
  
  // args: D:\data\text_remove\frames_full  D:\data\text_remove\frames_full\mask.png
  
  using namespace std;
  namespace fs = boost::filesystem;
  
  void process_files(const vector<string>& infile, const vector<string>& outfile, const cv::Mat& mask, int i0, int i1)
  {
      for (int i = i0; i < i1; ++i)
      {
          cv::Mat img = cv::imread(infile[i]);
  
          if (img.empty())
          {
              cout << "process_files(): imread(): " << "[" << i0 << "," << i1 << ")  : " << i1 - i0 << endl;
              break;
          }
  
          cv::Mat out;
          cv::inpaint(img, mask, out, 3, cv::INPAINT_NS);
  
          cv::imwrite(outfile[i], out);
      }
  }
  
  void threaded_process_files(const vector<string>& in, const vector<string>& out, const cv::Mat& mask, int threads)
  {
      int step = in.size() / threads;
      int rem = in.size() % threads;
  
      vector<thread> pool;
  
      for (int i = 0; i < (threads - 1); ++i)
      {
          int i0 = i * step;
          int i1 = (i + 1) * step;
          pool.push_back(thread(process_files, in, out, mask, i0, i1));
      }
  
      int i0 = (threads - 1) * step;
      int i1 = in.size();
      pool.push_back(thread(process_files, in, out, mask, i0, i1));
  
      for (auto& th : pool)
          th.join();
  }
  
  int main(int argc, char** argv)
  {
      if (argc < 2)
      {
          cout << "argv < 2: Missing input directory" << endl;
          return EXIT_FAILURE;
      }
  
      if (argc < 3)
      {
          cout << "argv < 3: Missing mask image" << endl;
          return EXIT_FAILURE;
      }
  
      cv::Mat mask(cv::imread(argv[2], cv::IMREAD_GRAYSCALE));
  
      if (mask.empty())
      {
          cout << "imread(): failed to read mask" << endl;
          return EXIT_FAILURE;
      }
  
      cout << "mask image: " << mask.size() << endl;
  
      fs::path infile(argv[1]);
      fs::path ifstem = infile.stem();
      fs::path ifleaf = infile.leaf();
      fs::path ifparent = infile.parent_path();
  
      if (!fs::is_directory(infile))
      {
          cout << infile << " is not a directory" << endl;
          return EXIT_FAILURE;
      }
  
      string fstr = ifleaf.string() + ".output";
      fs::path outdir = ifparent / fstr;
  
      if (!fs::exists(outdir))
      {
          if (!fs::create_directory(outdir))
          {
              cout << "create_directory() failed on: " << outdir << endl;
              return EXIT_FAILURE;
          }
      }
  
      vector<string> fnames;
      vector<string> fnames_out;
  
      clock_t t0 = clock();
  
      cout << "Scanning directory images" << endl;
  
      int i = 0;
      for (fs::directory_iterator di(infile); di != fs::directory_iterator(); ++di)
      {
          fs::path fpath = di->path();
          fs::path leaf = fpath.leaf();
          fs::path fpath_new = outdir / leaf;
  
          fnames.push_back(fpath.string());
      }
  
      cout << (double)(clock() - t0) / CLOCKS_PER_SEC << endl;
      cout << "Processing images" << endl;
      t0 = clock();
  
      threaded_process_files(fnames, fnames_out, mask, 16);
  
      clock_t t1 = clock();
      double dt = (double)(t1 - t0) / CLOCKS_PER_SEC;
      cout << dt << endl;
      cout << dt / fnames.size() << endl;
  
      return EXIT_SUCCESS;
  }
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2017-01-17. Score: 1
  
  Remove? No.
  
  Best thing to do would be to remove the text from the original video project and re-render.
  
  Barring that, you could cover it.
  
  What I would do (and have done before) is pull the video into After Effects and cover it with a small area of blur. Once the blur is applied, pull the brightness down enough so that it blends with the surrounding area.
  
  Alternative (and possibly better since the video would probably allow it) is to do essentially the same thing as above only to cover the small area with a dark rectangle shape in After Effects.
  
  > **Comments:**
  > **username_3**: Or copy the video layer, mask a small section near to the text and then move it down to cover the text. That way you'd get the texture and match the grain in the original source. You could also use the clone brush, just as you would in photoshop.  
  
  ---
  
  