gpt4 book ai didi

video - 如何使用 ffmpeg 将 WebM 音频(Opus)和 MP4 视频(H.264)合并为一个 MP4 文件

转载 作者:行者123 更新时间:2023-12-04 16:27:04 28 4
gpt4 key购买 nike

我正在尝试将 WebM 文件与 Opus 音频 + MP4 文件与 H.264 视频合并到 MP4 文件中:

ffmpeg -i audio.webm -i video.mp4 -c copy output.mp4

但是,我收到一个错误:
[mp4 @ 0x56105a6d0a40] opus in MP4 support is experimental, add '-strict -2' if you want to use it.
Could not write header for output file #0 (incorrect codec parameters ?): Experimental feature

完整的日志:
ffmpeg version n4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.3.0 (Arch Linux 9.3.0-1)
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-version3
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, matroska,webm, from 'audio.webm':
Metadata:
ENCODER : Lavf58.29.100
Duration: 00:00:10.01, start: -0.007000, bitrate: 106 kb/s
Stream #0:0: Audio: opus, 48000 Hz, stereo, fltp (default)
Metadata:
ENCODER : Lavc58.54.100 libopus
DURATION : 00:00:10.008000000
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Duration: 00:00:10.00, start: 0.000000, bitrate: 2796 kb/s
Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 2793 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
[mp4 @ 0x56105a6d0a40] track 1: codec frame size is not set
[mp4 @ 0x56105a6d0a40] opus in MP4 support is experimental, add '-strict -2' if you want to use it.
Could not write header for output file #0 (incorrect codec parameters ?): Experimental feature
Stream mapping:
Stream #1:0 -> #0:0 (copy)
Stream #0:0 -> #0:1 (copy)
Last message repeated 1 times

更新 1

我试过这个命令:

ffmpeg -i audio.webm -i video.mp4 -c copy -strict 实验输出.mp4

但出现了一个新错误:

[mov,mp4,m4a,3gp,3g2,mj2 @ 00000225b1eb07c0] Format mov,mp4,m4a,3gp,3g2,mj2 detected only with low score of 1, misdetection possible! [mov,mp4,m4a,3gp,3g2,mj2 @ 00000225b1eb07c0] moov atom not found inputVideo.mp4: Invalid data found when processing input



更新 2

我发现我的输入视频已损坏,导致更新 1 中出现错误。

因此,一旦我在 Update 1 中运行该命令,它确实给了我一个更大的 mp4 文件,但该文件仍然没有音频。

最佳答案

问题 #1:MP4 中的作品

添加 -strict -2 (或别名 -strict experimental )如您的日志中所述:

[mp4 @ 0x5630ee4eb000] opus in MP4 support is experimental, add '-strict -2' if you want to use it.



示例命令:
ffmpeg -i audio.webm -i video.mp4 -c copy -strict experimental output.mp4

但是, ffmpeg 的较新版本不再认为 MP4 中的 Opus 是实验性的,所以如果你升级你不需要添加 -strict .

截至本答案的最新版本是 4.2.2。使用来自 git master 分支的版本或等待 4.3 跳过使用 -strict .

问题 #2:处理输入时发现无效数据

输入文件已损坏。不幸的是,什么都没有 ffmpeg可以做到这一点。

问题 3:没有音频

这意味着您的播放器、浏览器或设备不支持 MP4 容器中的 Opus 音频。您需要将音频重新编码为 AAC:
ffmpeg -i audio.webm -i video.mp4 -c copy -c:a aac output.mp4

关于video - 如何使用 ffmpeg 将 WebM 音频(Opus)和 MP4 视频(H.264)合并为一个 MP4 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61777314/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com