我一直在开发使用mediastreamrecorder和whammy.js捕获视频和音频的媒体流应用程序。
在这个过程中,我发现了一个问题,我怀疑它与whammy.js呈现和存储到blob var中的方式有关。
我对此有所了解,因为我试图使用ffmpeg
将音频(wav)和视频(webm)编码为mp4。
出于任何原因,我根本不知道,有些视频编码正确但其他视频没有。当它编码不正确时,视频不流畅,但音频是。
我一直在使用这个ffmpeg句子:
'ffmpeg -i path/to/file.wav -i path/to/file.webm -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -map 0:0 -map 1:0 -c:v libx264 -preset ultrafast -qp 0 -c:a libvo_aacenc -b:a 128k path/to/file.mp4'
然后用ffprobe检查一个良好的转换和使用相同的相机转换成mp4的错误我得到了它的结果:
对于好人:
ffprobe version N-77003-g64f7db5 Copyright (c) 2007-2015 the FFmpeg developers
built with gcc 5.2.1 (Ubuntu 5.2.1-22ubuntu2) 20151010
configuration: --prefix=/home/devstarlight/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/devstarlight/ffmpeg_build/include --extra-ldflags=-L/home/devstarlight/ffmpeg_build/lib --bindir=/home/devstarlight/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree
libavutil 55. 9.100 / 55. 9.100
libavcodec 57. 16.101 / 57. 16.101
libavformat 57. 19.100 / 57. 19.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 19.100 / 6. 19.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/devstarlight/Escritorio/178.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.36.100
Duration: 00:00:04.50, start: 0.036281, bitrate: 5821 kb/s
Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 129 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #0:1(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv420p, 400x400 [SAR 1:1 DAR 1:1], 5841 kb/s, 16 fps, 16 tbr, 16384 tbn, 32 tbc (default)
Metadata:
handler_name : VideoHandler
错误的转换:
ffprobe version N-77003-g64f7db5 Copyright (c) 2007-2015 the FFmpeg developers
built with gcc 5.2.1 (Ubuntu 5.2.1-22ubuntu2) 20151010
configuration: --prefix=/home/devstarlight/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/devstarlight/ffmpeg_build/include --extra-ldflags=-L/home/devstarlight/ffmpeg_build/lib --bindir=/home/devstarlight/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree
libavutil 55. 9.100 / 55. 9.100
libavcodec 57. 16.101 / 57. 16.101
libavformat 57. 19.100 / 57. 19.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 19.100 / 6. 19.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/devstarlight/Escritorio/179.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.36.100
Duration: 00:00:04.50, start: 0.036281, bitrate: 12815 kb/s
Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #0:1(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv420p, 400x400 [SAR 1:1 DAR 1:1], 13381 kb/s, 1000.24 fps, 1k tbr, 16k tbn, 2k tbc (default)
Metadata:
handler_name : VideoHandler
然后我直接查看了webm文件,我发现坏文件中没有定义fps:
好记录:
ffprobe version N-77003-g64f7db5 Copyright (c) 2007-2015 the FFmpeg developers
built with gcc 5.2.1 (Ubuntu 5.2.1-22ubuntu2) 20151010
configuration: --prefix=/home/devstarlight/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/devstarlight/ffmpeg_build/include --extra-ldflags=-L/home/devstarlight/ffmpeg_build/lib --bindir=/home/devstarlight/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree
libavutil 55. 9.100 / 55. 9.100
libavcodec 57. 16.101 / 57. 16.101
libavformat 57. 19.100 / 57. 19.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 19.100 / 6. 19.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, matroska,webm, from '/home/devstarlight/Escritorio/179.webm':
Metadata:
encoder : whammy
Duration: 00:00:04.25, start: 0.000000, bitrate: 1859 kb/s
Stream #0:0: Video: vp8, yuv420p, 400x400, SAR 1:1 DAR 1:1, 1k tbr, 1k tbn, 1k tbc (default)
糟糕的记录:
ffprobe version N-77003-g64f7db5 Copyright (c) 2007-2015 the FFmpeg developers
built with gcc 5.2.1 (Ubuntu 5.2.1-22ubuntu2) 20151010
configuration: --prefix=/home/devstarlight/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/devstarlight/ffmpeg_build/include --extra-ldflags=-L/home/devstarlight/ffmpeg_build/lib --bindir=/home/devstarlight/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree
libavutil 55. 9.100 / 55. 9.100
libavcodec 57. 16.101 / 57. 16.101
libavformat 57. 19.100 / 57. 19.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 19.100 / 6. 19.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, matroska,webm, from '/home/devstarlight/Escritorio/178.webm':
Metadata:
encoder : whammy
Duration: 00:00:04.36, start: 0.000000, bitrate: 1461 kb/s
Stream #0:0: Video: vp8, yuv420p, 400x400, SAR 1:1 DAR 1:1, 16 fps, 16 tbr, 1k tbn, 1k tbc (default)
ffmpeg
输出速率选项(-r)为空,速率被强制为25 fps(因为实际上webm
它不存在)。
该问题是在任何时候注册的,还是有人知道如何解决?
感谢您的建议。