我正在使用JavaCV FFmpegFrameRecorder类将Android的相机预览帧编码为视频.
目标是复制以下命令行的结果:
ffmpeg -i input.mp4 -metadata:s:v:0 rotate="90" output.mp4
Run Code Online (Sandbox Code Playgroud)
我修改了startUnsafe()如下方法,但无法生成所需的输出:
if ((video_st = avformat_new_stream(oc, video_codec)) != null) {
video_c = video_st.codec();
video_c.codec_id(oformat.video_codec());
video_c.codec_type(AVMEDIA_TYPE_VIDEO);
...
AVDictionary avDictionary = new AVDictionary(null);
av_dict_set(avDictionary, "rotate", "90", 0);
video_st.metadata(avDictionaty);
...
}
...
avformat_write_header(oc, (PointerPointer) null);
Run Code Online (Sandbox Code Playgroud)
这仍然可以正确编码视频,但添加的元数据永远不会出现在ffprobe上.如果有帮助,视频编码为h264.
顺便说一句,这是ffprobe输出:
ffprobe version 2.3.3 Copyright (c) 2007-2014 the FFmpeg developers
built on Jan 22 2015 18:22:57 with Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.3.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda …Run Code Online (Sandbox Code Playgroud) 我正在将 h264 编码的视频数据和 PCM g711 编码的音频数据混合到.mov媒体容器中。我试图在标题上写入元数据,但当我在 Windows 上转到文件->右键单击->属性->详细信息时,元数据没有显示,在 Ubuntu 中也是如此。这是我的代码 -
// Instead of creating new AVDictionary object, I also tried following way
// stated here: http://stackoverflow.com/questions/17024192/how-to-set-header-metadata-to-encoded-video
// but no luck
AVDictionary* pMetaData = m_pFormatCtx->metadata;
av_dict_set(&pMetaData, "title", "Cloud Recording", 0);
av_dict_set(&pMetaData, "artist", "Foobar", 0);
av_dict_set(&pMetaData, "copyright", "Foobar", 0);
av_dict_set(&pMetaData, "filename", m_sFilename.c_str(), 0);
time_t now = time(0);
struct tm tStruct = *localtime(&now);
char date[100];
strftime(date, sizeof(date), "%c", &tStruct); // i.e. Thu Aug 23 14:55:02 2001
av_dict_set(&pMetaData, "date", date, 0); …Run Code Online (Sandbox Code Playgroud)