From ArchWiki
Jump to navigation Jump to search

have a video with one language track, and add another language, contained in a different video. first make the two videos same length with an editor like avidemux. then extract the audio of one of the videos. then add the extracted audio to the other video:

 fmpeg -i orig-deu.mkv -vn -acodec copy audio-deu.mkv
 ffmpeg -i orig.mkv -i audio-deu.mkv -map 0 -map 1 -c copy result.mkv

extract audio only, video only, and create video with two language tracks:

ffmpeg -i orig.mp4 -vn -acodec copy fra.aac
ffmpeg -i orig.mp4 -c copy -an video.mp4
ffmpeg -i video.mp4 -i deu.aac -i fra.aac -map 0 -map 1 -map 2 -metadata:s:a:0 language=deu -metadata:s:a:1 language=fra -codec copy result.mp4

pause and resume does not work, so split in 5 minutes pieces, process, rejoin, see here. when extracting audio tracks do so into a container like m4a to not loose timestamp gaps.

ffmpeg -i orig.mp4 -c copy -flags +global_header -segment_time 300 -f segment part%03d.mp4
for name in part*; do
  nice -n 20 ffmpeg -i "$name" -c:v libx264 -c:a ac3 "${name%.*}.mp4"; done
ffmpeg -i orig.mp4 -vn -acodec copy aud_only.m4a
ffmpeg -i orig.mp4 -vn -map 0:a:0 -c copy a1.wav -map 0:a:1 -c copy a2.wav -map 0:a:2 -c copy a3.wav -map 0:a:3 -c copy a4.wav -map 0:a:4 -c copy a5.wav -map 0:a:5 -c copy a6.wav -map 0:a:6 -c copy a7.wav


from some video codec into h264, or av1, copy audio, use default crf 23:

ffmpeg -i in.mkv -vcodec av1 -acodec copy out.mkv