python-ffmpeg icon indicating copy to clipboard operation
python-ffmpeg copied to clipboard

Not working for Audio Video Muxing

Open dipanjal opened this issue 6 months ago • 1 comments

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

dipanjal avatar Jul 30 '25 08:07 dipanjal

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

marazmiki avatar Sep 25 '25 15:09 marazmiki