有时我会意外下载 VR(虚拟现实)视频。我无法在 Linux 机器上观看 VR 视频(即使在 macOS 上也不行)。
如何识别 VR 视频(mediainfo
或类似工具)并将其从文件夹中删除/torrents/complete
?
以下为视频元数据示例:
$ mediainfo example.mp4
General
Complete name : example.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom (isom/iso2/avc1/mp41)
File size : 83.1 MiB
Duration : 9 min 40 s
Overall bit rate : 1 201 kb/s
Writing application : Lavf58.0.100
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : [email protected]
Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, ReFrames : 4 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 9 min 40 s
Bit rate : 1 067 kb/s
Width : 1 440 pixels
Height : 720 pixels
Display aspect ratio : 2.000
Frame rate mode : Constant
Frame rate : 25.000 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.041
Stream size : 73.8 MiB (89%)
Writing library : x264 core 152 r19 ba24899
Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x3:0x3 / me=dia / subme=1 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=12 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=1 / keyint=125 / keyint_min=12 / scenecut=0 / intra_refresh=0 / rc=crf / mbtree=0 / crf=26.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / pb_ratio=1.30 / aq=1:1.00
Codec configuration box : avcC
Audio
ID : 2
Format : AAC LC
Format/Info : Advanced Audio Codec Low Complexity
Codec ID : mp4a-40-2
Duration : 9 min 40 s
Bit rate mode : Constant
Bit rate : 128 kb/s
Channel(s) : 6 channels
Channel layout : C L R Ls Rs LFE
Sampling rate : 48.0 kHz
Frame rate : 46.875 FPS (1024 SPF)
Compression mode : Lossy
Stream size : 8.86 MiB (11%)
Default : Yes
Alternate group : 1
谢谢:
我用了
find . -type f -name '[^.]*.mp4' -exec bash -c 'ratio=$(ffprobe -loglevel error -select_streams v:0 -show_entries stream=display_aspect_ratio -of csv=p=0 "$1"); if [[ "$ratio" == 2:1 ]]; then echo "$1"; fi' _ {} \;
它似乎rtorrent
创建了点文件。
我只会出现一个误报输出:
mediainfo xxx.mp4
General
Complete name : xxx.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom (isom/iso2/avc1/mp41)
File size : 613 MiB
Duration : 27 min 38 s
Overall bit rate mode : Variable
Overall bit rate : 3 099 kb/s
Encoded date : UTC 2013-06-12 05:00:00
Tagged date : UTC 2013-06-12 05:00:00
Writing application : Lavf53.6.0
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L3
Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, ReFrames : 4 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 27 min 38 s
Bit rate : 3 000 kb/s
Width : 640 pixels
Height : 320 pixels
Display aspect ratio : 2.000
Frame rate mode : Constant
Frame rate : 24.000 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.610
Stream size : 590 MiB (96%)
Writing library : x264 core 116
Encoding settings : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=24 / 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
Encoded date : UTC 2013-06-12 05:00:00
Tagged date : UTC 2013-06-12 05:00:00
Codec configuration box : avcC
Audio
ID : 2
Format : AAC LC
Format/Info : Advanced Audio Codec Low Complexity
Codec ID : mp4a-40-2
Duration : 27 min 38 s
Bit rate mode : Variable
Bit rate : 107 kb/s
Maximum bit rate : 128 kb/s
Channel(s) : 2 channels
Channel layout : L R
Sampling rate : 44.1 kHz
Frame rate : 43.066 FPS (1024 SPF)
Compression mode : Lossy
Stream size : 21.1 MiB (3%)
Language : English
Encoded date : UTC 2013-06-12 05:00:00
Tagged date : UTC 2013-06-12 05:00:00
答案1
根据您提供的信息,没有万无一失的方法,因为没有列出 VR 视频所独有的内容。
但是,也许你可以假设任何具有 2:1 显示宽高比的视频都可能是 VR:
#!/bin/bash
cd "/torrents/complete" || exit
for f in *.mp4; do
ratio=$(ffprobe -loglevel error -select_streams v:0 -show_entries stream=display_aspect_ratio -of csv=p=0 "$f")
if [ "$ratio" = 2:1 ]
then
echo "$f"
fi
done
上述脚本将仅打印要删除的文件的名称。如果这些名称匹配正确,您可以更改echo "$f"
为rm -f "$f"
。
或者使用递归版本find
:
cd "/torrents/complete"
find . -type f -name '*.mp4' -exec bash -c 'ratio=$(ffprobe -loglevel error -select_streams v:0 -show_entries stream=display_aspect_ratio -of csv=p=0 "$1"); if [[ "$ratio" == 2:1 ]]; then echo "$1"; fi' _ {} \;
上述命令将仅打印要删除的文件的名称。如果这些名称匹配正确,您可以更改echo "$1"
为rm -f "$1"
。