MP4Box 不连接视频
MP4Box does not concatenate videos
我的 MP4Box 有问题,无法在一个视频中连接多个视频。我得到 out.mp4 文件(~103 MB),但 omxplayer 无法播放它。我有 6 个非常简单的 .mp4 视频,我希望它们合并到一个视频中。到现在为止,我可以用命令做到这一点,没有任何问题:
MP4Box -cat Awards\ -\ Recognitions\ Screens\ Video.mp4 -cat Cornaro\ USLUGE\ video1.mp4 -cat Cornaro\ USLUGE\ video1.mp4 -cat DIOCLETIANS_BREAKFAST.mp4 -cat FLAVOURS_OF_DALMATIA.mp4 -cat Prognoza.mp4 -cat Restaurants\ -\ Bars\ 2016.mp4 -cat WineHappyHour3.mp4 -new out.mp4
但是现在omxplayer(也是vlc)无法播放.mp4视频。这是 6 个视频中每个视频的媒体信息输出:
General
Complete name : Awards - Recognitions Screens Video.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 16.8 MiB
Duration : 45s 379ms
Overall bit rate : 3 114 Kbps
Writing application : Lavf55.33.101
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main@L5.1
Format settings, CABAC : Yes
Format settings, ReFrames : 3 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 45s 379ms
Bit rate : 3 000 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.048
Stream size : 16.8 MiB (100%)
Writing library : x264 core 142 r2389 956c8d8
Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x1:0 / me=dia / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=6 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=3000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language : English
General
Complete name : Cornaro USLUGE video1.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 22.8 MiB
Duration : 1mn 13s
Overall bit rate : 2 624 Kbps
Writing application : Lavf55.33.101
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main@L5.1
Format settings, CABAC : Yes
Format settings, ReFrames : 3 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 1mn 13s
Bit rate : 2 621 Kbps
Nominal bit rate : 3 000 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.042
Stream size : 22.8 MiB (100%)
Writing library : x264 core 142 r2389 956c8d8
Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x1:0 / me=dia / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=6 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=3000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language : English
General
Complete name : DIOCLETIANS_BREAKFAST.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 11.6 MiB
Duration : 33s 0ms
Overall bit rate : 2 950 Kbps
Writing application : Lavf55.33.101
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main@L5.1
Format settings, CABAC : Yes
Format settings, ReFrames : 3 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 33s 0ms
Bit rate : 3 000 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.048
Stream size : 11.6 MiB (100%)
Writing library : x264 core 142 r2389 956c8d8
Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x1:0 / me=dia / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=6 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=3000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language : English
General
Complete name : FLAVOURS_OF_DALMATIA.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 11.4 MiB
Duration : 33s 0ms
Overall bit rate : 2 891 Kbps
Writing application : Lavf55.33.101
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main@L5.1
Format settings, CABAC : Yes
Format settings, ReFrames : 3 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 33s 0ms
Bit rate : 3 000 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.048
Stream size : 11.4 MiB (100%)
Writing library : x264 core 142 r2389 956c8d8
Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x1:0 / me=dia / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=6 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=3000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language : English
General
Complete name : Prognoza.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 3.27 MiB
Duration : 10s 44ms
Overall bit rate : 2 733 Kbps
Writing application : Lavf55.33.101
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main@L5.1
Format settings, CABAC : Yes
Format settings, ReFrames : 3 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 10s 44ms
Bit rate : 2 730 Kbps
Nominal bit rate : 3 000 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.044
Stream size : 3.27 MiB (100%)
Writing library : x264 core 142 r2389 956c8d8
Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x1:0 / me=dia / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=6 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=3000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language : English`
General
Complete name : Restaurants - Bars 2016.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 33.4 MiB
Duration : 1mn 35s
Overall bit rate : 2 929 Kbps
Writing application : Lavf55.33.101
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main@L5.1
Format settings, CABAC : Yes
Format settings, ReFrames : 3 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 1mn 35s
Bit rate : 3 000 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.048
Stream size : 33.4 MiB (100%)
Writing library : x264 core 142 r2389 956c8d8
Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x1:0 / me=dia / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=6 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=3000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language : English
General
Complete name : WineHappyHour3.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 4.10 MiB
Duration : 13s 581ms
Overall bit rate : 2 533 Kbps
Writing application : Lavf55.33.101
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main@L5.1
Format settings, CABAC : Yes
Format settings, ReFrames : 3 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 13s 581ms
Bit rate : 2 530 Kbps
Nominal bit rate : 3 000 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.041
Stream size : 4.10 MiB (100%)
Writing library : x264 core 142 r2389 956c8d8
Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x1:0 / me=dia / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=6 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=3000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language : English
所以所有 6 个视频都有良好的 mediainfo 输出,但是我尝试执行命令来测试没有 1 个视频(一个接一个),然后合并它们,但结果相同。当我执行 mp4box 命令时,我得到奇怪的命令行输出:
Appending file Awards - Recognitions Screens Video.mp4
No suitable destination track found - creating new one (type vide)
Appending file Cornaro USLUGE video1.mp4
Appending file Cornaro USLUGE video1.mp4
No suitable destination track found - creating new one (type vide)
Appending file DIOCLETIANS_BREAKFAST.mp4
Appending file FLAVOURS_OF_DALMATIA.mp4
Appending file Prognoza.mp4
Appending file Restaurants - Bars 2016.mp4
No suitable destination track found - creating new one (type vide)
Appending file WineHappyHour3.mp4
Saving out.mp4: 0.500 secs Interleaving
这是 out.mp4 视频的媒体信息:
General
Complete name : out.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 126 MiB
Duration : 4mn 50s
Overall bit rate : 3 651 Kbps
Encoded date : UTC 2016-06-10 15:32:13
Tagged date : UTC 2016-06-10 15:32:13
Video #1
ID : 1
Format : avc3
Codec ID : avc3
Duration : 1mn 58s
Bit rate : 2 809 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 fps
Bits/(Pixel*Frame) : 0.045
Stream size : 39.6 MiB (31%)
Language : English
Tagged date : UTC 2016-06-10 15:32:15
Video #2
ID : 2
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main@L5.1
Format settings, CABAC : Yes
Format settings, ReFrames : 3 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 4mn 41s
Source duration : 3mn 28s
Bit rate : 2 143 Kbps
Nominal bit rate : 3 000 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Variable
Frame rate : 23.432 fps
Minimum frame rate : 0.022 fps
Maximum frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.044
Stream size : 53.1 MiB (42%)
Source stream size : 53.1 MiB (42%)
Writing library : x264 core 142 r2389 956c8d8
Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x1:0 / me=dia / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=6 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=3000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language : English
Tagged date : UTC 2016-06-10 15:32:15
Video #3
ID : 3
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main@L5.1
Format settings, CABAC : Yes
Format settings, ReFrames : 3 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 4mn 50s
Source duration : 1mn 35s
Nominal bit rate : 3 000 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.048
Source stream size : 33.4 MiB (26%)
Writing library : x264 core 142 r2389 956c8d8
Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x1:0 / me=dia / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=6 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=3000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language : English
Tagged date : UTC 2016-06-10 15:32:15
如您所见,"No suitable destination track found..." 行中恰好有“#”个视频部分,这很奇怪。到目前为止,最接近解决我的问题的是这个命令:
MP4Box -force-cat -add Awards\ -\ Recognitions\ Screens\ Video.mp4 -cat Cornaro\ USLUGE\ video1.mp4 -cat Cornaro\ USLUGE\ video1.mp4 -cat DIOCLETIANS_BREAKFAST.mp4 -cat FLAVOURS_OF_DALMATIA.mp4 -cat Prognoza.mp4 -cat Restaurants\ -\ Bars\ 2016.mp4 -cat WineHappyHour3.mp4 out.mp4
但它连续两次显示第二个视频 (Cornaro USLUGE video1.mp4),然后休息正常。我真的不知道该怎么办。任何帮助将不胜感激。
这是 https://github.com/gpac/gpac/issues/549 的重复答案:FFmpeg 有时会在 SPS 中添加 PAR 可选字段。因此MP4Box检测到不同的SPS,无法合并。
作为解决方法,GPAC 是否应该能够检测到此更改仍在讨论中。请针对根本问题发表意见:https://github.com/gpac/gpac/issues/13.
注意@IncBrain:bs-switching 是 DASH 的一个特性,不是 MP4。
您还可以使用 ffmpeg
来连接您的 mp4 文件,如 here:
所述
首先,您必须像这样将视频转码为 MPEG2-TS:
ffmpeg -i vid1.mp4 -c:v copy -bsf:v h264_mp4toannexb -f mpegts inter1.ts
ffmpeg -i vid2.mp4 -c:v copy -bsf:v h264_mp4toannexb -f mpegts inter2.ts
ffmpeg -i vid3.mp4 -c:v copy -bsf:v h264_mp4toannexb -f mpegts inter3.ts
...
然后将它们连接起来:
ffmpeg -i "concat:inter1.ts|inter2.ts|inter3.ts" -c copy out.mp4
我用 your videos 测试了它(link 你在 github 上发帖)并且它工作得很好。
也可以在不使用命名管道创建中间 .ts 文件的情况下执行此操作,这看起来类似于:
mkfifo temp1 temp2
ffmpeg -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts temp1 2> /dev/null & \
ffmpeg -i input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts temp2 2> /dev/null & \
ffmpeg -f mpegts -i "concat:temp1|temp2" -c copy output.mp4
but it is showing second video (Cornaro USLUGE video1.mp4) two times in row
在我看来,您从命令行添加了两次。
感谢您的帮助,但我需要使用 MP4Box 来合并视频而不是 ffmpeg,因为我的 RPi3 上只安装了 MP4Box。
无论如何,更改命令并可以确认它像魅力一样有效(即使视频缺少 PAR 参数信息):
MP4Box -force-cat -cat Awards\ -\ Recognitions\ Screens\ Video.mp4 -cat Cornaro\ USLUGE\ video1.mp4 -cat Cornaro\ USLUGE\ video1.mp4 -cat DIOCLETIANS_BREAKFAST.mp4 -cat FLAVOURS_OF_DALMATIA.mp4 -cat Prognoza.mp4 -cat Restaurants\ -\ Bars\ 2016.mp4 -cat WineHappyHour3.mp4 output.mp4
我的 MP4Box 有问题,无法在一个视频中连接多个视频。我得到 out.mp4 文件(~103 MB),但 omxplayer 无法播放它。我有 6 个非常简单的 .mp4 视频,我希望它们合并到一个视频中。到现在为止,我可以用命令做到这一点,没有任何问题:
MP4Box -cat Awards\ -\ Recognitions\ Screens\ Video.mp4 -cat Cornaro\ USLUGE\ video1.mp4 -cat Cornaro\ USLUGE\ video1.mp4 -cat DIOCLETIANS_BREAKFAST.mp4 -cat FLAVOURS_OF_DALMATIA.mp4 -cat Prognoza.mp4 -cat Restaurants\ -\ Bars\ 2016.mp4 -cat WineHappyHour3.mp4 -new out.mp4
但是现在omxplayer(也是vlc)无法播放.mp4视频。这是 6 个视频中每个视频的媒体信息输出:
General
Complete name : Awards - Recognitions Screens Video.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 16.8 MiB
Duration : 45s 379ms
Overall bit rate : 3 114 Kbps
Writing application : Lavf55.33.101
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main@L5.1
Format settings, CABAC : Yes
Format settings, ReFrames : 3 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 45s 379ms
Bit rate : 3 000 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.048
Stream size : 16.8 MiB (100%)
Writing library : x264 core 142 r2389 956c8d8
Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x1:0 / me=dia / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=6 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=3000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language : English
General
Complete name : Cornaro USLUGE video1.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 22.8 MiB
Duration : 1mn 13s
Overall bit rate : 2 624 Kbps
Writing application : Lavf55.33.101
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main@L5.1
Format settings, CABAC : Yes
Format settings, ReFrames : 3 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 1mn 13s
Bit rate : 2 621 Kbps
Nominal bit rate : 3 000 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.042
Stream size : 22.8 MiB (100%)
Writing library : x264 core 142 r2389 956c8d8
Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x1:0 / me=dia / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=6 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=3000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language : English
General
Complete name : DIOCLETIANS_BREAKFAST.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 11.6 MiB
Duration : 33s 0ms
Overall bit rate : 2 950 Kbps
Writing application : Lavf55.33.101
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main@L5.1
Format settings, CABAC : Yes
Format settings, ReFrames : 3 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 33s 0ms
Bit rate : 3 000 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.048
Stream size : 11.6 MiB (100%)
Writing library : x264 core 142 r2389 956c8d8
Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x1:0 / me=dia / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=6 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=3000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language : English
General
Complete name : FLAVOURS_OF_DALMATIA.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 11.4 MiB
Duration : 33s 0ms
Overall bit rate : 2 891 Kbps
Writing application : Lavf55.33.101
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main@L5.1
Format settings, CABAC : Yes
Format settings, ReFrames : 3 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 33s 0ms
Bit rate : 3 000 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.048
Stream size : 11.4 MiB (100%)
Writing library : x264 core 142 r2389 956c8d8
Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x1:0 / me=dia / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=6 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=3000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language : English
General
Complete name : Prognoza.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 3.27 MiB
Duration : 10s 44ms
Overall bit rate : 2 733 Kbps
Writing application : Lavf55.33.101
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main@L5.1
Format settings, CABAC : Yes
Format settings, ReFrames : 3 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 10s 44ms
Bit rate : 2 730 Kbps
Nominal bit rate : 3 000 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.044
Stream size : 3.27 MiB (100%)
Writing library : x264 core 142 r2389 956c8d8
Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x1:0 / me=dia / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=6 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=3000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language : English`
General
Complete name : Restaurants - Bars 2016.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 33.4 MiB
Duration : 1mn 35s
Overall bit rate : 2 929 Kbps
Writing application : Lavf55.33.101
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main@L5.1
Format settings, CABAC : Yes
Format settings, ReFrames : 3 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 1mn 35s
Bit rate : 3 000 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.048
Stream size : 33.4 MiB (100%)
Writing library : x264 core 142 r2389 956c8d8
Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x1:0 / me=dia / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=6 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=3000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language : English
General
Complete name : WineHappyHour3.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 4.10 MiB
Duration : 13s 581ms
Overall bit rate : 2 533 Kbps
Writing application : Lavf55.33.101
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main@L5.1
Format settings, CABAC : Yes
Format settings, ReFrames : 3 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 13s 581ms
Bit rate : 2 530 Kbps
Nominal bit rate : 3 000 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.041
Stream size : 4.10 MiB (100%)
Writing library : x264 core 142 r2389 956c8d8
Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x1:0 / me=dia / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=6 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=3000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language : English
所以所有 6 个视频都有良好的 mediainfo 输出,但是我尝试执行命令来测试没有 1 个视频(一个接一个),然后合并它们,但结果相同。当我执行 mp4box 命令时,我得到奇怪的命令行输出:
Appending file Awards - Recognitions Screens Video.mp4
No suitable destination track found - creating new one (type vide)
Appending file Cornaro USLUGE video1.mp4
Appending file Cornaro USLUGE video1.mp4
No suitable destination track found - creating new one (type vide)
Appending file DIOCLETIANS_BREAKFAST.mp4
Appending file FLAVOURS_OF_DALMATIA.mp4
Appending file Prognoza.mp4
Appending file Restaurants - Bars 2016.mp4
No suitable destination track found - creating new one (type vide)
Appending file WineHappyHour3.mp4
Saving out.mp4: 0.500 secs Interleaving
这是 out.mp4 视频的媒体信息:
General
Complete name : out.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 126 MiB
Duration : 4mn 50s
Overall bit rate : 3 651 Kbps
Encoded date : UTC 2016-06-10 15:32:13
Tagged date : UTC 2016-06-10 15:32:13
Video #1
ID : 1
Format : avc3
Codec ID : avc3
Duration : 1mn 58s
Bit rate : 2 809 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 fps
Bits/(Pixel*Frame) : 0.045
Stream size : 39.6 MiB (31%)
Language : English
Tagged date : UTC 2016-06-10 15:32:15
Video #2
ID : 2
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main@L5.1
Format settings, CABAC : Yes
Format settings, ReFrames : 3 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 4mn 41s
Source duration : 3mn 28s
Bit rate : 2 143 Kbps
Nominal bit rate : 3 000 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Variable
Frame rate : 23.432 fps
Minimum frame rate : 0.022 fps
Maximum frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.044
Stream size : 53.1 MiB (42%)
Source stream size : 53.1 MiB (42%)
Writing library : x264 core 142 r2389 956c8d8
Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x1:0 / me=dia / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=6 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=3000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language : English
Tagged date : UTC 2016-06-10 15:32:15
Video #3
ID : 3
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main@L5.1
Format settings, CABAC : Yes
Format settings, ReFrames : 3 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 4mn 50s
Source duration : 1mn 35s
Nominal bit rate : 3 000 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.048
Source stream size : 33.4 MiB (26%)
Writing library : x264 core 142 r2389 956c8d8
Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x1:0 / me=dia / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=6 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=3000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language : English
Tagged date : UTC 2016-06-10 15:32:15
如您所见,"No suitable destination track found..." 行中恰好有“#”个视频部分,这很奇怪。到目前为止,最接近解决我的问题的是这个命令:
MP4Box -force-cat -add Awards\ -\ Recognitions\ Screens\ Video.mp4 -cat Cornaro\ USLUGE\ video1.mp4 -cat Cornaro\ USLUGE\ video1.mp4 -cat DIOCLETIANS_BREAKFAST.mp4 -cat FLAVOURS_OF_DALMATIA.mp4 -cat Prognoza.mp4 -cat Restaurants\ -\ Bars\ 2016.mp4 -cat WineHappyHour3.mp4 out.mp4
但它连续两次显示第二个视频 (Cornaro USLUGE video1.mp4),然后休息正常。我真的不知道该怎么办。任何帮助将不胜感激。
这是 https://github.com/gpac/gpac/issues/549 的重复答案:FFmpeg 有时会在 SPS 中添加 PAR 可选字段。因此MP4Box检测到不同的SPS,无法合并。
作为解决方法,GPAC 是否应该能够检测到此更改仍在讨论中。请针对根本问题发表意见:https://github.com/gpac/gpac/issues/13.
注意@IncBrain:bs-switching 是 DASH 的一个特性,不是 MP4。
您还可以使用 ffmpeg
来连接您的 mp4 文件,如 here:
首先,您必须像这样将视频转码为 MPEG2-TS:
ffmpeg -i vid1.mp4 -c:v copy -bsf:v h264_mp4toannexb -f mpegts inter1.ts
ffmpeg -i vid2.mp4 -c:v copy -bsf:v h264_mp4toannexb -f mpegts inter2.ts
ffmpeg -i vid3.mp4 -c:v copy -bsf:v h264_mp4toannexb -f mpegts inter3.ts
...
然后将它们连接起来:
ffmpeg -i "concat:inter1.ts|inter2.ts|inter3.ts" -c copy out.mp4
我用 your videos 测试了它(link 你在 github 上发帖)并且它工作得很好。
也可以在不使用命名管道创建中间 .ts 文件的情况下执行此操作,这看起来类似于:
mkfifo temp1 temp2
ffmpeg -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts temp1 2> /dev/null & \
ffmpeg -i input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts temp2 2> /dev/null & \
ffmpeg -f mpegts -i "concat:temp1|temp2" -c copy output.mp4
but it is showing second video (Cornaro USLUGE video1.mp4) two times in row
在我看来,您从命令行添加了两次。
感谢您的帮助,但我需要使用 MP4Box 来合并视频而不是 ffmpeg,因为我的 RPi3 上只安装了 MP4Box。 无论如何,更改命令并可以确认它像魅力一样有效(即使视频缺少 PAR 参数信息):
MP4Box -force-cat -cat Awards\ -\ Recognitions\ Screens\ Video.mp4 -cat Cornaro\ USLUGE\ video1.mp4 -cat Cornaro\ USLUGE\ video1.mp4 -cat DIOCLETIANS_BREAKFAST.mp4 -cat FLAVOURS_OF_DALMATIA.mp4 -cat Prognoza.mp4 -cat Restaurants\ -\ Bars\ 2016.mp4 -cat WineHappyHour3.mp4 output.mp4