python-ffmpeg
python-ffmpeg copied to clipboard
Not working for Audio Video Muxing
This is a raw ffmpeg command for muxing audio and video
ffmpeg -i temp.mp4 \
-i temp.m4a \
-c:v copy -c:a aac -map 0:v:0 -map 1:a:0 \
output.mp4
But I can't find any hint or support in your python API
ffmpeg = (
FFmpeg()
.option("y")
.input(str(temp_video_path))
.input(str(temp_audio_path))
.output(
str(output_path),
{"c:v": "copy", "c:a": "aac", "map 0:v": "0", "map 1:a": "0"},
)
)
Error:
Traceback (most recent call last):
File "/projects/python/muxer/.venv/lib/python3.11/site-packages/ffmpeg/asyncio/ffmpeg.py", line 208, in execute
raise FFmpegError.create(message=tasks[2].result(), arguments=self.arguments)
ffmpeg.errors.FFmpegInvalidCommand: Error splitting the argument list: Option not found
Try to pass map as a list of arguments, like that:
>>> from ffmpeg import FFmpeg
>>> temp_video_path = "temp.mp4"
>>> temp_audio_path = "temp.m4a"
>>> output_path = "output.mp4"
>>>
>>>
>>> ffmpeg = (
... FFmpeg()
... .option("y")
... .input(str(temp_video_path))
... .input(str(temp_audio_path))
... .output(
... str(output_path),
... {"c:v": "copy", "c:a": "aac", "map": ["0:v:0", "1:a:0"]},
... )
... )
>>>
>>> print(" ".join(ffmpeg.arguments))
ffmpeg -y -i temp.mp4 -i temp.m4a -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 output.mp4