Created
December 17, 2013 21:07
-
-
Save shvechikov/8012638 to your computer and use it in GitHub Desktop.
Mux Youtube DASH audio and video
This file contains 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 characters
from __future__ import unicode_literals | |
import sys | |
from sh import ffmpeg | |
from unipath import Path | |
_, src_dir, dest_dir = sys.argv | |
src_dir = Path(src_dir) | |
dest_dir = Path(dest_dir) | |
if not dest_dir.exists(): | |
dest_dir.mkdir() | |
m4a = set(f.stem for f in src_dir.listdir('*.m4a')) | |
mp4 = set(f.stem for f in src_dir.listdir('*.mp4')) | |
both = sorted(m4a & mp4) | |
for basename in both: | |
source_video = src_dir + basename + '.mp4' | |
source_audio = src_dir + basename + '.m4a' | |
destination = dest_dir + basename + '.480.mp4' | |
if source_audio.exists() and source_video.exists(): | |
if destination.exists(): | |
print destination, 'already muxed!' | |
else: | |
print destination, 'running ffmpeg...' | |
ffmpeg( | |
'-i', source_video, | |
'-i', source_audio, | |
'-vcodec', 'copy', | |
'-acodec', 'copy', | |
destination, | |
) | |
print 'OK' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment