Answers.Body: <p>Sorry, I cannot write the script but here is the idea. First get the <code>codec_name</code> of your text-based subtitle from a video</p>
  <pre><code>ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 &lt;test video name&gt;
  </code></pre>
  <p>Now replace  with that with that codec name in te following script.</p>
  <pre><code>Usage: imgsrtremover &lt;file name&gt;
  Output: &lt;filename without extention&gt;.mp4
  </code></pre>
  <pre><code>#! /bin/bash
  imgsrtstreams=$(ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 $1 | grep -n &quot;&lt;codec&gt;&quot; | cut -f1 -d:)
  cmd=&quot;ffmpeg -i $1 -map 0&quot;
  for i in $imgsrtstreams
  do
  cmd+=&quot; -map -0:$((i-1))&quot;
  done 
  $cmd -c copy $(echo &quot;$1&quot; | rev|cut -f 2- -d '.'|rev).mp4  
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-09-03T12:55:21.607Z
Answers.LastActivityDate: 2021-09-03T12:55:21.607Z
Answers.UserDisplayName: Abdullah Ibn Fulan
Body: <p>Is it possible to remove <em>only</em> image based subtitles using ffmpeg? I know that you can manually select/exclude streams using -map, however I'm trying to automate this process, and the input files have a mix of image based subtitles (pgssubs) and text based subtitles. Since I'm trying to encode to an MP4 container, the image based subtitles are incompatible.</p>
  
Tags: <ffmpeg>
Title: Using ffmpeg to strip image based subtitles
UserDisplayName: William Huebner
ThreadText: # Using ffmpeg to strip image based subtitles
  
  (Asked by: username_0 on 2021-08-24)
  
  Is it possible to remove *only* image based subtitles using ffmpeg? I know that you can manually select/exclude streams using -map, however I'm trying to automate this process, and the input files have a mix of image based subtitles (pgssubs) and text based subtitles. Since I'm trying to encode to an MP4 container, the image based subtitles are incompatible.
  
  **Tags:** ffmpeg
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-09-03. Score: 1
  
  Sorry, I cannot write the script but here is the idea. First get the `codec_name` of your text-based subtitle from a video
  
  ```
  ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 <test video name>
  
  ```
  
  Now replace with that with that codec name in te following script.
  
  ```
  Usage: imgsrtremover <file name>
  Output: <filename without extention>.mp4
  
  ```
  
  ```
  #! /bin/bash
  imgsrtstreams=$(ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 $1 | grep -n "<codec>" | cut -f1 -d:)
  cmd="ffmpeg -i $1 -map 0"
  for i in $imgsrtstreams
  do
  cmd+=" -map -0:$((i-1))"
  done 
  $cmd -c copy $(echo "$1" | rev|cut -f 2- -d '.'|rev).mp4  
  
  ```
  
  
  ---
  
  