Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ThorsAngerVaNeT/00e2ce7e7529e11ac18cf952e1839c70 to your computer and use it in GitHub Desktop.
Save ThorsAngerVaNeT/00e2ce7e7529e11ac18cf952e1839c70 to your computer and use it in GitHub Desktop.

Revisions

  1. @jamesmacwhite jamesmacwhite revised this gist Mar 5, 2018. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion ffmpeg_mkv_mp4_conversion.md
    Original file line number Diff line number Diff line change
    @@ -26,9 +26,11 @@ for f in *.mkv; do ffmpeg -i "$f" -c copy "${f%.mkv}.mp4"; done
    ##### Windows one-liner example:

    ```
    for /R %%f IN (*.mkv) DO ffmpeg -i "%%f" -c copy "%~nf.mp4"
    for /R %f IN (*.mkv) DO ffmpeg -i "%f" -c copy "%~nf.mp4"
    ```

    `/R` is used to recursively search within sub directories at the target location.

    If running within a batch script, you will need to double the percentage signs `%%` in order for the command to run properly.

    In both examples, the original .mkv extension is removed from the final output to avoid the filename ending up as `example.mkv.mp4` which would be a bit weird, although harmless.
  2. @jamesmacwhite jamesmacwhite revised this gist Feb 22, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ffmpeg_mkv_mp4_conversion.md
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,7 @@ for f in *.mkv; do ffmpeg -i "$f" -c copy "${f%.mkv}.mp4"; done
    ##### Windows one-liner example:

    ```
    for /R %%f IN (*.mkv) DO ffmpeg -i "%f" -c copy "%~nf.mp4"
    for /R %%f IN (*.mkv) DO ffmpeg -i "%%f" -c copy "%~nf.mp4"
    ```

    `/R` is used to recursively search within sub directories at the target location.
  3. @jamesmacwhite jamesmacwhite revised this gist Feb 22, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ffmpeg_mkv_mp4_conversion.md
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,7 @@ for f in *.mkv; do ffmpeg -i "$f" -c copy "${f%.mkv}.mp4"; done
    ##### Windows one-liner example:

    ```
    for /R %f IN (*.mkv) DO ffmpeg -i "%f" -c copy "%~nf.mp4"
    for /R %%f IN (*.mkv) DO ffmpeg -i "%f" -c copy "%~nf.mp4"
    ```

    `/R` is used to recursively search within sub directories at the target location.
  4. @jamesmacwhite jamesmacwhite revised this gist Jan 30, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ffmpeg_mkv_mp4_conversion.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    # Converting mkv to mp4 with `ffmpeg`
    ##### Essentially just copy the existing video and audio stream as is into a new container, no funny business!

    The easiest way to "convert" MKV to MP4, is to copy the existing video and audio streams and place them into a new container. This avoids any encoding task and hence no quality will be lost, it is also a fairly quick process and requires very little CPU power.
    The easiest way to "convert" MKV to MP4, is to copy the existing video and audio streams and place them into a new container. This avoids any encoding task and hence no quality will be lost, it is also a fairly quick process and requires very little CPU power. The main factor is disk read/write speed.

    With `ffmpeg` this can be achieved with `-c copy`. Older examples may use `-vcodec copy -acodec copy` which does the same thing.

  5. @jamesmacwhite jamesmacwhite revised this gist Jan 25, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions ffmpeg_mkv_mp4_conversion.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    # Converting mkv to mp4 with `ffmpeg`
    ##### Essentially just copy the existing video and audio stream as is into a new container, no funny business!

    The easiest way to switch MKV to MP4, is to copy the existing video and audio streams and place them into a new container. This avoids any encoding task and hence no quality will be lost.
    The easiest way to "convert" MKV to MP4, is to copy the existing video and audio streams and place them into a new container. This avoids any encoding task and hence no quality will be lost, it is also a fairly quick process and requires very little CPU power.

    With `ffmpeg` this can be achieved with `-c copy`. Older examples may use `-vcodec copy -acodec copy` which does the same thing.

    @@ -15,7 +15,7 @@ ffmpeg -i example.mkv -c copy example.mp4

    ### Batch conversion example

    If you want to batch convert multiple MKV files, you can switch into the directory and run the following, depending on OS. This can be run directly from command line. All MKV files found in the directory will be converted with their original filename.
    If you want to batch convert multiple MKV files, you can switch into the directory that contains MKV files and run the following, depending on OS. This can be run directly from command line. All MKV files found in the directory will be converted with their original filename.

    ##### Unix one-liner example i.e. MacOS/Linux:

  6. @jamesmacwhite jamesmacwhite revised this gist Jan 25, 2018. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion ffmpeg_mkv_mp4_conversion.md
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,9 @@ for f in *.mkv; do ffmpeg -i "$f" -c copy "${f%.mkv}.mp4"; done
    ##### Windows one-liner example:

    ```
    for %f IN (*.mkv) DO ffmpeg -i "%f" -c copy "%~nf.mp4"
    for /R %f IN (*.mkv) DO ffmpeg -i "%f" -c copy "%~nf.mp4"
    ```

    `/R` is used to recursively search within sub directories at the target location.

    In both examples, the original .mkv extension is removed from the final output to avoid the filename ending up as `example.mkv.mp4` which would be a bit weird, although harmless.
  7. @jamesmacwhite jamesmacwhite revised this gist Oct 11, 2017. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions ffmpeg_mkv_mp4_conversion.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Converting mkv to mp4 with ffmpeg
    # Converting mkv to mp4 with `ffmpeg`
    ##### Essentially just copy the existing video and audio stream as is into a new container, no funny business!

    The easiest way to switch MKV to MP4, is to copy the existing video and audio streams and place them into a new container. This avoids any encoding task and hence no quality will be lost.
    @@ -17,13 +17,13 @@ ffmpeg -i example.mkv -c copy example.mp4

    If you want to batch convert multiple MKV files, you can switch into the directory and run the following, depending on OS. This can be run directly from command line. All MKV files found in the directory will be converted with their original filename.

    ##### Unix one-liner example i.e. MacOS/Linux
    ##### Unix one-liner example i.e. MacOS/Linux:

    ```
    for f in *.mkv; do ffmpeg -i "$f" -c copy "${f%.mkv}.mp4"; done
    ```

    ##### Windows one-liner example
    ##### Windows one-liner example:

    ```
    for %f IN (*.mkv) DO ffmpeg -i "%f" -c copy "%~nf.mp4"
  8. @jamesmacwhite jamesmacwhite revised this gist Oct 11, 2017. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions ffmpeg_mkv_mp4_conversion.md
    Original file line number Diff line number Diff line change
    @@ -1,21 +1,21 @@
    # Converting mkv to mp4 with ffmpeg
    ##### Essentially just copy the existing video and audio stream as is into a new container, no funny business!

    The easiest way to switch MKV to MP4, is to copy the existing video and audio streams and place them into a new container. This avoids any encoding task and hence no quality will be lost. The "conversion" is also fairly quick and isn't CPU intensitive.
    The easiest way to switch MKV to MP4, is to copy the existing video and audio streams and place them into a new container. This avoids any encoding task and hence no quality will be lost.

    With `ffmpeg` this can be achieved with `-c copy`. Older examples may use `-vcodec copy -acodec copy` which does the same thing.

    These examples assume ffmpeg is in your `PATH`. If not just substitute with the full path to your ffmpeg binary.
    These examples assume `ffmpeg` is in your `PATH`. If not just substitute with the full path to your ffmpeg binary.

    ### Single file conversion example

    ```
    ffmpeg -i example.mkv -c copy example.mp4
    ```

    ### Batch file conversion example
    ### Batch conversion example

    If you want to batch convert multiple MKV files, you can switch into the directory and run the following, depending on OS. This can be run directly from command line.
    If you want to batch convert multiple MKV files, you can switch into the directory and run the following, depending on OS. This can be run directly from command line. All MKV files found in the directory will be converted with their original filename.

    ##### Unix one-liner example i.e. MacOS/Linux

  9. @jamesmacwhite jamesmacwhite revised this gist Oct 11, 2017. 1 changed file with 16 additions and 7 deletions.
    23 changes: 16 additions & 7 deletions ffmpeg_mkv_mp4_conversion.md
    Original file line number Diff line number Diff line change
    @@ -1,23 +1,32 @@
    # Converting mkv to mp4 with ffmpeg
    ##### Basically just copy video and audio stream as is into a new container, no funny business.
    ##### Essentially just copy the existing video and audio stream as is into a new container, no funny business!

    The easiest way to switch MKV to MP4, is to copy the existing video and audio streams and place into a new container. This avoids any encoding and hence no quality will be lost.
    The easiest way to switch MKV to MP4, is to copy the existing video and audio streams and place them into a new container. This avoids any encoding task and hence no quality will be lost. The "conversion" is also fairly quick and isn't CPU intensitive.

    With `ffmpeg` this can be achieved with `-c copy`. Older examples may use `-vcodec copy -acodec copy` which does the same thing.

    These examples assume ffmpeg is in your `PATH`. If not just substitute with the full path to your ffmpeg binary.

    ### Single file conversion example

    ```
    ffmpeg -i example.mkv -c copy example.mp4
    ```

    ### Multiple file conversion (cd into directory containing mkv files and run the following)
    ### Batch file conversion example

    If you want to batch convert multiple MKV files, you can switch into the directory and run the following:
    If you want to batch convert multiple MKV files, you can switch into the directory and run the following, depending on OS. This can be run directly from command line.

    ##### Unix one-liner example i.e. MacOS/Linux

    ```
    for i in *mkv; do ffmpeg -i "$i" -c copy "${i%.mkv}.mp4"; done
    for f in *.mkv; do ffmpeg -i "$f" -c copy "${f%.mkv}.mp4"; done
    ```

    ##### Windows one-liner example

    ```
    for %f IN (*.mkv) DO ffmpeg -i "%f" -c copy "%~nf.mp4"
    ```
    for %i IN (*.mkv) DO ffmpeg -i "%i" -c copy "%i.mp4"
    ```

    In both examples, the original .mkv extension is removed from the final output to avoid the filename ending up as `example.mkv.mp4` which would be a bit weird, although harmless.
  10. @jamesmacwhite jamesmacwhite revised this gist Oct 11, 2017. 1 changed file with 8 additions and 2 deletions.
    10 changes: 8 additions & 2 deletions ffmpeg_mkv_mp4_conversion.md
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,18 @@
    # Converting mkv to mp4 with ffmpeg
    ##### Basically just copy video and audio stream as is into a new container, no funny business
    ##### Basically just copy video and audio stream as is into a new container, no funny business.

    The easiest way to switch MKV to MP4, is to copy the existing video and audio streams and place into a new container. This avoids any encoding and hence no quality will be lost.

    ### Single file conversion example
    ```
    ffmpeg -i example.mkv -c copy example.mp4
    ```

    ### Multiple file conversion (cd into directory containing mkv files and run the following)

    ##### Unix one-liner example
    If you want to batch convert multiple MKV files, you can switch into the directory and run the following:

    ##### Unix one-liner example i.e. MacOS/Linux
    ```
    for i in *mkv; do ffmpeg -i "$i" -c copy "${i%.mkv}.mp4"; done
    ```
  11. @jamesmacwhite jamesmacwhite revised this gist Oct 11, 2017. 2 changed files with 17 additions and 13 deletions.
    17 changes: 17 additions & 0 deletions ffmpeg_mkv_mp4_conversion.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    # Converting mkv to mp4 with ffmpeg
    ##### Basically just copy video and audio stream as is into a new container, no funny business

    ### Single file conversion example
    ffmpeg -i example.mkv -c copy example.mp4

    ### Multiple file conversion (cd into directory containing mkv files and run the following)

    ##### Unix one-liner example
    ```
    for i in *mkv; do ffmpeg -i "$i" -c copy "${i%.mkv}.mp4"; done
    ```

    ##### Windows one-liner example
    ```
    for %i IN (*.mkv) DO ffmpeg -i "%i" -c copy "%i.mp4"
    ```
    13 changes: 0 additions & 13 deletions ffmpeg_mkv_mp4_conversion.sh
    Original file line number Diff line number Diff line change
    @@ -1,13 +0,0 @@
    # Converting mkv to mp4 with ffmpeg
    # Basically just copy video and audio stream as is into a new container, no funny business

    # Single file conversion example
    ffmpeg -i example.mkv -vcodec copy -acodec copy example.mp4

    # Multiple file conversion (cd into directory containing mkv files and run the following)

    # Unix one-liner example
    for i in *mkv; do ffmpeg -i "$i" -vcodec copy -acodec copy "${i%.mkv}.mp4"; done

    # Windows one-liner example
    for %i IN (*.mkv) DO ffmpeg -i "%i" -vcodec copy -acodec copy "%i.mp4"
  12. @jamesmacwhite jamesmacwhite revised this gist Oct 10, 2017. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions ffmpeg_mkv_mp4_conversion.sh
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,13 @@
    # Converting mkv to mp4 with ffmpeg
    # Basically just copy video and audio stream as is into a new container
    # Basically just copy video and audio stream as is into a new container, no funny business

    # Single file conversion example
    ffmpeg -i example.mkv -vcodec copy -acodec copy example.mp4

    # Multiple file conversion (cd into directory containing mkv files and run the following)

    # Unix one-liner example
    for i in *mkv; do ffmpeg -i "$i" -vcodec copy -acodec copy "${i%.mkv}.mp4"; done

    # $i is quoted for filenames with spaces
    # ${i%.mkv} is used on output, to strip .mkv from filename so you don't get somefile.mkv.mp4 (That would be silly)
    # Windows one-liner example
    for %i IN (*.mkv) DO ffmpeg -i "%i" -vcodec copy -acodec copy "%i.mp4"
  13. @jamesmacwhite jamesmacwhite renamed this gist Aug 16, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  14. @jamesmacwhite jamesmacwhite created this gist Aug 16, 2016.
    11 changes: 11 additions & 0 deletions mkv_mp4_conversion.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    # Converting mkv to mp4 with ffmpeg
    # Basically just copy video and audio stream as is into a new container

    # Single file conversion example
    ffmpeg -i example.mkv -vcodec copy -acodec copy example.mp4

    # Multiple file conversion (cd into directory containing mkv files and run the following)
    for i in *mkv; do ffmpeg -i "$i" -vcodec copy -acodec copy "${i%.mkv}.mp4"; done

    # $i is quoted for filenames with spaces
    # ${i%.mkv} is used on output, to strip .mkv from filename so you don't get somefile.mkv.mp4 (That would be silly)