ffmpeg怎么处理动态帧率(VFR)的视频

Totem,mplayer,sopcast,realplayer,bmp
回复
头像
kashu
帖子: 451
注册时间: 2014-02-07 17:31
系统: Xubuntu 14.04.5 64位

ffmpeg怎么处理动态帧率(VFR)的视频

#1

帖子 kashu » 2016-12-24 23:29

像下面这种动态帧率的视频,如何转码好点?


-----------
我知道怎么弄了,谢谢……
上次由 kashu 在 2016-12-25 23:54,总共编辑 1 次。


OS: Xubuntu 14.04.5 LTS 64-bit
CPU: Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
RAM: 12GB DDR3 1333MHz
128GB SSD + 2TB HDD
神舟优雅A480B-I5B 购于 2012.08

YouTube频道:https://www.youtube.com/channel/UCGSPXZ ... DuDYX8L6Qg
头像
astolia
论坛版主
帖子: 6435
注册时间: 2008-09-18 13:11

Re: ffmpeg怎么处理动态帧率(VFR)的视频

#2

帖子 astolia » 2016-12-25 1:16

最高120fps被你压到30fps怎能不卡,你原视频的比特率有多少?试试-maxrate和-bufsize参数
头像
nyfair
帖子: 1067
注册时间: 2007-12-07 12:49
系统: winnux10
来自: Tree New Bee

Re: ffmpeg怎么处理动态帧率(VFR)的视频

#3

帖子 nyfair » 2016-12-28 13:46

你们真折腾,这种事尽量别用ffmpeg做
本人在此论坛仅负责吐槽,问题急需解决请支付宝转账5毛至{我的id@qq.com},将会竭诚为您服务

linux常见多媒体问题处理指南

1. 视频播放有问题->卸载gstreamer
2. 音频播放有问题->卸载pulseaudio
3. 远程播放有问题->卸载avahi
4. 系统全都有问题->卸载systemd,远离Lennart这傻逼让你从此轻松自在

⇩自由网络⇩
https://github.com/nyfair/freeweb
头像
kashu
帖子: 451
注册时间: 2014-02-07 17:31
系统: Xubuntu 14.04.5 64位

Re: ffmpeg怎么处理动态帧率(VFR)的视频

#4

帖子 kashu » 2016-12-28 14:16

nyfair 写了:你们真折腾,这种事尽量别用ffmpeg做
用什么软件好点?


OS: Xubuntu 14.04.5 LTS 64-bit
CPU: Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
RAM: 12GB DDR3 1333MHz
128GB SSD + 2TB HDD
神舟优雅A480B-I5B 购于 2012.08

YouTube频道:https://www.youtube.com/channel/UCGSPXZ ... DuDYX8L6Qg
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: ffmpeg怎么处理动态帧率(VFR)的视频

#5

帖子 poloshiao » 2016-12-28 15:36

动态帧率(VFR)
用什么软件好点?
1. 試試 套件 handbrake
versatile DVD ripper and video transcoder (GTK GUI)
是否合於你的要求

2. https://help.ubuntu.com/community/HandBrake
HandBrake

3. http://packages.ubuntu.com/search?suite ... chon=names
套件 handbrake

4. https://launchpad.net/~stebbins/+archiv ... e-releases
Adding PPA

5. http://www.ubuntugeek.com/handbrake-0-9 ... luded.html
HandBrake 0.9.6 released and PPA installation instructions included
Support for VFR, CFR and VFR

6. 剛好 HandBrake 1.0.0 最新版本 歷經 13 年 研發 Dec 24, 2016 問世
6-1. 發行公告
https://handbrake.fr/news.php?article=37
6-2. 下載
http://linux.softpedia.com/get/Multimed ... l#download
6-3. 報導
http://news.softpedia.com/news/handbrak ... 1315.shtml

7. 官網
https://handbrake.fr/
头像
kashu
帖子: 451
注册时间: 2014-02-07 17:31
系统: Xubuntu 14.04.5 64位

Re: ffmpeg怎么处理动态帧率(VFR)的视频

#6

帖子 kashu » 2016-12-28 18:39

poloshiao, 感谢推荐。电脑里很早就已经安装了HandBrake 0.10.5,但几乎没用过这软件。

我用的是ffmpeg来处理的(x264命令没研究过,选项参数不会敲,不知道用x264处理出来的效果和ffmpeg相比会有怎样的差异?)
ffmpeg -i a.mp4 -hide_banner -c:v libx264 -b:v 500k -vf scale=-1:480 -tune animation -r 119.88 -vsync 2 -preset veryslow -c:a aac -b:a 96k b.mp4

