【发布时间】:2014-02-01 08:21:55
【问题描述】:
我有一个与 mp4 相关的问题。我不太擅长视频处理相关的东西。我们遇到了通过 HTTP Live Streaming (HLS) 从实时流中记录的图像文件的问题。 HLS 块只是放在一起并作为 .mp4 文件保存在文件系统中。此文件无法使用 Apple QuickTime 播放。 VLC 可以播放。但前提是能用 QuickTime 播放。
但是,我找到了一个可行的解决方案。当我使用 ffmpeg 命令 -reset_timestamps 时,可以使用 QuickTime 播放视频文件。我还看到了哪些参数发生了变化。这是起始值。
使用命令前:
ffmpeg -i recorded_file.mp4
ffmpeg version 1.2.4 Copyright (c) 2000-2013 the FFmpeg developers
built on Jan 9 2014 09:06:57 with Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/1.2.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
libavutil 52. 18.100 / 52. 18.100
libavcodec 54. 92.100 / 54. 92.100
libavformat 54. 63.104 / 54. 63.104
libavdevice 54. 3.103 / 54. 3.103
libavfilter 3. 42.103 / 3. 42.103
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
[h264 @ 0x7fcb7b015a00] non-existing SPS 2 referenced in buffering period
[h264 @ 0x7fcb7b015a00] non-existing PPS referenced
[h264 @ 0x7fcb7b015a00] non-existing SPS 2 referenced in buffering period
[h264 @ 0x7fcb7b015a00] non-existing PPS 0 referenced
[h264 @ 0x7fcb7b015a00] decode_slice_header error
[h264 @ 0x7fcb7b015a00] no frame!
[mpegts @ 0x7fcb7b004a00] max_analyze_duration 5000000 reached at 5013333 microseconds
[mpegts @ 0x7fcb7b004a00] Could not find codec parameters for stream 2 (Unknown: none ([21][0][0][0] / 0x0015)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[NULL @ 0x7fcb7b016a00] start time is not set in estimate_timings_from_pts
Input #0, mpegts, from 'recorded_file.mp4':
Duration: 00:25:00.01, start: 68428.580933, bitrate: 1499 kb/s
Program 1
Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 1024x576 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1[0x101]: Audio: aac ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 124 kb/s
Stream #0:2[0x102]: Unknown: none ([21][0][0][0] / 0x0015)
命令的使用:
ffmpeg -i recorded_file.mp4 output.mp4 -reset_timestamps 0
使用命令后的文件:
ffmpeg -i output.mp4
ffmpeg version 1.2.4 Copyright (c) 2000-2013 the FFmpeg developers
built on Jan 9 2014 09:06:57 with Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/1.2.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
libavutil 52. 18.100 / 52. 18.100
libavcodec 54. 92.100 / 54. 92.100
libavformat 54. 63.104 / 54. 63.104
libavdevice 54. 3.103 / 54. 3.103
libavfilter 3. 42.103 / 3. 42.103
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf54.63.104
Duration: 00:25:00.04, start: 0.021333, bitrate: 1358 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1024x576 [SAR 1:1 DAR 16:9], 1224 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s
Metadata:
handler_name : SoundHandler
很多文本输出发生变化,但持续时间、开始和比特率的行很有趣,因为开始值设置为接近零。
Duration: 00:25:00.04, start: 0.021333, bitrate: 1358 kb/s
所以使用这个解决方案就足够了。问题是,我不能在下载文件的解决方案中使用 ffmpeg(它适用于 Android)。所以我尝试在Java中找到一种方法来做到这一点。但是,由于我在视频处理方面没有太多经验,所以我无法弄清楚这个 ffmpeg 命令是做什么的,因此不知道从哪个方向寻找 Java 解决方案。
是否有一个库可以在 Java 中执行相同的操作,或者是否有一种简单的方法可以在 Java 中自己执行(例如调整文件时间戳)?
感谢您的帮助!
编辑:现在显示整个控制台输出,而不仅仅是其中的一部分。
【问题讨论】:
-
您应该包含 ffmpeg 编码命令的完整控制台输出。
标签: java android video ffmpeg mp4