I have this video I can watch on MPC-HC alright, but I've been trying to re-encode it with FFMPEG to no avail.
The video unerringly stops 5 minutes into the clip and freezes. Checking the key frames it would seem like the last keyframe is indeed at around the 5 minute mark, even though the video is completely watchable for its entire duration of upwards an hour. I've been looking into finding a way to repopulate the index of keyframes or something, but the answer eludes me.
Both Handbrake and Premiere Pro fails to handle this video properly as well. Premiere Pro just imports it as though it's 5 minutes long, and Handbrake freezes when the encoding reaches the 5 minute mark.
Even doing a -c copy would give me an output that terminates at the 5 minute mark.
What can I do to fix this?
Edit: Added log as requested.
ffmpeg version git-2020-02-27-9b22254 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9.2.1 (GCC) 20200122
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
libavutil 56. 42.100 / 56. 42.100
libavcodec 58. 73.102 / 58. 73.102
libavformat 58. 39.101 / 58. 39.101
libavdevice 58. 9.103 / 58. 9.103
libavfilter 7. 77.100 / 7. 77.100
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
[mov,mp4,m4a,3gp,3g2,mj2 # 0000019d5f659b00] st: 0 edit list: 1 Missing key frame while searching for timestamp: 20
[mov,mp4,m4a,3gp,3g2,mj2 # 0000019d5f659b00] st: 0 edit list 1 Cannot find an index entry before timestamp: 20.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '[REDACTED].mp4':
Metadata:
major_brand : isom
minor_version : 1
compatible_brands: isom
creation_time : 2009-07-27T12:06:40.000000Z
Duration: 01:13:58.42, start: 0.000000, bitrate: 2671 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 716x480 [SAR 8:9 DAR 179:135], 2504 kb/s, SAR 29127:32768 DAR 1007794:760071, 29.97 fps, 29.97 tbr, 48k tbn, 59.94 tbc (default)
Metadata:
rotate : 0
creation_time : 2007-09-08T18:58:09.000000Z
encoder : AVC Coding
Side data:
displaymatrix: rotation of -0.00 degrees
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 159 kb/s (default)
Metadata:
creation_time : 2009-07-27T12:06:47.000000Z
handler_name : GPAC ISO Audio Handler
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 # 0000019d5f65de40] using SAR=8/9
[libx264 # 0000019d5f65de40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0000019d5f65de40] profile High 4:4:4 Predictive, level 3.0, 4:2:0, 8-bit
[libx264 # 0000019d5f65de40] 64 - core 159 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=0 mixed_ref=1 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=0 threads=9 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc=cqp mbtree=0 qp=0
Output #0, mp4, to '[REDACTED].mp4':
Metadata:
major_brand : isom
minor_version : 1
compatible_brands: isom
encoder : Lavf58.39.101
Stream #0:0(und): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p(progressive), 716x480 [SAR 29127:32768 DAR 1007794:760071], q=-1--1, 29.97 fps, 11988 tbn, 29.97 tbc (default)
Metadata:
encoder : Lavc58.73.102 libx264
creation_time : 2007-09-08T18:58:09.000000Z
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
displaymatrix: rotation of -0.00 degrees
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 192 kb/s (default)
Metadata:
creation_time : 2009-07-27T12:06:47.000000Z
handler_name : GPAC ISO Audio Handler
encoder : Lavc58.73.102 aac
frame= 9958 fps= 70 q=-1.0 Lsize= 960472kB time=00:11:13.32 bitrate=11685.6kbits/s speed=4.71x
video:944292kB audio:15836kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.035744%
[libx264 # 0000015f858dde40] frame I:46 Avg QP: 0.00 size:113701
[libx264 # 0000015f858dde40] frame P:9912 Avg QP: 0.00 size: 97026
[libx264 # 0000015f858dde40] mb I I16..4: 52.6% 10.7% 36.7%
[libx264 # 0000015f858dde40] mb P I16..4: 22.5% 5.5% 10.5% P16..4: 31.8% 15.2% 11.1% 0.0% 0.0% skip: 3.4%
[libx264 # 0000015f858dde40] 8x8 transform intra:14.3% inter:40.9%
[libx264 # 0000015f858dde40] coded y,uvDC,uvAC intra: 95.6% 84.9% 84.0% inter: 81.2% 83.0% 82.5%
[libx264 # 0000015f858dde40] i16 v,h,dc,p: 53% 44% 2% 1%
[libx264 # 0000015f858dde40] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 40% 47% 8% 1% 1% 1% 1% 1% 1%
[libx264 # 0000015f858dde40] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 33% 44% 5% 3% 5% 4% 2% 3% 1%
[libx264 # 0000015f858dde40] i8c dc,h,v,p: 12% 44% 43% 1%
[libx264 # 0000015f858dde40] Weighted P-Frames: Y:1.0% UV:0.2%
[libx264 # 0000015f858dde40] ref P L0: 59.1% 10.2% 27.8% 2.9% 0.0%
[libx264 # 0000015f858dde40] kb/s:23281.49
[aac # 0000015f85b5b880] Qavg: 182.070
Related
I have a JPG image in a directory that I update each time I got a new one and I have to send this image to a rtmp server.
I fond that ffmpeg can do that but I thougt -loop 0 is suppose to loop over the image and see if it is refreshed but when I start my command inside my app it seem to start well and end with good Return Code (0) but don't seem to loop.
Here is my ffmpeg command : '-re -loop 0 -i $pathToFile -preset ultrafast -tune zerolatency -c:v libx264 -f flv $streamUrl'
This code execute the command :
FFmpegKit.executeAsync(command, (session) async {
if (ReturnCode.isSuccess(await session.getReturnCode())) {
log('FFmpeg process exited with rc ${await session.getReturnCode()} in ${await session.getDuration()} milliseconds');
} else if (ReturnCode.isCancel(await session.getReturnCode())) {
log('FFmpeg process cancelled');
} else {
log('FFmpeg process failed with rc ${await session.getReturnCode()} in ${await session.getReturnCode()} milliseconds');
}
}, (session) {
log('Message ${session.getMessage()}');
}, (session) {
log('Statistics ${session.toString()}');
});
And finally I got those logs :
[log] Message [libx264 # 0x7ccd0b6400] 264 - core 164 - H.264/MPEG-4 AVC codec - Copyleft 2003-2022 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=7 lookahead_threads=7 sliced_threads=1 slices=7 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
[log] Message Output #0, flv, to 'rtmp://stream.stream.url.com':
[log] Message Metadata:
[log] Message encoder :
[log] Message Lavf59.27.100
[log] Message
[log] Message Stream #0:0
[log] Message : Video: h264 ([7][0][0][0] / 0x0007), yuvj422p(pc, bt470bg/unknown/unknown, progressive), 640x480, q=2-31
[log] Message ,
[log] Message 25 fps,
[log] Message 1k tbn
[log] Message
[log] Message Metadata:
[log] Message encoder :
[log] Message Lavc59.37.100 libx264
[log] Message
[log] Message Side data:
[log] Message
[log] Message cpb:
[log] Message bitrate max/min/avg: 0/0/0 buffer size: 0
[log] Message vbv_delay: N/A
[log] Message
[log] Statistics Instance of 'Statistics'
[log] Message frame= 1 fps=0.0 q=20.0 size= 21kB time=00:00:00.00 bitrate=173704.0kbits/s speed= 333x
[log] Message [flv # 0x7cf7f74d00] Failed to update header with correct duration.
[log] Message [flv # 0x7cf7f74d00] Failed to update header with correct filesize.
[log] Statistics Instance of 'Statistics'
[log] Message frame= 1 fps=0.0 q=20.0 Lsize= 21kB time=00:00:00.00 bitrate=173864.0kbits/s speed=0.0204x
[log] Message video:21kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.513382%
[log] Statistics Instance of 'Statistics'
[log] Message frame= 1 fps=0.0 q=20.0 Lsize=N/A time=00:00:00.00 bitrate=N/A speed=0.0204x
[log] Message video:21kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[log] Message [libx264 # 0x7ccd0b6400] frame I:1 Avg QP:20.00 size: 20815
[log] Message [libx264 # 0x7ccd0b6400] mb I I16..4: 100.0% 0.0% 0.0%
[log] Message [libx264 # 0x7ccd0b6400] coded y,uvDC,uvAC intra: 37.5% 22.7% 2.3%
[log] Message [libx264 # 0x7ccd0b6400] i16 v,h,dc,p: 50% 14% 24% 12%
[log] Message [libx264 # 0x7ccd0b6400] i8c dc,h,v,p: 78% 6% 15% 1%
[log] Message [libx264 # 0x7ccd0b6400] kb/s:4163.00
[log] FFmpeg process exited with rc 0 in 562 milliseconds
All of this in inside a Flutter app with the package ffmpeg_kit_flutter (the full gpl version of it).
Any one have an idea of how to loop over constantly every time the image is updated ?
Edit : I try adding -f image2 in input but it failed with :
[log] Message ffmpeg version n5.1.2
[log] Message Copyright (c) 2000-2022 the FFmpeg developers
[log] Message
I/ink.kw_deliver(30445): WaitForGcToComplete blocked ProfileSaver on HeapTrim for 28.215ms
[log] Message built with Android (7155654, based on r399163b1) clang version 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315dfbea7c137aa2e6d362dbb457e388158d)
[log] Message configuration: --cross-prefix=aarch64-linux-android- --sysroot=/files/android-sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/sysroot --prefix=/home/taner/Projects/ffmpeg-kit/prebuilt/android-arm64/ffmpeg --pkg-config=/usr/bin/pkg-config --enable-version3 --arch=aarch64 --cpu=armv8-a --target-os=android --enable-neon --enable-asm --enable-inline-asm --ar=aarch64-linux-android-ar --cc=aarch64-linux-android24-clang --cxx=aarch64-linux-android24-clang++ --ranlib=aarch64-linux-android-ranlib --strip=aarch64-linux-android-strip --nm=aarch64-linux-android-nm --extra-libs='-L/home/taner/Projects/ffmpeg-kit/prebuilt/android-arm64/cpu-features/lib -lndk_compat' --disable-autodetect --enable-cross-compile --enable-pic --enable-jni --enable-optimizations --enable-swscale --disable-static --enable-shared --enable-pthreads --enable-v4l2-m2m --disable-outdev=fbdev --disable-indev=fbdev --enable-small --disable-xmm-clobber-test --disable-debug --enable-lto --disable-neon-clobber-test --disable-programs --disable-postproc --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-sndio --disable-schannel --disable-securetransport --disable-xlib --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --disable-videotoolbox --disable-audiotoolbox --disable-appkit --disable-alsa --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gmp --enable-gnutls --enable-libmp3lame --enable-libass --enable-iconv --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxml2 --enable-libopencore-amrnb --enable-libshine --enable-libspeex --enable-libdav1d --enable-libkvazaar --enable-libx264 --enable-libxvid --enable-libx265 --enable-libvidstab --enable-libilbc --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libtwolame --disable-sdl2 --enable-libvo-amrwbenc --enable-libzimg --disable-openssl --enable-zlib --enable-mediacodec --enable-gpl
[log] Message libavutil 57. 28.100 / 57. 28.100
[log] Message libavcodec 59. 37.100 / 59. 37.100
[log] Message libavformat 59. 27.100 / 59. 27.100
[log] Message libavdevice 59. 7.100 / 59. 7.100
[log] Message libavfilter 8. 44.100 / 8. 44.100
[log] Message libswscale 6. 7.100 / 6. 7.100
[log] Message libswresample 4. 7.100 / 4. 7.100
[log] Message Input #0, image2, from '/data/user/0/com.kwikwink.kw_delivery/cache/images/stream.jpg':
[log] Message Duration:
[log] Message 00:00:00.04
[log] Message , start:
[log] Message 0.000000
[log] Message , bitrate:
[log] Message N/A
[log] Message
[log] Message Stream #0:0
[log] Message : Video: mjpeg, yuvj422p(pc, bt470bg/unknown/unknown), 640x480
[log] Message ,
[log] Message 25 fps,
[log] Message 25 tbr,
[log] Message 25 tbn
[log] Message
[log] Message rtmp://stream.path.com: I/O error
[log] FFmpeg process failed with rc 1 in 1 milliseconds
I want to remux a HEVC file (without encoding). I have tried most options, even removing audio, but I cannot get an output file that plays smoothly with Apple products.
First I AirDrop any MOV from an iPhone recorded with the camera in HEVC.
Then run:
ffmpeg -i IMG_4605.MOV -c copy out.mov
Then if I send out.mov back to the iPhone and try to play it back, it plays back with glitches while seeking, like this: (original to the right)
When I try to drag the file into a new iMovie project and try to play it back, it freezes the whole iMovie app and needs a force quit.
Doing the same with the original causes no issues, so obviously there is something wrong with the way ffmpeg remuxes it, or something wrong with Apple's software.
ffmpeg -i IMG_4605.MOV
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with Apple clang version 11.0.0 (clang-1100.0.33.17)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2_2 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'IMG_4605.MOV':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2019-12-29T10:20:56.000000Z
com.apple.quicktime.location.ISO6709: +01.3602+103.9897+024.438/
com.apple.quicktime.make: Apple
com.apple.quicktime.model: iPhone 11
com.apple.quicktime.software: 13.3
com.apple.quicktime.creationdate: 2019-12-29T18:20:56+0800
Duration: 00:00:09.00, start: 0.000000, bitrate: 24882 kb/s
Stream #0:0(und): Video: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv, bt709), 3840x2160, 24659 kb/s, 29.99 fps, 29.97 tbr, 600 tbn, 600 tbc (default)
Metadata:
rotate : 90
creation_time : 2019-12-29T10:20:56.000000Z
handler_name : Core Media Video
encoder : HEVC
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 192 kb/s (default)
Metadata:
creation_time : 2019-12-29T10:20:56.000000Z
handler_name : Core Media Audio
Stream #0:2(und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
Metadata:
creation_time : 2019-12-29T10:20:56.000000Z
handler_name : Core Media Metadata
Stream #0:3(und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
Metadata:
creation_time : 2019-12-29T10:20:56.000000Z
handler_name : Core Media Metadata
Stream #0:4(und): Data: none (mebx / 0x7862656D), 17 kb/s (default)
Metadata:
creation_time : 2019-12-29T10:20:56.000000Z
handler_name : Core Media Metadata
ffmpeg -i out.mov
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with Apple clang version 11.0.0 (clang-1100.0.33.17)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2_2 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mov':
Metadata:
major_brand : qt
minor_version : 512
compatible_brands: qt
encoder : Lavf58.29.100
Duration: 00:00:09.00, start: 0.000000, bitrate: 24860 kb/s
Stream #0:0: Video: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv, bt709), 3840x2160, 24659 kb/s, 29.99 fps, 29.97 tbr, 19200 tbn, 19200 tbc (default)
Metadata:
rotate : 90
handler_name : Core Media Video
encoder : HEVC
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 192 kb/s (default)
Metadata:
handler_name : Core Media Audio
If I open out.mov in QuickTime and do a trim and export it, then it it still "broken", so I'm thinking there's nothing wrong with the actual muxing into MOV, because QuickTime is passing the error on.
I noticed that out.mov has different parameters 19200 tbn, 19200 tbc (vs original 600 tbn, 600 tbc). However, if I force set these to 600 with -video_track_timescale 600 the output file is still broken.
Anyone got some insights?
I use IframeExtractor from the git mooncatventure, it play nice the .mov file.
But when i try to read a rtsp stream, i hear no sound.
This is the FFMEG dump from the rtsp stream:
Metadata:
title : unknown
comment : unknown
Duration: N/A, start: 49435.000589, bitrate: 258 kb/s
Program 3223
No Program
Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 720x576 [SAR 64:45 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1(fra): Audio: aac ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 142 kb/s
Stream #0:2(fra): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
Stream #0:3(qad): Audio: aac ([15][0][0][0] / 0x000F), 48000 Hz, mono, fltp, 47 kb/s
Stream #0:4(qaa): Audio: aac ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 68 kb/s
And this is the dump from the local .mov file that work:
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2010-01-17 21:52:33
model : iPhone 3GS
model-eng : iPhone 3GS
date : 2010-01-17T16:52:33-0500
date-eng : 2010-01-17T16:52:33-0500
encoder : 3.1.2
encoder-eng : 3.1.2
make : Apple
make-eng : Apple
Duration: 00:00:03.25, start: 0.000000, bitrate: 3836 kb/s
Stream #0:0(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 640x480, 3695 kb/s, 30.02 fps, 30 tbr, 600 tbn, 1200 tbc
Metadata:
rotate : 90
creation_time : 2010-01-17 21:52:33
handler_name : Core Media Data Handler
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 63 kb/s
Metadata:
creation_time : 2010-01-17 21:52:33
handler_name : Core Media Data Handler
The audio class that manage sounds contain a codec detector which say that the codec CODEC_ID_AAC is found for the two input:
audioStreamBasicDesc_.mFormatFlags = 0;
switch (_audioCodecContext->codec_id) {
case CODEC_ID_MP3:
audioStreamBasicDesc_.mFormatID = kAudioFormatMPEGLayer3;
break;
case CODEC_ID_AAC:
audioStreamBasicDesc_.mFormatID = kAudioFormatMPEG4AAC;
audioStreamBasicDesc_.mFormatFlags = kMPEG4Object_AAC_Main;
NSLog(#"audio format aac %s (%d) is supported", _audioCodecContext->codec_name, _audioCodecContext->codec_id);
break;
}
I see data going into the buffer but i hear nothing. It's maybe audioStreamBasicDesc_ which has wrong settings but i can't find what.
Is it possible that it's not the same AAC codec ?
Has someone experienced the same issue ?
Any help are welcome, i'm on this problem since some days now.
Edit:
I have found a error that i had not before, i don't know how to resolve it. If i change audioStreamBasicDesc.mFramesPerPacket to 0 or divided by 2, the error message dissapear.
AudioConverterNew returned 'fmt?'
Prime failed ('fmt?'); will stop (72000/0 frames)
You could try forcing a buffer size here of some arbitraraly large size, say 480000
status = AudioQueueAllocateBufferWithPacketDescriptions(audioQueue_,
audioStreamBasicDesc_.mSampleRate * kAudioBufferSeconds / 8,
_audioCodecContext->sample_rate * kAudioBufferSeconds /
_audioCodecContext->frame_size + 1,
&audioQueueBuffer_[i]);
We run a video service streaming movies to smartphones (iOS&Android).
We are encoding in H.264+AAC and using the mp4 container.
We have a problem that long movies (60 minutes+) take a very long time to
start playing and have tracked this down to the large size of moov
atom for these movies.
For 110 minute movies the atom is as large as 4.2Mb which obviously takes a long
time to download to a smart-phone over 3G!
Is there anyway to make the moov atom smaller? We can reduce it bit
by dropping the audio sampling rate, but obviously anything below 22kHz
would not really be acceptable.
We are using ffmpeg as the encoder, and MP4Box to move the metadata
to the front of the file. Is there any way to get it to make
a smaller moov? Any other encoders out there which make a smaller moov?
For example...
Big size (280 Mb, 1h 49min) streamable mp4 (h.264, AAC) file have a big header size (4.2 Mb). File was encoded by two pass ffmpeg and MP4Box for replacing metadata into beginning of the file:
/usr/bin/ffmpeg -i /var/lib/encoder/incoming/2388 -aspect 320:210 -threads 8 -vcodec libx264 -profile baseline -level 13 -flags +loop+mv4 -cmp 256 -partitions +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 -me_method hex -subq 7 -trellis 1 -refs 5 -bf 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qmin 10 -qmax 51 -qdiff 4 -b:v 270k -maxrate 270k -bufsize 270k -g 30 -passlogfile /tmp/mediaservice/3100/video-IPH.ffmpeg -an -f rawvideo -pass 1 -y /dev/null
/usr/bin/ffmpeg -i /var/lib/encoder/incoming/2388 -aspect 320:210 -threads 8 -vcodec libx264 -profile baseline -level 13 -flags +loop+mv4 -cmp 256 -partitions +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 -me_method hex -subq 7 -trellis 1 -refs 5 -bf 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qmin 10 -qmax 51 -qdiff 4 -b:v 270k -maxrate 270k -bufsize 270k -g 30 -passlogfile /tmp/mediaservice/3100/video-IPH.ffmpeg -acodec libfaac -ac 2 -b:a 32k -ar 44100 -f mp4 -pass 2 -y /var/lib/encoder/encoded/3100/video-IPH.mp4
/usr/bin/MP4Box -quiet -tmp /tmp/mediaservice/3100/ -inter 500 /var/lib/encoder/encoded/3100/video-IPH.mp4
Media info (audio sample rate = 44100):
General
Count : 278
Count of stream of this kind : 1
Kind of stream : General
Kind of stream : General
Stream identifier : 0
Count of video streams : 1
Count of audio streams : 1
Video_Format_List : AVC
Video_Format_WithHint_List : AVC
Codecs Video : AVC
Audio_Format_List : AAC
Audio_Format_WithHint_List : AAC
Audio codecs : AAC LC
Complete name : 1348645218_970458_2465.iph.mp4
File name : 1348645218_970458_2465.iph.mp4
File extension : mp4
Format : MPEG-4
Format : MPEG-4
Format/Extensions usually used : mp4 m4v m4a m4b m4p 3gpp 3gp 3gpp2 3g2 k3g jpm jpx mqv ismv isma f4v
Commercial name : MPEG-4
Format profile : Base Media
Internet media type : video/mp4
Codec ID : isom
Codec ID/Url : http://www.apple.com/quicktime/download/standalone.html
Codec : MPEG-4
Codec : MPEG-4
Codec/Extensions usually used : mp4 m4v m4a m4b m4p 3gpp 3gp 3gpp2 3g2 k3g jpm jpx mqv ismv isma f4v
File size : 272703970
File size : 260 MiB
File size : 260 MiB
File size : 260 MiB
File size : 260 MiB
File size : 260.1 MiB
Duration : 6556027
Duration : 1h 49mn
Duration : 1h 49mn 16s 27ms
Duration : 1h 49mn
Duration : 01:49:16.027
Overall bit rate : 332767
Overall bit rate : 333 Kbps
Stream size : 4230761
Stream size : 4.03 MiB (2%)
Stream size : 4 MiB
Stream size : 4.0 MiB
Stream size : 4.03 MiB
Stream size : 4.035 MiB
Stream size : 4.03 MiB (2%)
Proportion of this stream : 0.01551
HeaderSize : 4230683
DataSize : 268473217
FooterSize : 70
IsStreamable : Yes
File last modification date : UTC 2012-09-26 12:38:19
File last modification date (local) : 2012-09-26 21:38:19
Writing application : Lavf54.6.100
Video
Count : 201
Count of stream of this kind : 1
Kind of stream : Video
Kind of stream : Video
Stream identifier : 0
ID : 1
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format/Url : http://developers.videolan.org/x264.html
Commercial name : AVC
Format profile : Baseline#L1.3
Format settings : 5 Ref Frames
Format settings, CABAC : No
Format settings, CABAC : No
Format settings, ReFrames : 5
Format settings, ReFrames : 5 frames
Format settings, GOP : M=1, N=30
Internet media type : video/H264
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Codec ID/Url : http://www.apple.com/quicktime/download/standalone.html
Codec : AVC
Codec : AVC
Codec/Family : AVC
Codec/Info : Advanced Video Codec
Codec/Url : http://developers.videolan.org/x264.html
Codec/CC : avc1
Codec profile : Baseline#L1.3
Codec settings : 5 Ref Frames
Codec settings, CABAC : No
Codec_Settings_RefFrames : 5
Duration : 6556017
Duration : 01:49:16.017
Bit rate : 270000
Bit rate : 270 Kbps
Width : 480
Width : 480 pixels
Height : 270
Height : 270 pixels
Pixel aspect ratio : 1.000
Display aspect ratio : 1.778
Display aspect ratio : 16:9
Rotation : 0.000
Frame rate mode : CFR
Frame rate mode : Constant
FrameRate_Mode_Original : VFR
Frame rate : 29.970
Frame rate : 29.970 fps
Frame count : 196484
Resolution : 8
Resolution : 8 bits
Colorimetry : 4:2:0
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8
Bit depth : 8 bits
Scan type : Progressive
Scan type : Progressive
Interlacement : PPF
Interlacement : Progressive
Bits/(Pixel*Frame) : 0.070
Stream size : 220159060
Stream size : 210 MiB (81%)
Stream size : 210 MiB
Stream size : 210 MiB
Stream size : 210 MiB
Stream size : 210.0 MiB
Stream size : 210 MiB (81%)
Proportion of this stream : 0.80732
Writing library : x264 - core 125
Writing library : x264 core 125
Writing library/Name : x264
Writing library/Version : core 125
Encoding settings : cabac=0 / ref=5 / deblock=1:0:0 / analyse=0x1:0x131 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=8 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=0 / weightp=0 / keyint=30 / keyint_min=16 / scenecut=40 / intra_refresh=0 / rc_lookahead=30 / rc=2pass / mbtree=1 / bitrate=270 / ratetol=1.0 / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / vbv_maxrate=270 / vbv_bufsize=270 / nal_hrd=none / ip_ratio=1.40 / aq=1:1.00
Tagged date : UTC 2012-09-25 07:21:37
Audio
Count : 169
Count of stream of this kind : 1
Kind of stream : Audio
Kind of stream : Audio
Stream identifier : 0
ID : 2
ID : 2
Format : AAC
Format/Info : Advanced Audio Codec
Commercial name : AAC
Format profile : LC
Codec ID : 40
Codec : AAC LC
Codec : AAC LC
Codec/Family : AAC
Codec/CC : 40
Duration : 6556027
Duration : 1h 49mn
Duration : 1h 49mn 16s 27ms
Duration : 1h 49mn
Duration : 01:49:16.027
Bit rate mode : VBR
Bit rate mode : Variable
Bit rate : 58955
Bit rate : 59.0 Kbps
Maximum bit rate : 270000
Maximum bit rate : 270 Kbps
Channel(s) : 2
Channel(s) : 2 channels
Channel positions : Front: L R
Channel positions : 2/0/0
Sampling rate : 44100
Sampling rate : 44.1 KHz
Samples count : 289120791
Compression mode : Lossy
Compression mode : Lossy
Stream size : 48314149
Stream size : 46.1 MiB (18%)
Stream size : 46 MiB
Stream size : 46 MiB
Stream size : 46.1 MiB
Stream size : 46.08 MiB
Stream size : 46.1 MiB (18%)
Proportion of this stream : 0.17717
Tagged date : UTC 2012-09-25 07:21:37
Moov atom info (/moov/trak[0] - video, /moov/trak[1] - audio) sample rate 44100:
(look stsz and stts nodes in trak)
Atom ftyp # 0 of size: 32, ends # 32
Atom moov # 32 of size: 4230651, ends # 4230683
Atom mvhd # 40 of size: 108, ends # 148
Atom trak # 148 of size: 868970, ends # 869118
Atom tkhd # 156 of size: 92, ends # 248
Atom edts # 248 of size: 36, ends # 284
Atom elst # 256 of size: 28, ends # 284
Atom mdia # 284 of size: 868834, ends # 869118
Atom mdhd # 292 of size: 32, ends # 324
Atom hdlr # 324 of size: 45, ends # 369
Atom minf # 369 of size: 868749, ends # 869118
Atom vmhd # 377 of size: 20, ends # 397
Atom dinf # 397 of size: 36, ends # 433
Atom dref # 405 of size: 28, ends # 433
Atom stbl # 433 of size: 868685, ends # 869118
Atom stsd # 441 of size: 149, ends # 590
Atom avc1 # 457 of size: 133, ends # 590
Atom avcC # 543 of size: 47, ends # 590
Atom stts # 590 of size: 24, ends # 614
Atom stss # 614 of size: 26340, ends # 26954
Atom stsc # 26954 of size: 52, ends # 27006
Atom stsz # 27006 of size: 785956, ends # 812962
Atom stco # 812962 of size: 56156, ends # 869118
Atom trak # 869118 of size: 3361468, ends # 4230586
Atom tkhd # 869126 of size: 92, ends # 869218
Atom edts # 869218 of size: 36, ends # 869254
Atom elst # 869226 of size: 28, ends # 869254
Atom mdia # 869254 of size: 3361332, ends # 4230586
Atom mdhd # 869262 of size: 32, ends # 869294
Atom hdlr # 869294 of size: 45, ends # 869339
Atom minf # 869339 of size: 3361247, ends # 4230586
Atom smhd # 869347 of size: 16, ends # 869363
Atom dinf # 869363 of size: 36, ends # 869399
Atom dref # 869371 of size: 28, ends # 869399
Atom stbl # 869399 of size: 3361187, ends # 4230586
Atom stsd # 869407 of size: 91, ends # 869498
Atom mp4a # 869423 of size: 75, ends # 869498
Atom esds # 869459 of size: 39, ends # 869498
**Atom stts # 869498 of size: 2135816, ends # 3005314**
Atom stsc # 3005314 of size: 39712, ends # 3045026
**Atom stsz # 3045026 of size: 1129400, ends # 4174426**
Atom stco # 4174426 of size: 56160, ends # 4230586
Atom udta # 4230586 of size: 97, ends # 4230683
Atom meta # 4230594 of size: 89, ends # 4230683
Atom hdlr # 4230606 of size: 33, ends # 4230639
Atom ilst # 4230639 of size: 44, ends # 4230683
Atom ©too # 4230647 of size: 36, ends # 4230683
Atom data # 4230655 of size: 28, ends # 4230683
Atom mdat # 4230683 of size: 268473217, ends # 272703900
Atom free # 272703900 of size: 8, ends # 272703908
Atom free # 272703908 of size: 62, ends # 272703970
------------------------------------------------------
Total size: 272703970 bytes; 50 atoms total. AtomicParsley version: 0.9.0 (utf8)
Media data: 268473217 bytes; 4230753 bytes all other atoms (1.551% atom overhead).
Total free atom space: 70 bytes; 0.000% waste. Padding available: 0 bytes.
------------------------------------------------------
After reencoding this movie with audio sample rate 11025 header size much less:
Media info (audio sample rate = 11025): (crop duplicate info)
General
***
HeaderSize : 1276359
Video
***
Audio
Count : 169
Count of stream of this kind : 1
Kind of stream : Audio
Kind of stream : Audio
Stream identifier : 0
ID : 2
ID : 2
Format : AAC
Format/Info : Advanced Audio Codec
Commercial name : AAC
Format profile : LC
Codec ID : 40
Codec : AAC LC
Codec : AAC LC
Codec/Family : AAC
Codec/CC : 40
Duration : 6556132
Duration : 1h 49mn
Duration : 1h 49mn 16s 132ms
Duration : 1h 49mn
Duration : 01:49:16.132
Bit rate mode : VBR
Bit rate mode : Variable
Bit rate : 37991
Bit rate : 38.0 Kbps
Maximum bit rate : 128000
Maximum bit rate : 128 Kbps
Channel(s) : 2
Channel(s) : 2 channels
Channel positions : Front: L R
Channel positions : 2/0/0
Sampling rate : 11025
Sampling rate : 11.025 KHz
Samples count : 72281355
Compression mode : Lossy
Compression mode : Lossy
Stream size : 31134257
Stream size : 29.7 MiB (12%)
Stream size : 30 MiB
Stream size : 30 MiB
Stream size : 29.7 MiB
Stream size : 29.69 MiB
Stream size : 29.7 MiB (12%)
Proportion of this stream : 0.12327
Tagged date : UTC 2012-09-25 13:20:28
Moov atom info (/moov/trak[0] - video, /moov/trak[1] - audio) sample rate 11025:
Atom ftyp # 0 of size: 32, ends # 32
Atom moov # 32 of size: 1276327, ends # 1276359
Atom mvhd # 40 of size: 108, ends # 148
Atom trak # 148 of size: 821662, ends # 821810
Atom tkhd # 156 of size: 92, ends # 248
Atom edts # 248 of size: 36, ends # 284
Atom elst # 256 of size: 28, ends # 284
Atom mdia # 284 of size: 821526, ends # 821810
Atom mdhd # 292 of size: 32, ends # 324
Atom hdlr # 324 of size: 45, ends # 369
Atom minf # 369 of size: 821441, ends # 821810
Atom vmhd # 377 of size: 20, ends # 397
Atom dinf # 397 of size: 36, ends # 433
Atom dref # 405 of size: 28, ends # 433
Atom stbl # 433 of size: 821377, ends # 821810
Atom stsd # 441 of size: 149, ends # 590
Atom avc1 # 457 of size: 133, ends # 590
Atom avcC # 543 of size: 47, ends # 590
Atom stts # 590 of size: 24, ends # 614
Atom stss # 614 of size: 26340, ends # 26954
Atom stsc # 26954 of size: 52, ends # 27006
Atom stsz # 27006 of size: 785956, ends # 812962
Atom stco # 812962 of size: 8848, ends # 821810
Atom trak # 821810 of size: 454452, ends # 1276262
Atom tkhd # 821818 of size: 92, ends # 821910
Atom edts # 821910 of size: 36, ends # 821946
Atom elst # 821918 of size: 28, ends # 821946
Atom mdia # 821946 of size: 454316, ends # 1276262
Atom mdhd # 821954 of size: 32, ends # 821986
Atom hdlr # 821986 of size: 45, ends # 822031
Atom minf # 822031 of size: 454231, ends # 1276262
Atom smhd # 822039 of size: 16, ends # 822055
Atom dinf # 822055 of size: 36, ends # 822091
Atom dref # 822063 of size: 28, ends # 822091
Atom stbl # 822091 of size: 454171, ends # 1276262
Atom stsd # 822099 of size: 91, ends # 822190
Atom mp4a # 822115 of size: 75, ends # 822190
Atom esds # 822151 of size: 39, ends # 822190
Atom stts # 822190 of size: 161368, ends # 983558
Atom stsc # 983558 of size: 1480, ends # 985038
Atom stsz # 985038 of size: 282372, ends # 1267410
Atom stco # 1267410 of size: 8852, ends # 1276262
Atom udta # 1276262 of size: 97, ends # 1276359
Atom meta # 1276270 of size: 89, ends # 1276359
Atom hdlr # 1276282 of size: 33, ends # 1276315
Atom ilst # 1276315 of size: 44, ends # 1276359
Atom ©too # 1276323 of size: 36, ends # 1276359
Atom data # 1276331 of size: 28, ends # 1276359
Atom mdat # 1276359 of size: 251293325, ends # 252569684
Atom free # 252569684 of size: 8, ends # 252569692
Atom free # 252569692 of size: 62, ends # 252569754
------------------------------------------------------
Total size: 252569754 bytes; 50 atoms total. AtomicParsley version: 0.9.0 (utf8)
Media data: 251293325 bytes; 1276429 bytes all other atoms (0.505% atom overhead).
Total free atom space: 70 bytes; 0.000% waste. Padding available: 0 bytes.
------------------------------------------------------
On slow connection this movie start playing after 30-40 seconds until header info (4.2 Mb) downloading. I need that movie start playing fast as it possible. And i have next questions:
How reduce size of movie header?
How reduce size of
/moov[0]/trak[1]/mdia[0]/minf[0]/stbl[0] and why it so big when
sample rate 44100?
It looks like the AAC encoder or ffmpeg is doing a bad job encoding the AAC stream. The sample rate is not the issue here. Have you tried using the other AAC encoder?
-acodec aac -strict experimental
ffmpeg usually uses very small chunk sizes which will consequently lead to larger headers. Same goes for video.
The below is quite extreme.
Atom stts # 869498 of size: 2135816, ends # 3005314
Atom stsz # 3045026 of size: 1129400, ends # 4174426
I would try a different encoder if the other AAC encoder ends up looking the same.
Instead of using ffmpeg and then mp4box, I recommend you to look at a branch of ffmpeg called ffmbc. This can put the header at the start while transcoding instead of it being a post process. But given it's an ffmpeg branch, I am not sure whether it will help on your header size issue. Worth giving a try though.
Hi im using the following perl command to convert files with ffmpeg:
system ("/usr/local/bin/ffmpeg -i $inputFile $outputFile");
I would like to know if its possible to print the ffmpeg output?
Cheers
UPDATE
The solution was to use backticks
my $output = qx{/usr/local/bin/ffmpeg -i $inputFile $outputFile 2>&1};
print $output
This prints out the following:
FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers built on Jan 31 2012 12:30:35 with gcc 4.4.5 20110214 (Red Hat 4.4.5-6) configuration: --enable-libmp3lame --disable-mmx --enable-shared libavutil 50.36. 0 / 50.36. 0 libavcore 0.16. 1 / 0.16. 1 libavcodec 52.108. 0 / 52.108. 0 libavformat 52.93. 0 / 52.93. 0 libavdevice 52. 2. 3 / 52. 2. 3 libavfilter 1.74. 0 / 1.74. 0 libswscale 0.12. 0 / 0.12. 0 [wav # 0x8af94c0] max_analyze_duration reached Input #0, wav, from 'a.wav': Duration: 00:00:05.84, bitrate: 1537 kb/s Stream #0.0: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s Output #0, mp3, to 'a.mp3': Metadata: TSSE : Lavf52.93.0 Stream #0.0: Audio: libmp3lame, 48000 Hz, 2 channels, s16, 64 kb/s Stream mapping: Stream #0.0 -> #0.0 Press [q] to stop encoding size= 42kB time=5.42 bitrate= 64.0kbits/s size= 46kB time=5.88 bitrate= 64.0kbits/s video:0kB audio:46kB global headers:0kB muxing overhead 0.070153%
Hint: FFmpeg throws its output to the StandrdError instead of StandrdOutput