Skip to content

Instantly share code, notes, and snippets.

@Cougar
Created March 30, 2015 20:21
Show Gist options
  • Save Cougar/0a2656a9fb4d328e57b1 to your computer and use it in GitHub Desktop.
Save Cougar/0a2656a9fb4d328e57b1 to your computer and use it in GitHub Desktop.
Mix audio tracks from two video files with different fps using ffmpeg
Input files are following:
file1.mkv:
Duration: 01:42:13.13, start: 0.000000, bitrate: 3735 kb/s
Stream #0:0(eng): Video: h264 (High), yuv420p, 1920x800 [SAR 1:1 DAR 12:5], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Stream #0:1(eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s (default)
Stream #0:2(kor): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
file2.mpeg:
Duration: 01:37:52.97, start: 0.780000, bitrate: 4153 kb/s
Program 2
Stream #1:0[0x21]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv), 720x576 [SAR 64:45 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #1:1[0x24](est): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 448 kb/s
Stream #1:2[0x25](rus): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 256 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #1:1 -> #0:1 (ac3 (native) -> ac3 (native))
Stream #0:1 -> #0:2 (copy)
Command line:
ffmpeg -i file1.mkv -i file2.mpeg -map 0:v -map 1:a:0 -map 0:a:0 -codec:v copy -codec:a:0 ac3 -vsync 0 -filter:a:0 "atempo=0.959040959" -codec:a:1 copy -metadata:s:a:0 language=est -metadata:s:a:1 language=eng file3.mkv
Output file will be:
Duration: 01:42:13.21, start: 0.078000, bitrate: 3994 kb/s
Stream #0:0(eng): Video: h264 (High), yuv420p, 1920x800 [SAR 1:1 DAR 12:5], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Metadata:
LANGUAGE : eng
Stream #0:1(est): Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s
Metadata:
LANGUAGE : est
Stream #0:2(eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s (default)
Metadata:
LANGUAGE : eng
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment