Answers.Body: <p>You need to add <code>-c copy</code> to make ffmpeg copy the bitstreams as-is. This is also called <em>remuxing</em>.</p>
  <p>Otherwise it will default to re-encoding each stream, and the chosen defaults usually mean a rather low bitrate (and, consequently a reduction in quality.)</p>
  <p>For more info, see the <a href="https://trac.ffmpeg.org/wiki/Map" rel="nofollow noreferrer">FFmpeg wiki entry on selecting streams</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-04-21T15:33:58.867Z
Answers.LastActivityDate: 2022-04-21T15:33:58.867Z
Answers.UserDisplayName: slhck
Body: <p>I wrote the following script that is meant to remove the unnecessary audio streams, aka dubbing, as well as subtitles from
  the movies in my collection:</p>
  <pre><code>#!/usr/bin/bash
  
  echo &quot;What is the path to the source file?&quot;
  read if
  of=$(echo &quot;${if}&quot;|sed -E 's/(\.)([avimp4kv]{3,3}$)/\1stripped.\2/')
  echo &quot;What is the number of the audio stream that you want to copy?&quot;
  read no
  
  ffmpeg -v 0 -i &quot;${if}&quot; -map 0:v -map 0:${no} &quot;${of}&quot;
  </code></pre>
  <p>My intent is to save on storage while preserving the original quality of both video and audio stream of my choice.
  I noticed that the reduction of the size of the media files is very large. For example:
  <code>Todo_Sobre_Mi_Madre_(1999).avi</code> that has 1.4GB and the following streams:</p>
  <pre><code>Input #0, avi, from 'Todo_Sobre_Mi_Madre_(1999).avi':
    Metadata:
      encoder         : VirtualDubMod 1.5.10.2 (build 2540/release)
    Duration: 01:41:24.67, start: 0.000000, bitrate: 1936 kb/s
      Stream #0:0: Video: mpeg4 (DX50 / 0x30355844), yuv420p, 720x304 [SAR 1:1 DAR 45:19], 1539 kb/s, 23.98 fps, 23.98 tbr, 23.98 tbn, 30k tbc
      Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp, 192 kb/s
      Stream #0:2: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp, 192 kb/s
  </code></pre>
  <p>was converted to <code>Todo_Sobre_Mi_Madre_(1999).stripped.avi</code> of only 248MB with the following streams:</p>
  <pre><code>Input #0, avi, from 'Todo_Sobre_Mi_Madre_(1999).stripped.avi':
    Metadata:
      encoder         : Lavf58.29.100
    Duration: 01:41:24.75, start: 0.000000, bitrate: 341 kb/s
      Stream #0:0: Video: mpeg4 (Simple Profile) (FMP4 / 0x34504D46), yuv420p, 720x304 [SAR 1:1 DAR 45:19], 200 kb/s, 23.98 fps, 23.98 tbr, 23.98 tbn, 24k tbc
      Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp, 128 kb/s
  
  </code></pre>
  <p>I noticed the unintended reduction of the bitrate of both the video, from 1539 kb/s to just 200 kb/s and the audio stream, from 192 kb/s to just 128 kb/s. The resolution remained unchanged. What am I doing wrong? How might I utilize <code>ffmpeg</code> and its <code>-map</code> option to accomplish my goal?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-04-21T15:34:22.507Z
Comments.Text: Next time posting, please always include all the ffmpeg output, not just the parts you think are relevant. Thanks!
Comments.UserDisplayName: slhck
Tags: <ffmpeg><video-quality><audio-quality><bitrate>
Title: Why does this script reduce the bitrate of both the video and the audio stream?
UserDisplayName: John Smith
ThreadText: # Why does this script reduce the bitrate of both the video and the audio stream?
  
  (Asked by: username_0 on 2022-04-21)
  
  I wrote the following script that is meant to remove the unnecessary audio streams, aka dubbing, as well as subtitles from
  the movies in my collection:
  
  ```
  #!/usr/bin/bash
  
  echo "What is the path to the source file?"
  read if
  of=$(echo "${if}"|sed -E 's/(\.)([avimp4kv]{3,3}$)/\1stripped.\2/')
  echo "What is the number of the audio stream that you want to copy?"
  read no
  
  ffmpeg -v 0 -i "${if}" -map 0:v -map 0:${no} "${of}"
  
  ```
  
  My intent is to save on storage while preserving the original quality of both video and audio stream of my choice.
  I noticed that the reduction of the size of the media files is very large. For example:
  `Todo_Sobre_Mi_Madre_(1999).avi` that has 1.4GB and the following streams:
  
  ```
  Input #0, avi, from 'Todo_Sobre_Mi_Madre_(1999).avi':
    Metadata:
      encoder         : VirtualDubMod 1.5.10.2 (build 2540/release)
    Duration: 01:41:24.67, start: 0.000000, bitrate: 1936 kb/s
      Stream #0:0: Video: mpeg4 (DX50 / 0x30355844), yuv420p, 720x304 [SAR 1:1 DAR 45:19], 1539 kb/s, 23.98 fps, 23.98 tbr, 23.98 tbn, 30k tbc
      Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp, 192 kb/s
      Stream #0:2: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp, 192 kb/s
  
  ```
  
  was converted to `Todo_Sobre_Mi_Madre_(1999).stripped.avi` of only 248MB with the following streams:
  
  ```
  Input #0, avi, from 'Todo_Sobre_Mi_Madre_(1999).stripped.avi':
    Metadata:
      encoder         : Lavf58.29.100
    Duration: 01:41:24.75, start: 0.000000, bitrate: 341 kb/s
      Stream #0:0: Video: mpeg4 (Simple Profile) (FMP4 / 0x34504D46), yuv420p, 720x304 [SAR 1:1 DAR 45:19], 200 kb/s, 23.98 fps, 23.98 tbr, 23.98 tbn, 24k tbc
      Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp, 128 kb/s
  
  ```
  
  I noticed the unintended reduction of the bitrate of both the video, from 1539 kb/s to just 200 kb/s and the audio stream, from 192 kb/s to just 128 kb/s. The resolution remained unchanged. What am I doing wrong? How might I utilize `ffmpeg` and its `-map` option to accomplish my goal?
  
  **Tags:** ffmpeg, video-quality, audio-quality, bitrate
  
  > **Comments:**
  > **username_1**: Next time posting, please always include all the ffmpeg output, not just the parts you think are relevant. Thanks!  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-04-21. Score: 1 | Accepted answer
  
  You need to add `-c copy` to make ffmpeg copy the bitstreams as-is. This is also called *remuxing*.
  
  Otherwise it will default to re-encoding each stream, and the chosen defaults usually mean a rather low bitrate (and, consequently a reduction in quality.)
  
  For more info, see the [FFmpeg wiki entry on selecting streams](https://trac.ffmpeg.org/wiki/Map).
  
  
  ---
  
  