我尝试使用 ffmpeg 将 h264 基本流和 aac 音频流合并为 mp4 文件。h264 流使用 x264 编码。
多路复用的 mp4 播放正常。但是 ffmpeg 总是会抛出警告“数据包中流 0 的时间戳未设置”。
这是一个基本流,那么我应该在哪里获取时间戳?是我做错了什么,还是只是 ffmpeg 的问题?
ffmpeg -r 50.000 -i test_x264.264 -i test.aac -acodec copy -vcodec copy test_720p50_ffmpeg.mp4 ffmpeg version N-87353-g183fd30 Copyright (c) 2000-2017 the FFmpeg developers built with gcc 7.2.0 (GCC) configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib libavutil 55. 76.100 / 55. 76.100 libavcodec 57.106.101 / 57.106.101 libavformat 57. 82.101 / 57. 82.101 libavdevice 57. 8.101 / 57. 8.101 libavfilter 6.105.100 / 6.105.100 libswscale 4. 7.103 / 4. 7.103 libswresample 2. 8.100 / 2. 8.100 libpostproc 54. 6.100 / 54. 6.100 Input #0, h264, from 'test_x264.264': Duration: N/A, bitrate: N/A Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 1200k tbn, 100 tbc [aac @ 034eea40] Estimating duration from bitrate, this may be inaccurate Input #1, aac, from 'test.aac': Duration: 00:02:48.13, bitrate: 173 kb/s Stream #1:0: Audio: aac (LC), 48000 Hz, stereo, fltp, 173 kb/s Output #0, mp4, to 'test_720p50_ffmpeg.mp4': Metadata: encoder : Lavf57.82.101 Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 50 fps, 50 tbr, 12800 tbn, 50 tbc Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 173 kb/s Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #1:0 -> #0:1 (copy) Press [q] to stop, [?] for help [mp4 @ 035ce7c0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly [mp4 @ 035ce7c0] pts has no value Last message repeated 750 times [mp4 @ 035ce7c0] pts has no value 7424kB time=00:00:14.98 bitrate=4059.9kbits/s speed= 30x Last message repeated 752 times ... frame= 8974 fps=1477 q=-1.0 Lsize= 99764kB time=00:02:59.45 bitrate=4554.2kbits/s speed=29.5x video:96064kB audio:3563kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.137808%