代码: 全选

原视频的mediainfo信息
Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L3.1
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 5 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 1h 22mn
Bit rate                                 : 1 205 Kbps
Maximum bit rate                         : 11.5 Mbps
Width                                    : 960 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 4:3
Frame rate mode                          : Variable
Frame rate                               : 25.629 fps
Original frame rate                      : 29.970 fps
Minimum frame rate                       : 14.985 fps
Maximum frame rate                       : 119.880 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.068
Title                                    : Imported with GPAC 0.4.6-DEV-git-5ca3a9a
Writing library                          : x264 core 142 r2409M+r890[x64] release1
Encoding settings                        : cabac=1 / ref=5 / deblock=1:0:0 / analyse=0x3:0x113 / me=umh / subme=10 / psy=1 / fade_compensate=0.00 / psy_rd=1.00:0.20 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=0 / chroma_qp_offset=-3 / threads=12 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=0 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / fgo=0 / bframes=3 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=4 / scenecut=40 / intra_refresh=0 / rc=crf / mbtree=0 / crf=21.0 / qcomp=0.75 / qpmin=0 / qpmax=69 / qpstep=12 / ip_ratio=1.50 / pb_ratio=1.30 / aq=1:0.60
Color range                              : Limited
Matrix coefficients                      : BT.709

Audio
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : LC
Codec ID                                 : 40
Duration                                 : 1h 22mn
Bit rate mode                            : Variable
Bit rate                                 : 160 Kbps
Maximum bit rate                         : 266 Kbps
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 48.0 KHz
Compression mode                         : Lossy


OS: Xubuntu 14.04.5 LTS 64-bit
CPU: Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
RAM: 12GB DDR3 1333MHz
128GB SSD + 2TB HDD
神舟优雅A480B-I5B 购于 2012.08

YouTube频道:https://www.youtube.com/channel/UCGSPXZ ... DuDYX8L6Qg
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: ffmpeg怎么处理动态帧率(VFR)的视频

#7

帖子 poloshiao » 2016-12-28 20:10

我用的是ffmpeg来处理的
參閱

https://ffmpeg.org/ffmpeg.html#Video-Options
5.5 Video Options
-vframes number (output)
Set the number of video frames to output. This is an alias for -frames:v.

https://ffmpeg.org/ffmpeg.html#Advanced-Video-options
5.6 Advanced Video options
2, vfr
Frames are passed through with their timestamp or dropped so as to prevent 2 frames from having the same timestamp.

https://ffmpeg.org/ffmpeg.html#Video-an ... conversion
If you want to extract just a limited number of frames, you can use the above command in combination with the -vframes or -t option, or in combination with -ss to start extracting from a certain point in time.
头像
nyfair
帖子: 1067
注册时间: 2007-12-07 12:49
系统: winnux10
来自: Tree New Bee

Re: ffmpeg怎么处理动态帧率(VFR)的视频

#8

帖子 nyfair » 2016-12-30 16:30

kashu 写了:poloshiao, 感谢推荐。电脑里很早就已经安装了HandBrake 0.10.5,但几乎没用过这软件。

我用的是ffmpeg来处理的(x264命令没研究过,选项参数不会敲,不知道用x264处理出来的效果和ffmpeg相比会有怎样的差异?)
ffmpeg -i a.mp4 -hide_banner -c:v libx264 -b:v 500k -vf scale=-1:480 -tune animation -r 119.88 -vsync 2 -preset veryslow -c:a aac -b:a 96k b.mp4

代码: 全选

原视频的mediainfo信息
Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L3.1
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 5 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 1h 22mn
Bit rate                                 : 1 205 Kbps
Maximum bit rate                         : 11.5 Mbps
Width                                    : 960 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 4:3
Frame rate mode                          : Variable
Frame rate                               : 25.629 fps
Original frame rate                      : 29.970 fps
Minimum frame rate                       : 14.985 fps
Maximum frame rate                       : 119.880 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.068
Title                                    : Imported with GPAC 0.4.6-DEV-git-5ca3a9a
Writing library                          : x264 core 142 r2409M+r890[x64] release1
Encoding settings                        : cabac=1 / ref=5 / deblock=1:0:0 / analyse=0x3:0x113 / me=umh / subme=10 / psy=1 / fade_compensate=0.00 / psy_rd=1.00:0.20 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=0 / chroma_qp_offset=-3 / threads=12 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=0 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / fgo=0 / bframes=3 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=4 / scenecut=40 / intra_refresh=0 / rc=crf / mbtree=0 / crf=21.0 / qcomp=0.75 / qpmin=0 / qpmax=69 / qpstep=12 / ip_ratio=1.50 / pb_ratio=1.30 / aq=1:0.60
Color range                              : Limited
Matrix coefficients                      : BT.709

