Skip to content

Instantly share code, notes, and snippets.

@TH3xACE
Forked from maximebories/convert.md
Created December 26, 2024 16:57
Show Gist options
  • Save TH3xACE/6c026d00521c3a803c3f626dd632dbd6 to your computer and use it in GitHub Desktop.
Save TH3xACE/6c026d00521c3a803c3f626dd632dbd6 to your computer and use it in GitHub Desktop.

Revisions

  1. @maximebories maximebories revised this gist Sep 9, 2024. 1 changed file with 29 additions and 29 deletions.
    58 changes: 29 additions & 29 deletions convert.md
    Original file line number Diff line number Diff line change
    @@ -1,67 +1,67 @@
    This ffmpeg command converts a .webm video file to a standard .mp4 file using the libx264 codec for video, aac codec for audio, and a CRF value of 22. The preset is set to 'slow' for higher quality encoding, and the audio bitrate is set to 128 kbps.
    # WebM to MP4 using FFmpeg

    # If the input and output filenames don't contain spaces, quotation marks or other special characters:
    ## This FFmpeg command converts a .webm video file to a standard .mp4 file using the libx264 codec for video, aac codec for audio, and a CRF value of 22. The preset is set to 'slow' for higher quality encoding, and the audio bitrate is set to 128 kbps.

    If the input and output filenames don't contain spaces, quotation marks or other special characters:

    ```
    ffmpeg -i input.webm -c:v libx264 -preset slow -crf 22 -c:a aac -b:a 128k output.mp4
    ```

    # Or escape spaces using backslashes
    Or escape spaces using backslashes

    ```
    ffmpeg -i input\ with\ spaces.webm -c:v libx264 -preset slow -crf 22 -c:a aac -b:a 128k output\ with\ spaces.mp4
    ```

    # Or use quotation marks in any other cases:
    Or use quotation marks in any other cases:

    ```
    ffmpeg -i "input with spaces.webm" -c:v libx264 -preset slow -crf 22 -c:a aac -b:a 128k "output with spaces.mp4"
    ```

    # Explanation:
    # -i input.webm: Specifies the input WebM file (use quotes or backslashes for spaces).
    # -c:v libx264: Uses the libx264 encoder for video (widely compatible).
    # -preset slow: Prioritizes quality over speed (consider 'medium' for faster encodes).
    # -crf 22: Sets Constant Rate Factor (lower values mean higher quality, typically 18-28 is good).
    # -c:a aac: Encodes audio with AAC (common and efficient).
    # -b:a 128k: Sets audio bitrate to 128 kbps (adjust based on needs).
    # output.mp4: Names the output MP4 file (use quotes or backslashes for spaces).
    ## Explanation:
    -i input.webm: Specifies the input WebM file (use quotes or backslashes for spaces).
    -c:v libx264: Uses the libx264 encoder for video (widely compatible).
    -preset slow: Prioritizes quality over speed (consider 'medium' for faster encodes).
    -crf 22: Sets Constant Rate Factor (lower values mean higher quality, typically 18-28 is good).
    -c:a aac: Encodes audio with AAC (common and efficient).
    -b:a 128k: Sets audio bitrate to 128 kbps (adjust based on needs).
    output.mp4: Names the output MP4 file (use quotes or backslashes for spaces).

    # Alternatives & common values:
    ## Alternatives & common values:

    # Video codec alternative to libx264:
    # - libx265 (for even better compression, but may require more processing power)
    Video codec alternative to libx264:
    - libx265 (for even better compression, but may require more processing power)

    # Audio codec alternative to AAC and common bitrates:
    # - libopus (modern, efficient codec)
    # - Common bitrates: 64k, 96k, 128k (for music), or even lower for speech-only content
    # - mp3 (widely supported, but less efficient than AAC or Opus)
    # - Common bitrates: 128k, 192k, 256k
    Audio codec alternative to AAC and common bitrates:
    - libopus (modern, efficient codec) at 64k, 96k, 128k (for music), or even lower for speech-only content
    - mp3 (widely supported, but less efficient than AAC or Opus) at 128k, 192k, 256k

    # Potential enhancements:
    ## Potential enhancements:

    # 1. Copying metadata:
    ### 1. Copying metadata:
    ```
    ffmpeg -i "input with spaces.webm" -c:v libx264 -preset slow -crf 22 -c:a aac -b:a 128k -map_metadata 0 "output with spaces.mp4"
    ```

    # 2. Scaling video (if needed):
    ### 2. Scaling video (if needed):
    ```
    # ffmpeg -i "input with spaces.webm" -vf scale=1280:-2 -c:v libx264 ...
    ```

    # 3. Hardware acceleration (if available):
    ### 3. Hardware acceleration (if available):
    ```
    # ffmpeg -hwaccel auto -i "input with spaces.webm" ...
    ```

    # 4. Two-pass encoding (for even better quality, but slower):
    ### 4. Two-pass encoding (for even better quality, but slower):
    ```
    # ffmpeg -i "input with spaces.webm" -c:v libx264 -preset slow -crf 22 -pass 1 -f mp4 /dev/null
    # ffmpeg -i "input with spaces.webm" -c:v libx264 -preset slow -crf 22 -pass 2 "output with spaces.mp4"
    ```

    # Remember:
    # - Experiment with CRF and audio bitrate for your specific needs.
    # - Consider hardware acceleration for faster encodes on supported systems.
    # - Two-pass encoding offers the best quality but takes longer.
    Remember:
    - Experiment with CRF and audio bitrate for your specific needs.
    - Consider hardware acceleration for faster encodes on supported systems.
    - Two-pass encoding offers the best quality but takes longer.
  2. @maximebories maximebories revised this gist Sep 9, 2024. 1 changed file with 63 additions and 1 deletion.
    64 changes: 63 additions & 1 deletion convert.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,67 @@
    This ffmpeg command converts a .webm video file to a standard .mp4 file using the libx264 codec for video, aac codec for audio, and a CRF value of 22. The preset is set to 'slow' for higher quality encoding, and the audio bitrate is set to 128 kbps.

    # If the input and output filenames don't contain spaces, quotation marks or other special characters:

    ```
    ffmpeg -i input.webm -c:v libx264 -preset slow -crf 22 -c:a aac -b:a 128k output.mp4
    ```

    This ffmpeg command converts a .webm video file to a standard .mp4 file using the libx264 codec for video, aac codec for audio, and a CRF value of 22. The preset is set to 'slow' for higher quality encoding, and the audio bitrate is set to 128 kbps.
    # Or escape spaces using backslashes

    ```
    ffmpeg -i input\ with\ spaces.webm -c:v libx264 -preset slow -crf 22 -c:a aac -b:a 128k output\ with\ spaces.mp4
    ```

    # Or use quotation marks in any other cases:

    ```
    ffmpeg -i "input with spaces.webm" -c:v libx264 -preset slow -crf 22 -c:a aac -b:a 128k "output with spaces.mp4"
    ```

    # Explanation:
    # -i input.webm: Specifies the input WebM file (use quotes or backslashes for spaces).
    # -c:v libx264: Uses the libx264 encoder for video (widely compatible).
    # -preset slow: Prioritizes quality over speed (consider 'medium' for faster encodes).
    # -crf 22: Sets Constant Rate Factor (lower values mean higher quality, typically 18-28 is good).
    # -c:a aac: Encodes audio with AAC (common and efficient).
    # -b:a 128k: Sets audio bitrate to 128 kbps (adjust based on needs).
    # output.mp4: Names the output MP4 file (use quotes or backslashes for spaces).

    # Alternatives & common values:

    # Video codec alternative to libx264:
    # - libx265 (for even better compression, but may require more processing power)

    # Audio codec alternative to AAC and common bitrates:
    # - libopus (modern, efficient codec)
    # - Common bitrates: 64k, 96k, 128k (for music), or even lower for speech-only content
    # - mp3 (widely supported, but less efficient than AAC or Opus)
    # - Common bitrates: 128k, 192k, 256k

    # Potential enhancements:

    # 1. Copying metadata:
    ```
    ffmpeg -i "input with spaces.webm" -c:v libx264 -preset slow -crf 22 -c:a aac -b:a 128k -map_metadata 0 "output with spaces.mp4"
    ```

    # 2. Scaling video (if needed):
    ```
    # ffmpeg -i "input with spaces.webm" -vf scale=1280:-2 -c:v libx264 ...
    ```

    # 3. Hardware acceleration (if available):
    ```
    # ffmpeg -hwaccel auto -i "input with spaces.webm" ...
    ```

    # 4. Two-pass encoding (for even better quality, but slower):
    ```
    # ffmpeg -i "input with spaces.webm" -c:v libx264 -preset slow -crf 22 -pass 1 -f mp4 /dev/null
    # ffmpeg -i "input with spaces.webm" -c:v libx264 -preset slow -crf 22 -pass 2 "output with spaces.mp4"
    ```

    # Remember:
    # - Experiment with CRF and audio bitrate for your specific needs.
    # - Consider hardware acceleration for faster encodes on supported systems.
    # - Two-pass encoding offers the best quality but takes longer.
  3. @maximebories maximebories revised this gist Mar 30, 2023. 1 changed file with 4 additions and 18 deletions.
    22 changes: 4 additions & 18 deletions convert.md
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,5 @@
    <!--
    Copyright (C) 2023 Maxime Bories
    This file is part of maximebories.github.io.
    maximebories.github.io is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    maximebories.github.io is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.
    You should have received a copy of the GNU General Public License
    along with maximebories.github.io. If not, see <http://www.gnu.org/licenses/>.
    -->
    ```
    ffmpeg -i input.webm -c:v libx264 -preset slow -crf 22 -c:a aac -b:a 128k output.mp4
    ```

    This ffmpeg command converts a .webm video file to a standard .mp4 file using the libx264 codec for video, aac codec for audio, and a CRF value of 22. The preset is set to 'slow' for higher quality encoding, and the audio bitrate is set to 128 kbps.
  4. @maximebories maximebories revised this gist Mar 30, 2023. 1 changed file with 19 additions and 1 deletion.
    20 changes: 19 additions & 1 deletion convert.md
    Original file line number Diff line number Diff line change
    @@ -1 +1,19 @@
    ‎‎​
    <!--
    Copyright (C) 2023 Maxime Bories
    This file is part of maximebories.github.io.
    maximebories.github.io is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    maximebories.github.io is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.
    You should have received a copy of the GNU General Public License
    along with maximebories.github.io. If not, see <http://www.gnu.org/licenses/>.
    -->

  5. @maximebories maximebories revised this gist Mar 30, 2023. 1 changed file with 1 addition and 19 deletions.
    20 changes: 1 addition & 19 deletions convert.md
    Original file line number Diff line number Diff line change
    @@ -1,19 +1 @@
    <!--
    Copyright (C) 2023 Maxime Bories
    This file is part of maximebories.github.io.
    maximebories.github.io is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    maximebories.github.io is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.
    You should have received a copy of the GNU General Public License
    along with maximebories.github.io. If not, see <http://www.gnu.org/licenses/>.
    -->

    ‎‎​
  6. @maximebories maximebories revised this gist Mar 30, 2023. 1 changed file with 19 additions and 1 deletion.
    20 changes: 19 additions & 1 deletion convert.md
    Original file line number Diff line number Diff line change
    @@ -1 +1,19 @@
    ‎‎​
    <!--
    Copyright (C) 2023 Maxime Bories
    This file is part of maximebories.github.io.
    maximebories.github.io is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    maximebories.github.io is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.
    You should have received a copy of the GNU General Public License
    along with maximebories.github.io. If not, see <http://www.gnu.org/licenses/>.
    -->

  7. @maximebories maximebories created this gist Mar 30, 2023.
    1 change: 1 addition & 0 deletions convert.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    ‎‎​