Forked from jamesmacwhite/ffmpeg_mkv_mp4_conversion.md
Created
March 24, 2024 08:03
-
-
Save ThorsAngerVaNeT/00e2ce7e7529e11ac18cf952e1839c70 to your computer and use it in GitHub Desktop.
Revisions
-
jamesmacwhite revised this gist
Mar 5, 2018 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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" ``` `/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. -
jamesmacwhite revised this gist
Feb 22, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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" ``` `/R` is used to recursively search within sub directories at the target location. -
jamesmacwhite revised this gist
Feb 22, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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" ``` `/R` is used to recursively search within sub directories at the target location. -
jamesmacwhite revised this gist
Jan 30, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 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. -
jamesmacwhite revised this gist
Jan 25, 2018 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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. 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 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: -
jamesmacwhite revised this gist
Jan 25, 2018 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 /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. -
jamesmacwhite revised this gist
Oct 11, 2017 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # 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: ``` 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" -
jamesmacwhite revised this gist
Oct 11, 2017 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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. 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 ``` ### 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. ##### Unix one-liner example i.e. MacOS/Linux -
jamesmacwhite revised this gist
Oct 11, 2017 . 1 changed file with 16 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,23 +1,32 @@ # 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. 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 ``` ### Batch file 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. ##### 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 ``` for %f IN (*.mkv) DO ffmpeg -i "%f" -c copy "%~nf.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. -
jamesmacwhite revised this gist
Oct 11, 2017 . 1 changed file with 8 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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. 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) 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 ``` -
jamesmacwhite revised this gist
Oct 11, 2017 . 2 changed files with 17 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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" ``` This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,13 +0,0 @@ -
jamesmacwhite revised this gist
Oct 10, 2017 . 1 changed file with 5 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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, 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" -
jamesmacwhite renamed this gist
Aug 16, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jamesmacwhite created this gist
Aug 16, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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)