Audio
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : LC
Codec ID                                 : 40
Duration                                 : 1h 22mn
Bit rate mode                            : Variable
Bit rate                                 : 160 Kbps
Maximum bit rate                         : 266 Kbps
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 48.0 KHz
Compression mode                         : Lossy
kashu 写了:x264 core 142 r2409M+r890
普通使用区别不大,x264通过链接libavcodec和libavofrmat后可以直接拿ffmpeg当输入。
但是ffmpeg自带的设置选项太少没法拓展出来,而linux发行版自带的ffmpeg很多时候又因为各种gpl non-free之类的限制关掉了一些实用的编译参数(顺便加了一堆大多数人一辈子都不会用到的依赖库弄得异常臃肿),所以一般你想认认真真搞rip基本都得自己从头开始自己编译折腾一遍
高级视频编辑推荐直接写VapourSynth脚本(http://www.vapoursynth.com/),不过这都是字幕组玩的那一套了不必刻意深入

顺便说下-tune animation这里的animation跟普通意义上的アニメ不是一个东西,甚至这个参数本身也只是为了讨好psnr而不是为了讨好肉眼,一般不应该加上
本人在此论坛仅负责吐槽,问题急需解决请支付宝转账5毛至{我的id@qq.com},将会竭诚为您服务

linux常见多媒体问题处理指南

1. 视频播放有问题->卸载gstreamer
2. 音频播放有问题->卸载pulseaudio
3. 远程播放有问题->卸载avahi
4. 系统全都有问题->卸载systemd,远离Lennart这傻逼让你从此轻松自在

⇩自由网络⇩
https://github.com/nyfair/freeweb
头像
nyfair
帖子: 1067
注册时间: 2007-12-07 12:49
系统: winnux10
来自: Tree New Bee

Re: ffmpeg怎么处理动态帧率(VFR)的视频

#9

帖子 nyfair » 2016-12-30 16:36

astolia 写了:最高120fps被你压到30fps怎能不卡,你原视频的比特率有多少?试试-maxrate和-bufsize参数
120fps压到30fps为什么可能会卡?
本人在此论坛仅负责吐槽,问题急需解决请支付宝转账5毛至{我的id@qq.com},将会竭诚为您服务

linux常见多媒体问题处理指南

1. 视频播放有问题->卸载gstreamer
2. 音频播放有问题->卸载pulseaudio
3. 远程播放有问题->卸载avahi
4. 系统全都有问题->卸载systemd,远离Lennart这傻逼让你从此轻松自在

⇩自由网络⇩
https://github.com/nyfair/freeweb
头像
kashu
帖子: 451
注册时间: 2014-02-07 17:31
系统: Xubuntu 14.04.5 64位

Re: ffmpeg怎么处理动态帧率(VFR)的视频

#10

帖子 kashu » 2016-12-30 22:07

nyfair, -tune animation也不知道是干什么用的,网上找的然后就用上了。

我用的ffmpeg是static build版,2016年12月02月。

代码: 全选

$ ffmpeg 
ffmpeg version N-82963-g9ec52a0a9b-static http://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.4.1 (Debian 5.4.1-4) 20161202
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-5 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg
  libavutil      55. 43.100 / 55. 43.100
  libavcodec     57. 70.100 / 57. 70.100
  libavformat    57. 61.100 / 57. 61.100
  libavdevice    57.  2.100 / 57.  2.100
  libavfilter     6. 68.100 /  6. 68.100
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
VapourSynth是什么?感觉用不了……
nyfair 写了:
astolia 写了:最高120fps被你压到30fps怎能不卡,你原视频的比特率有多少?试试-maxrate和-bufsize参数
120fps压到30fps为什么可能会卡?
如果是动态的fps转换成固定的fps时,就会发现画面卡,不自然。


OS: Xubuntu 14.04.5 LTS 64-bit
CPU: Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
RAM: 12GB DDR3 1333MHz
128GB SSD + 2TB HDD
神舟优雅A480B-I5B 购于 2012.08

YouTube频道:https://www.youtube.com/channel/UCGSPXZ ... DuDYX8L6Qg
回复