I have an mp4 related issue. I’m not very good in video processing related stuff. We have a problem with an image file that is recorded via HTTP Live Streaming (HLS) from a live stream. The HLS chunks are just put together and saved on the file system as .mp4 file. This file cannot be played with Apple QuickTime. VLC can play it. But it is a requirement that it can be played with QuickTime.
However, I found a solution that works. When I use the ffmpeg command -reset_timestamps, the video file can be played with QuickTime. I also see which parameter changes. It’s the start value.
Before use of the command:
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)
Use of the command:
ffmpeg -i recorded_file.mp4 output.mp4 -reset_timestamps 0
File after use of the command:
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
A lot of the text output changes but the line with the duration, start and bitrate is interesting, as the start value is set to near zero.
Duration: 00:25:00.04, start: 0.021333, bitrate: 1358 kb/s
So to use this solution would be enough. The problem is, I cannot use ffmpeg in the solution that downloads the file (it's for Android). So I try to find a way to do this in Java. However, as I have not much experience in Video processing, I can’t figure out, what this ffmpeg command does and therefore don’t know in which direction to look for a Java solution.
Is there a library that may do the same operation in Java or is there an easy way to do it myself in Java (like adjusting the file timestamp)?
Thanks for you help!
EDIT: The whole console output is now shown, instead of just a part of it.