【发布时间】:2019-04-19 02:47:12
【问题描述】:
来自 FFMPEG 的 GitHub,我使用 encode_video.c 生成 1 秒视频。这是有问题的示例:https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/encode_video.c
我编译:gcc -Wall -o ffencode encode_video.c -lavcodec -lavutil -lz -lm
干净编译,零警告。
我通过运行测试程序:./ffencode video.mp4 libx264
打印出大量统计信息(预计基于源代码)以及 ffmpeg 日志,但最终没有错误或警告。
但是,生成的输出video.mp4,只能由ffplay播放,VLC Player(以及谷歌浏览器)无法播放视频。
通过vlc 命令行播放它实际上会打印:
[00007ffd3550fec0] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
TagLib: MP4: Invalid atom size
TagLib: MP4: Invalid atom size
TagLib: MP4: Invalid atom size
查看ffprobe 输出,比特率和持续时间字段为空:
Input #0, h264, from 'video.mp4':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p(progressive), 352x288, 25 fps, 25 tbr, 1200k tbn, 50 tbc
我正在使用具有以下配置的 ffmpeg 4.1:
ffprobe version 4.1 Copyright (c) 2007-2018 the FFmpeg developers
built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gpl --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-opencl --enable-videotoolbox
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
任何想法如何解决这个问题?看到 API 的官方示例缺少这样的基本信息,真是令人惊讶。
【问题讨论】:
标签: c video ffmpeg video-encoding libavcodec