Skip to main content

Make videos with double audio

Project description

Dual-audio video maker

You can pass 2 playlists (or 2 lists with playlists), first for extracting audio (audio-playlists), second for resulting video (video-playlists), and get video with both audio tracks. For the first playlists it is better to use low quality video.

Dependencies

You need installed in system ffmpeg (work with media), wget (download) and grep utilities.

Install

pip install dual-audio

Usage example

Extract audios from video files from audio-playlist.m3u and add to related videos from video-playlist.m3u (for example, 1x1.aac will be added to 1x1.mp4).

dual-audio --out-dir . -a audio-playlist.m3u -v video-playlist.m3u

Number of entries in both audio and video playlists should be equal.

After downloading and converting, you may also want to specify a language for each audio track. Create a file with filenames to do this mapping, e.g. list.txt (or use finished.txt), then if the first audio track is russian and the second is english, run:

dual-audio \
	--fix-audio-lang \
	--fix-audio-lang-list list.txt \
	--first-audio-lang rus \
	--second-audio-lang eng

First track from video playlist, second from audio playlist.

CLI arguments

Argument Action
-d, --out-dir Directory where place audio and video folders
-a, --audio-playlists Path(s) to playlist(s) with videos from which extract audio
-v, --video-playlists Path(s) to playlist(s) with videos to add a second audio
--args Pass shell arguments via file
--preserve-video Preserving original videos from video-playlists
-h, --help Show help message and exit
--fix-audio-lang Fix audio tracks language metadata 1
--fix-audio-lang-list File with list of filenames to fix language
--first-audio-lang Language in first audio track (from video file) 2
--second-audio-lang Language in second audio track (from extracted audio)

1 If specified, downloading and converting will not be performed.

2 Language is 3-letter identifier like "eng" or "rus".

Shortened M3U playlist syntax

You can write playlists manually by this template:

#EXTM3U
#EXTINF: <duration>,<title>
#EXTVLCOPT:
<link>
  • #EXTM3U is the required header for the file,
  • duration can be zero,
  • the title must not contain commas,
  • the link should be on a separate line,
  • other lines and directives are ignored and can be omitted.

For example:

#EXTM3U
#EXTINF: 0,Your show - episode 1
http://example.com/1x1.mp4
#EXTINF: 0,Your show - episode 2
http://example.com/1x2.mp4

These videos will be saved as Your show - episode 1.mp4 and Your show - episode 2.mp4.

How it works

  1. Parse playlists.

  2. Download audio-playlists. For each playlist:

    • Download videos to video-cache folder,
    • Extract audio to audio folder and select extension based on ffprobe (from ffmpeg) output,

    For example, from the Stream #0:0: Audio: aac (LC), 48000 Hz, stereo, fltp, 94 kb/s line will be taken aac.

  3. For each playlist from video-playlists download videos to video/ folder.

  4. Correlate audio and video file names (for example, 1x1.aac will be added to 1x1.mp4).

  5. Join audios and videos and save to video-result folder.

  6. If --preserve-video is not passed, move resulting videos to video folder.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dual-audio-1.1.tar.gz (8.2 kB view hashes)

Uploaded Source

Built Distribution

dual_audio-1.1-py3-none-any.whl (8.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page