ffmpeg avfilter map解释

I would like to place the audio from a video to another video without an audio (in one command):

ffmpeg.exe -i video1_noAudio.mov -i video2_wAudio.mov -vcodec copy -acodec copy video1_audioFromVideo2.mov

I guess "-map" is the correct way to do it but I got confused with it.

Can you suggest how to resolve it?

解决方案

Overview of inputs

input_0.mp4 has the desired video stream and input_1.mp4 has the desired audio stream:

mapping diagram

In ffmpeg the streams look like this:

$ ffmpeg -i input_0.mp4 -i input_1.mp4

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input_0.mp4':
  Duration: 00:01:48.50, start: 0.000000, bitrate: 4144 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 4014 kb/s, SAR 115:87 DAR 1840:783, 23.98 fps, 23.98 tbr, 16k tbn, 47.95 tbc (default)
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 124 kb/s (default)

Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'input_1.mp4':
  Duration: 00:00:30.05, start: 0.000000, bitrate: 1754 kb/s
    Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x480 [SAR 8:9 DAR 4:3], 1687 kb/s, 59.94 fps, 59.94 tbr, 60k tbn, 119.88 tbc (default)
    Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 55 kb/s (default)

ID numbers

ffmpeg refers to input files and streams with index numbers. The format is input_file_id:input_stream_id. Since ffmpeg starts counting from 0, stream 1:1 refers to the audio from input_1.mp4.

Stream specifiers

This can be enhanced with stream specifiers. For example, you can tell ffmpeg that you want the first video stream from the first input (0:v:0), and the first audio stream from the second input (1:a:0). I prefer this method because it's more efficient. Also, it is less prone to accidental mapping because 1:1 can refer to any type of stream, while 2:v:3 only refers to the fourth video stream of the third input file.

Examples

The -map option instructs ffmpeg what streams you want. To copy the video from input_0.mp4 and audio from input_1.mp4:

$ ffmpeg -i input_0.mp4 -i input_1.mp4 -c copy -map 0:0 -map 1:1 -shortest out.mp4

This next example will do the same thing:

$ ffmpeg -i input_0.mp4 -i input_1.mp4 -c copy -map 0:v:0 -map 1:a:0 -shortest out.mp4
  • -map 0:v:0 can be translated as: from the first input (0), select video stream type (v), first video stream (0)

  • -map 1:a:0 can be translated as: from the second input (1), select audio stream type (a), first audio stream (0)

Additional Notes

本文地址:IT屋 » FFMPEG mux video and audio (from another video) - mapping issue

问 题

我想向从视频到另一个视频中的音频没有音频(在一个命令):

  ffmpeg.exe -i video1_noAudio.mov -i video2_wAudio.mov -v codeC副本-a codeC副本video1_audioFromVideo2.mov

我猜“-Map”是做了正确的方式,但我得到了它混淆。

您可以建议如何解决?


解决方案

输入概述

input_0.mp4 具有所需的视频流和 input_1.mp4 具有所需的音频流:

在的ffmpeg 流是这样的:

  $的ffmpeg -i input_0.mp4 -i input_1.mp4输入#0,MOV,MP4,M4A,3GP,3G2,MJ2,从'input_0.mp4“:
  时间:00:01:48.50,启动:0.000000,比特率:4144 KB /秒
    流#0:0(UND):视频:H264(高)(AVC1 / 0x31637661),YUV420P,1280×720,4014 KB /秒,SAR 115:87 DAR 1840:783,23.98 fps的,23.98 TBR,16K TBN,47.95 TBC (默认)
    流#0:1(UND):音频:AAC(LC)(MP4A / 0x6134706D),48000赫兹,立体声,fltp,124 kb / s的(默认)输入#1,MOV,MP4,M4A,3GP,3G2,MJ2,从'input_1.mp4“:
  时间:00:00:30.05,启动:0.000000,比特率:1754 KB /秒
    流#1:0(UND):视频:H264(高)(AVC1 / 0x31637661),YUV420P,720×480 [SAR 8:9 DAR 4:3] 1687 KB /秒,59.94帧,59.94 TBR,60K TBN,119.88 TBC(默认)
    流#1:1(UND):音频:AAC(LC)(MP4A / 0x6134706D),48000赫兹,立体声,fltp,55 KB /秒(默认)

身份证号码

的ffmpeg 是指输入文件和索引号流。格式为 input_file_id:input_stream_id 。由于的ffmpeg 从0开始计数,流 1:1 是指从 INPUT_1音频。 MP4 。

流符

这可以流符增强。例如,你可以告诉的ffmpeg 您想从第一个输入的第一个视频流( 0:V:0 ),并从第二输入( 1的第一音频流:一个:0 )。我preFER这种方法,因为它的效率更高。此外,它是不易发生意外映射,因为 1:1 可以指任何类型的流,而 2:ν:3 只是指第三输入文件的第四个视频流。

例子

-map 选项指示的ffmpeg 你要什么流。从 input_0.mp4 和音频复制视频 input_1.mp4 :

  $的ffmpeg -i input_0.mp4 -i input_1.mp4 -c复制-map 0:0 -map 1:1 -shortest out.mp4

这一个例子将做同样的事情:

  $的ffmpeg -i input_0.mp4 -i input_1.mp4 -c复制-map 0:V:0 -map 1:0 -shortest out.mp4

  • 0 -Map:V:0 可译为:从第一输入( 0 ),选择视频流类型( v ),第一视频流( 0 )


  • -map 1:0 可译为:从第二个输入( 1 ),选择音频流类型( A ),第一音频流( 0 )


附加注释

  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值