如何与ffmpeg一起使用过滤和流复制? [英] How to use filtering and stream copy together with ffmpeg?

查看:72
本文介绍了如何与ffmpeg一起使用过滤和流复制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  ffmpeg -ss 0 -t 8 -i input.mp4 -acodec复制-vcodec复制output.mp4 

可以设置编解码器.但是,要过滤:

  ffmpeg -i input.mp4 -vf crop = 100:100:0:0 output.mp4 

如果结合使用:

为视频输出流0:0定义了

  Filtergraph'crop = 100:100:0:0',但选择了编解码器副本.过滤和流复制不能一起使用. 

如何设置编解码器(如时间片段)?

解决方案

不可能

过滤要求将输入视频完全解码为原始视频,然后由过滤器处理原始视频,然后对其进行编码:

  _______ ________________|||||输入|解复用器|编码数据|解码器|文件--------->|包|----- +| _______ || ______________ ||v_________|||解码||框架|| _________ ||v__________|||过滤后||框架|| __________ |________ ______________ |||||||输出|< -------- |编码数据|< ---- +|文件多路复用器|包|编码器| ________ || ______________ | 

流复制模式省略了解码和编码:

  _______ ______________ ________|||||||输入|解复用器|编码数据|多路复用器|输出||文件--------->|包|------->|文件| _______ || ______________ || ________ | 

因此不可能同时过滤和流复制相同的流.但是,可以在过滤其他流的同时流复制未过滤的流.过滤视频和流复制音频的示例:

  ffmpeg -i输入-filter_complex"[0:v] scale = iw/2:-1 [v]" -map"[v]" -map 0:a -c:复制输出 

有关更多信息,请参见 ffmpeg 文档./p>

ffmpeg -ss 0 -t 8  -i  input.mp4  -acodec copy -vcodec copy output.mp4

can set codec. However, to filter:

ffmpeg  -i  input.mp4  -vf  crop=100:100:0:0 output.mp4

if combined:

Filtergraph 'crop=100:100:0:0' was defined for video output stream 0:0 but codec copy was selected.
Filtering and streamcopy cannot be used together.

how to set codec like time clip?

解决方案

Not possible

Filtering requires the input video to be fully decoded into raw video, then the raw video is processed by the filter(s), then it is encoded:

 _______              ______________
|       |            |              |
| input |  demuxer   | encoded data |   decoder
| file  | ---------> | packets      | -----+
|_______|            |______________|      |
                                           v
                                       _________
                                      |         |
                                      | decoded |
                                      | frames  |
                                      |_________|
                                           |
                                           v
                                       __________
                                      |          |
                                      | filtered |
                                      | frames   |
                                      |__________|
 ________             ______________       |
|        |           |              |      |
| output | <-------- | encoded data | <----+
| file   |   muxer   | packets      |   encoder
|________|           |______________|

Stream copy mode omits decoding and encoding:

 _______              ______________            ________
|       |            |              |          |        |
| input |  demuxer   | encoded data |  muxer   | output |
| file  | ---------> | packets      | -------> | file   |
|_______|            |______________|          |________|

So it is not possible to filter and stream copy the same stream at the same time. However, you can stream copy unfiltered streams while filtering others. Example to filter video and stream copy audio:

ffmpeg -i input -filter_complex "[0:v]scale=iw/2:-1[v]" -map "[v]" -map 0:a -c:a copy output

See the ffmpeg documentation for more info.

这篇关于如何与ffmpeg一起使用过滤和流复制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