Difference between revisions of "FFmpeg"

From Jesse's Wiki
Jump to navigation Jump to search
(init)
 
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
.MKVs are popular video files. Unfortunately they will not play on Apple devices. This is silly because the video streams often inside of the MKV container is actually h.264 which is playable on iPhone. Some software will convert these easily, but will take forever and quality is lost.
I use FFmpeg to remux .mkv [[Video containers|video files]] to .mp4 so that they will play with a broader range of devices without further conversion. All of the movies on my NAS as .mp4 or .m4v files.
I use FFmpeg to remux .mkv [[Video containers|video files]] to .mp4 so that they will play with a broader range of devices without further conversion. All of the movies on my NAS as .mp4 or .m4v files.


=== Windows Command Prompt ===
=== Windows Command Prompt ===
Remux all the .mkv files in a folder, stripping the metadata.<syntaxhighlight lang="bash">
Remux all the .mkv files in a folder, stripping the metadata.
for %i in (*.mkv) do ffmpeg -i "%i" -c:v copy -c:a copy -map_metadata -1 "%~ni.mp4"
for %i in (*.mkv) do ffmpeg -i "%i" -c:v copy -c:a copy -map_metadata -1 "%~ni.mp4"
</syntaxhighlight>Same as above, but converting the audio to AAC
Same as above, but converting the audio to AAC
  for %i in (*.mkv) do ffmpeg -i "%i" -c:v copy -c:a aac -map_metadata -1 "%~ni.mp4"
  for %i in (*.mkv) do ffmpeg -i "%i" -c:v copy -c:a aac -map_metadata -1 "%~ni.mp4"
Same as above, but converting to 2 channels (stereo)
for %i in (*.mkv) do ffmpeg -i "%i" -c:v copy -c:a aac -ac 2 -map_metadata -1 "%~ni.mp4"
=== Unix shell (Synology) ===
Remux all the .mkv files in a folder, stripping the metadata.
for i in *.mkv; do ./ffmpeg -i "$i" -c:v copy -c:a copy -map_metadata -1 "${i%.*}".mp4; done
Same as above, but converting the audio to AAC
for i in *.mkv; do ./ffmpeg -i "$i" -c:v copy -c:a aac -map_metadata -1 "${i%.*}".mp4; done

Latest revision as of 21:03, 21 February 2022

.MKVs are popular video files. Unfortunately they will not play on Apple devices. This is silly because the video streams often inside of the MKV container is actually h.264 which is playable on iPhone. Some software will convert these easily, but will take forever and quality is lost.

I use FFmpeg to remux .mkv video files to .mp4 so that they will play with a broader range of devices without further conversion. All of the movies on my NAS as .mp4 or .m4v files.

Windows Command Prompt

Remux all the .mkv files in a folder, stripping the metadata.

for %i in (*.mkv) do ffmpeg -i "%i" -c:v copy -c:a copy -map_metadata -1 "%~ni.mp4"

Same as above, but converting the audio to AAC

for %i in (*.mkv) do ffmpeg -i "%i" -c:v copy -c:a aac -map_metadata -1 "%~ni.mp4"

Same as above, but converting to 2 channels (stereo)

for %i in (*.mkv) do ffmpeg -i "%i" -c:v copy -c:a aac -ac 2 -map_metadata -1 "%~ni.mp4"

Unix shell (Synology)

Remux all the .mkv files in a folder, stripping the metadata.

for i in *.mkv; do ./ffmpeg -i "$i" -c:v copy -c:a copy -map_metadata -1 "${i%.*}".mp4; done

Same as above, but converting the audio to AAC

for i in *.mkv; do ./ffmpeg -i "$i" -c:v copy -c:a aac -map_metadata -1 "${i%.*}".mp4; done