我父亲只能使用一款老款的视频编辑器(Pinnacle Studio 12),这款软件对导入的视频文件要求非常严格。下面是 avprobe 对其导入的视频之一的输出:
encoder: Lavf53.24.2 bitrate: 9884 kb/s
Stream #0.0: Video: mpeg4 (Simple Profile), yuv420p,
1920x1080 [PAR 9:16 DAR 1:1], 25 tbn, 25 tbc
我想使用 avconv/ffmpeg 之类的 Linux 实用程序将我父亲的所有视频文件转换为上述格式。经过几个小时的阅读和测试,我能够匹配视频流的所有属性,除了 tbn、tbc 和比特率(请参阅我使用的命令的注释#1)。以下是 avprob 对我创建的视频的报告:
bitrate: 36617 kb/s
Stream #0.0: Video: mpeg4 (Simple Profile), yuv420p,
1920x1080 [PAR 9:16 DAR 1:1], 25 fps, 25 tbr, 90k tbn, 65535 tbc
为了省去您交叉检查两个输出的麻烦,这里有一个差异:
ORIG: bitrate: 9884 kb/s 25 tbn, 25 tbc
MINE: bitrate: 36617 kb/s 25 fps, 25 tbr, 90k tbn, 65535 tbc
这时我陷入了困境。我甚至很难找到并理解 tbn、tbr 和 tbc 到底是什么。我还想知道为什么 avconv 会忽略参数 -b:v 9756,但我相信我会通过更多的谷歌搜索和测试来解决这个问题。
更新
我在运行 Ubuntu 12.04 和 avconv 0.8.16-4:0.8.16 的笔记本电脑上尝试了相同的命令,它生成的视频具有完全相同的属性!请参阅注释 2。当然,将我父亲的 PC 从 Ubuntu 14.04 降级到 12.04 非常困难,所以我仍在寻找可以在那里使用的解决方案。[坦白说,在我的电脑上运行的命令中的音频编解码器存在差异。我不得不用 替换,mp3
因为libmp3lame
出于某种原因,前者不起作用。]
注释#1这是我使用的命令(在 ubuntu 14.04 上):
avconv -i GOPR0392.MP4 \
-codec:a mp3 -b:a 128k -ar:a 44100 \
-codec:v libxvid -aspect:v 1 -b:v 9756k \
test.avi
输出结果如下:
avconv version 9.16-6:9.16-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
built on Aug 10 2014 18:16:02 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x11f8060] Non-increasing DTS in stream 3: packet 2 with DTS 0, packet 3 with DTS 0
...
...
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x11f8060] Non-increasing DTS in stream 3: packet 54 with DTS 0, packet 55 with DTS 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x11f8060] Non-increasing DTS in stream 3: packet 55 with DTS 0, packet 56 with DTS 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x11f8060] Non-increasing DTS in stream 3: packet 56 with DTS 0, packet 57 with DTS 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'GOPR0392.MP4':
Metadata:
major_brand : mp41
minor_version : 538120216
compatible_brands: mp41
creation_time : 2015-02-08 01:30:55
Duration: 00:03:02.33, start: 0.000000, bitrate: 45149 kb/s
Stream #0.0(eng): Video: h264 (High), yuvj420p, 1920x1080 [PAR 1:1 DAR 16:9], 45007 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Metadata:
creation_time : 2015-02-08 01:30:55
Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, fltp, 128 kb/s
Metadata:
creation_time : 2015-02-08 01:30:55
Stream #0.2(eng): Data: tmcd / 0x64636D74
Metadata:
creation_time : 2015-02-08 01:30:55
Stream #0.3(eng): Data: fdsc / 0x63736466, 9 kb/s
Metadata:
creation_time : 2015-02-08 01:30:55
File 'test.avi' already exists. Overwrite ? [y/N] y
Output #0, avi, to 'test.avi':
Metadata:
major_brand : mp41
minor_version : 538120216
compatible_brands: mp41
creation_time : 2015-02-08 01:30:55
ISFT : Lavf54.20.4
Stream #0.0(eng): Video: libxvid, yuv420p, 1920x1080 [PAR 9:16 DAR 1:1], q=2-31, 9756 kb/s, 90k tbn, 90k tbc
Metadata:
creation_time : 2015-02-08 01:30:55
Stream #0.1(eng): Audio: libmp3lame, 44100 Hz, stereo, fltp, 128 kb/s
Metadata:
creation_time : 2015-02-08 01:30:55
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> libxvid)
Stream #0:1 -> #0:1 (aac -> libmp3lame)
Press ctrl-c to stop encoding
^Cframe= 1531 fps= 11 q=2.0 Lsize= 261134kB time=61.18 bitrate=34966.6kbits/s
video:131019kB audio:955kB global headers:0kB muxing overhead 97.868984%
Received signal 2: terminating.
笔记2我的笔记本电脑(Ubuntu 12.04)上的相同命令:
avconv -i GOPR0399.MP4 -codec:a libmp3lame -b:a 128k -ar:a 44100 -codec:v libxvid -aspect:v 1 -b:v 9756k test.avi
avconv version 0.8.16-4:0.8.16-0ubuntu0.12.04.1, Copyright (c) 2000-2014 the Libav developers
built on Sep 16 2014 18:35:14 with gcc 4.6.3
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'GOPR0399.MP4':
Metadata:
major_brand : mp41
minor_version : 538120216
compatible_brands: mp41
creation_time : 2015-02-11 17:53:34
Duration: 00:00:29.48, start: 0.000000, bitrate: 45176 kb/s
Stream #0.0(eng): Video: h264 (High), yuvj420p, 1920x1080 [PAR 1:1 DAR 16:9], 45028 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Metadata:
creation_time : 2015-02-11 17:53:34
Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, s16, 128 kb/s
Metadata:
creation_time : 2015-02-11 17:53:34
Stream #0.2(eng): Data: tmcd / 0x64636D74, 0 kb/s
Metadata:
creation_time : 2015-02-11 17:53:34
Stream #0.3(eng): Data: fdsc / 0x63736466, 9 kb/s
Metadata:
creation_time : 2015-02-11 17:53:34
File 'test.avi' already exists. Overwrite ? [y/N] y
Incompatible pixel format 'yuvj420p' for codec 'libxvid', auto-selecting format 'yuv420p'
[buffer @ 0x9bd81a0] w:1920 h:1080 pixfmt:yuvj420p
[avsink @ 0x9bc89c0] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'out'
[scale @ 0x9bc8520] w:1920 h:1080 fmt:yuvj420p -> w:1920 h:1080 fmt:yuv420p flags:0x4
Output #0, avi, to 'test.avi':
Metadata:
major_brand : mp41
minor_version : 538120216
compatible_brands: mp41
creation_time : 2015-02-11 17:53:34
ISFT : Lavf53.21.1
Stream #0.0(eng): Video: mpeg4, yuv420p, 1920x1080 [PAR 9:16 DAR 1:1], q=2-31, 9756 kb/s, 25 tbn, 25 tbc
Metadata:
creation_time : 2015-02-11 17:53:34
Stream #0.1(eng): Audio: libmp3lame, 44100 Hz, stereo, s16, 128 kb/s
Metadata:
creation_time : 2015-02-11 17:53:34
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> libxvid)
Stream #0:1 -> #0:1 (aac -> libmp3lame)
Press ctrl-c to stop encoding
frame= 737 fps= 14 q=3.0 Lsize= 36119kB time=29.48 bitrate=10037.0kbits/s
video:35605kB audio:461kB global headers:0kB muxing overhead 0.149473%
现在 avprobe 报告完全相同的视频属性(比特率有点不同,但我猜这是预料之中的):
avprobe test.avi
avprobe version 0.8.16-4:0.8.16-0ubuntu0.12.04.1, Copyright (c) 2007-2014 the Libav developers
built on Sep 16 2014 18:35:14 with gcc 4.6.3
Input #0, avi, from 'test.avi':
Metadata:
encoder : Lavf53.21.1
Duration: 00:00:29.49, start: 0.000000, bitrate: 10032 kb/s
Stream #0.0: Video: mpeg4 (Simple Profile), yuv420p, 1920x1080 [PAR 9:16 DAR 1:1], 25 tbr, 25 tbn, 25 tbc
Stream #0.1: Audio: mp3, 44100 Hz, stereo, s16, 128 kb/s