如何解决使用 ffmpeg 将内容类型为 video/quicktime 的视频转换为 video/mp4
我有一个奇怪的问题。我从用 iPhone 录制的视频文件开始。输出为 video.mov
。我使用 ffmpeg 将其转换为 mp4:
ffmpeg -i video.mov -vcodec h264 -acodec aac video.mp4
如果我使用像 exiftool 这样的工具来显示元数据,content-type
的输出为 video/mp4
似乎都是正确的。但是我接收视频的后端使用一个名为 Apache Tika 的库来提取内容类型,这里的结果是:video/quicktime
。
// byteArray: Array[Byte]
val tika = new TikaConfig()
val Metadata = new Metadata()
val contentType = tika.getDetector.detect(TikaInputStream.get(byteArray),Metadata)
顺便说一句:如果我使用视频编辑程序(在我的情况下为 DaVinci Resolve),我可以加载视频、调整设置并将编解码器显式设置为 mp4、导出视频,然后生成的文件工作,Apache Tika 提取所需的内容类型。这是一种解决方法,但它无法扩展,我喜欢通过 ffmpeg 自动执行此过程。
版本:
蒂卡:1.22
ffmpeg:4.4
ffmpeg 日志:
$ffmpeg -i video.mov -vcodec h264 -acodec aac video.mp4
ffmpeg version 4.4 copyright (c) 2000-2021 the FFmpeg developers
built with Apple clang version 12.0.0 (clang-1200.0.32.29)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.4_2 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-avresample --enable-videotoolBox
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
Input #0,mov,mp4,m4a,3gp,3g2,mj2,from 'video.mov':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2021-06-24T11:19:37.000000Z
com.apple.quicktime.location.accuracy.horizontal: 65.000000
com.apple.quicktime.location.ISO6709: +52.5554+013.3772+042.268/
com.apple.quicktime.make: Apple
com.apple.quicktime.model: iPhone 8
com.apple.quicktime.software: 14.4.2
com.apple.quicktime.creationdate: 2021-06-24T13:19:36+0200
Duration: 00:00:09.83,start: 0.000000,bitrate: 7954 kb/s
Stream #0:0(und): Video: hevc (Main) (hvc1 / 0x31637668),yuv420p(tv,bt709),1920x1080,7810 kb/s,30.01 fps,30 tbr,600 tbn,600 tbc (default)
Metadata:
rotate : 90
creation_time : 2021-06-24T11:19:37.000000Z
handler_name : Core Media Video
vendor_id : [0][0][0][0]
encoder : HEVC
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D),44100 Hz,mono,fltp,96 kb/s (default)
Metadata:
creation_time : 2021-06-24T11:19:37.000000Z
handler_name : Core Media Audio
vendor_id : [0][0][0][0]
Stream #0:2(und): Data: none (mebx / 0x7862656D),0 kb/s (default)
Metadata:
creation_time : 2021-06-24T11:19:37.000000Z
handler_name : Core Media Metadata
Stream #0:3(und): Data: none (mebx / 0x7862656D),0 kb/s (default)
Metadata:
creation_time : 2021-06-24T11:19:37.000000Z
handler_name : Core Media Metadata
Stream #0:4(und): Data: none (mebx / 0x7862656D),34 kb/s (default)
Metadata:
creation_time : 2021-06-24T11:19:37.000000Z
handler_name : Core Media Metadata
Stream mapping:
Stream #0:0 -> #0:0 (hevc (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop,[?] for help
[libx264 @ 0x7fbe08009400] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7fbe08009400] profile High,level 4.0,4:2:0,8-bit
[libx264 @ 0x7fbe08009400] 264 - core 163 r3060 5db6aa6 - H.264/MPEG-4 AVC codec - copyleft 2003-2021 - http://www.videolan.org/x264.html - options: 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=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=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0,to 'video.mp4':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
com.apple.quicktime.creationdate: 2021-06-24T13:19:36+0200
com.apple.quicktime.location.accuracy.horizontal: 65.000000
com.apple.quicktime.location.ISO6709: +52.5554+013.3772+042.268/
com.apple.quicktime.make: Apple
com.apple.quicktime.model: iPhone 8
com.apple.quicktime.software: 14.4.2
encoder : Lavf58.76.100
Stream #0:0(und): Video: h264 (avc1 / 0x31637661),bt709,progressive),1080x1920,q=2-31,30 fps,15360 tbn (default)
Metadata:
encoder : Lavc58.134.100 libx264
creation_time : 2021-06-24T11:19:37.000000Z
handler_name : Core Media Video
vendor_id : [0][0][0][0]
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
displaymatrix: rotation of -0.00 degrees
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D),69 kb/s (default)
Metadata:
creation_time : 2021-06-24T11:19:37.000000Z
handler_name : Core Media Audio
vendor_id : [0][0][0][0]
encoder : Lavc58.134.100 aac
frame= 295 fps= 18 q=-1.0 Lsize= 9980kB time=00:00:09.82 bitrate=8323.6kbits/s speed=0.614x
video:9884kB audio:85kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.103401%
[libx264 @ 0x7fbe08009400] frame I:6 Avg QP:21.84 size: 50301
[libx264 @ 0x7fbe08009400] frame P:217 Avg QP:24.23 size: 35435
[libx264 @ 0x7fbe08009400] frame B:72 Avg QP:24.97 size: 29582
[libx264 @ 0x7fbe08009400] consecutive B-frames: 66.8% 0.7% 4.1% 28.5%
[libx264 @ 0x7fbe08009400] mb I I16..4: 6.7% 88.9% 4.4%
[libx264 @ 0x7fbe08009400] mb P I16..4: 4.2% 32.9% 0.5% P16..4: 49.6% 5.0% 2.3% 0.0% 0.0% skip: 5.5%
[libx264 @ 0x7fbe08009400] mb B I16..4: 0.9% 6.9% 0.0% B16..8: 51.8% 7.7% 0.8% direct:12.2% skip:19.6% L0:50.1% L1:46.9% BI: 3.0%
[libx264 @ 0x7fbe08009400] 8x8 transform intra:87.7% inter:88.8%
[libx264 @ 0x7fbe08009400] coded y,uvDC,uvAC intra: 59.2% 41.2% 0.9% inter: 38.3% 57.3% 0.0%
[libx264 @ 0x7fbe08009400] i16 v,h,dc,p: 15% 23% 8% 53%
[libx264 @ 0x7fbe08009400] i8 v,ddl,ddr,vr,hd,vl,hu: 16% 14% 29% 7% 8% 7% 7% 6% 6%
[libx264 @ 0x7fbe08009400] i4 v,hu: 23% 18% 18% 9% 11% 7% 7% 4% 3%
[libx264 @ 0x7fbe08009400] i8c dc,v,p: 60% 20% 18% 1%
[libx264 @ 0x7fbe08009400] Weighted P-Frames: Y:3.2% UV:2.3%
[libx264 @ 0x7fbe08009400] ref P L0: 54.2% 10.7% 22.2% 12.5% 0.4%
[libx264 @ 0x7fbe08009400] ref B L0: 75.5% 19.6% 4.9%
[libx264 @ 0x7fbe08009400] ref B L1: 88.7% 11.3%
[libx264 @ 0x7fbe08009400] kb/s:8234.01
[aac @ 0x7fbe0802e000] Qavg: 446.889
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。