如何在ffmpeg-python中使用多个地图值?
How to use multiple map values in ffmpeg-python?
如何在 ffmpeg-python 中为不同的分辨率使用多个地图值?
-map [v1out] -c:v:0 libx264 -b:v:0 1900k -bufsize 3800k \
-map [v2out] -c:v:1 libx264 -b:v:0 900k -bufsize 1800k \
您可以在 ffmpeg-python 中提供多个地图值,例如:
ffmpeg.input('in.mp4').output(
...
map = [
"[v1out] -c:v:0 libx264 -b:v:0 1900k -bufsize 3800k",
"[v2out] -c:v:1 libx264 -b:v:0 900k -bufsize 1800k"
]
)
您可以尝试这样的操作:
import ffmpeg
input_file = 'input.mp4'
output_file = 'output.mp4'
subtitles_file = 'subtitles.srt'
# Load the video/audio master.
input_ffmpeg = ffmpeg.input(input_file)
# Load the subtitle master.
input_ffmpeg_sub = ffmpeg.input(subtitles_file)
# Refer to the master audio, video and subtitles streams separately.
input_video = input_ffmpeg['v']
input_audio = input_ffmpeg['a']
input_subtitles = input_ffmpeg_sub['s']
output_ffmpeg = ffmpeg.output(
input_video, input_audio, input_subtitles, output_file,
vcodec='copy', acodec='copy', scodec='mov_text'
)
# If the destination file already exists, overwrite it.
output_ffmpeg = ffmpeg.overwrite_output(output_ffmpeg)
# Print the equivalent ffmpeg command we could run to perform the same action as above.
print(ffmpeg.compile(output_ffmpeg))
# Do it! transcode!
ffmpeg.run(output_ffmpeg)
这是等效的 ffmpeg 命令:
ffmpeg -i input.mp4 -i subtitles.srt -map 0:v -map 0:a -map 1:s -acodec copy -vcodec copy -scodec mov_text output.mp4 -y
或
ffmpeg -i input.mp4 -i subtitles.srt -map 0:v -map 0:a -map 1:s -c:a copy -c:v copy -c:s mov_text output.mp4 -y
希望对你有帮助,对我有用。
如何在 ffmpeg-python 中为不同的分辨率使用多个地图值?
-map [v1out] -c:v:0 libx264 -b:v:0 1900k -bufsize 3800k \
-map [v2out] -c:v:1 libx264 -b:v:0 900k -bufsize 1800k \
您可以在 ffmpeg-python 中提供多个地图值,例如:
ffmpeg.input('in.mp4').output(
...
map = [
"[v1out] -c:v:0 libx264 -b:v:0 1900k -bufsize 3800k",
"[v2out] -c:v:1 libx264 -b:v:0 900k -bufsize 1800k"
]
)
您可以尝试这样的操作:
import ffmpeg
input_file = 'input.mp4'
output_file = 'output.mp4'
subtitles_file = 'subtitles.srt'
# Load the video/audio master.
input_ffmpeg = ffmpeg.input(input_file)
# Load the subtitle master.
input_ffmpeg_sub = ffmpeg.input(subtitles_file)
# Refer to the master audio, video and subtitles streams separately.
input_video = input_ffmpeg['v']
input_audio = input_ffmpeg['a']
input_subtitles = input_ffmpeg_sub['s']
output_ffmpeg = ffmpeg.output(
input_video, input_audio, input_subtitles, output_file,
vcodec='copy', acodec='copy', scodec='mov_text'
)
# If the destination file already exists, overwrite it.
output_ffmpeg = ffmpeg.overwrite_output(output_ffmpeg)
# Print the equivalent ffmpeg command we could run to perform the same action as above.
print(ffmpeg.compile(output_ffmpeg))
# Do it! transcode!
ffmpeg.run(output_ffmpeg)
这是等效的 ffmpeg 命令:
ffmpeg -i input.mp4 -i subtitles.srt -map 0:v -map 0:a -map 1:s -acodec copy -vcodec copy -scodec mov_text output.mp4 -y
或
ffmpeg -i input.mp4 -i subtitles.srt -map 0:v -map 0:a -map 1:s -c:a copy -c:v copy -c:s mov_text output.mp4 -y
希望对你有帮助,对我有用。