Hello All,
I am using FFMpeg to generate a down-sized proxy video for downstream
processing.
I am piping the video into FFMpeg as a stream and piping the resulting proxy
video directly back to the calling application as a stream.
In order to do this I use the '-movflags frag_keyframe+empty_moov' option in
order to place the 'moov' atoms to the start of the stream.
This all works fine, however the downstream process that uses the proxy video
is throwing an error because the frame count in the proxy video does not match
the frame count defined in the file's metadata.
In order to verify this, I ran the following FFMpeg command to export the
individual frames of the proxy video to a sub-directory.
ffmpeg -i proxy_video.mp4 frames/$filename%03d.bmp
I then count the number of frames generated as follows.
ls frames | wc -l
For my small sample video this gives me a count of 167.
I then used FFProbe to get the number of frames for the video as follows.
ffprobe -v error -select_streams v:0 -count_frames -show_entries
stream=nb_read_frames proxy_video.mp4
For the same video I get a count of 165.
Looking at the original video there are indeed 165 frames, and looking at the
bmp files generated for the proxy, it appears that two extra frames are added
at the start.
The two extra frames are not a problem, but the count of actual frames vs
frames defined in metadata must match.
Is there a way I can update the frame count in the header, or possibly a way to
prevent the generation of the extra frames?
The FFMpeg command I am running is as follows.
ffmpeg -i test_video.mp4 -acodec libmp3lame -vcodec libx264 -r 30 -vf
scale=480:-2 -f mov -movflags frag_keyframe+empty_moov proxy_video.mp4
The output from my FFMpeg version is as follows, and the full console dump is
attached.
ffmpeg version 5.1.2 Copyright (c) 2000-2022 the FFmpeg developers
built with Apple clang version 14.0.0 (clang-1400.0.29.102)
configuration: --prefix=/usr/local/Cellar/ffmpeg/5.1.2 --enable-shared
--enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags=
--enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray
--enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e
--enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt
--enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf
--enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264
--enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma
--enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass
--enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg
--enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg
--disable-libjack --disable-indev=jack --enable-videotoolbox
libavutil 57. 28.100 / 57. 28.100
libavcodec 59. 37.100 / 59. 37.100
libavformat 59. 27.100 / 59. 27.100
libavdevice 59. 7.100 / 59. 7.100
libavfilter 8. 44.100 / 8. 44.100
libswscale 6. 7.100 / 6. 7.100
libswresample 4. 7.100 / 4. 7.100
libpostproc 56. 6.100 / 56. 6.100
Thank you for your help
Mike
% ffmpeg -i test_video.mp4 -acodec libmp3lame -vcodec libx264 -r 30 -vf
scale=480:-2 -f mov -movflags frag_keyframe+empty_moov proxy_video.mp4
ffmpeg version 5.1.2 Copyright (c) 2000-2022 the FFmpeg developers
built with Apple clang version 14.0.0 (clang-1400.0.29.102)
configuration: --prefix=/usr/local/Cellar/ffmpeg/5.1.2 --enable-shared
--enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags=
--enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray
--enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e
--enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt
--enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf
--enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264
--enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma
--enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass
--enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg
--enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg
--disable-libjack --disable-indev=jack --enable-videotoolbox
libavutil 57. 28.100 / 57. 28.100
libavcodec 59. 37.100 / 59. 37.100
libavformat 59. 27.100 / 59. 27.100
libavdevice 59. 7.100 / 59. 7.100
libavfilter 8. 44.100 / 8. 44.100
libswscale 6. 7.100 / 6. 7.100
libswresample 4. 7.100 / 4. 7.100
libpostproc 56. 6.100 / 56. 6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test_video.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
creation_time : 2018-05-17T20:57:37.000000Z
Duration: 00:00:05.51, start: 0.000000, bitrate: 10528 kb/s
Stream #0:0[0x1](eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv,
bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 10189 kb/s, 29.97 fps, 29.97
tbr, 30k tbn (default)
Metadata:
creation_time : 2018-05-17T20:57:37.000000Z
handler_name : ?Mainconcept Video Media Handler
vendor_id : [0][0][0][0]
encoder : AVC Coding
Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo,
fltp, 317 kb/s (default)
Metadata:
creation_time : 2018-05-17T20:57:38.000000Z
handler_name : #Mainconcept MP4 Sound Media Handler
vendor_id : [0][0][0][0]
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
[libx264 @ 0x7fd91e206000] using SAR=1/1
[libx264 @ 0x7fd91e206000] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
AVX FMA3 BMI2 AVX2
[libx264 @ 0x7fd91e206000] profile High, level 2.1, 4:2:0, 8-bit
[libx264 @ 0x7fd91e206000] 264 - core 164 r3095 baee400 - H.264/MPEG-4 AVC
codec - Copyleft 2003-2022 - http://www.videolan.org/x264.html - options:
cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1
psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0
deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1
sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0
constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1
open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0
rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4
ip_ratio=1.40 aq=1:1.00
Output #0, mov, to 'proxy_video.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
encoder : Lavf59.27.100
Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709,
progressive), 480x270 [SAR 1:1 DAR 16:9], q=2-31, 30 fps, 15360 tbn (default)
Metadata:
creation_time : 2018-05-17T20:57:37.000000Z
handler_name : ?Mainconcept Video Media Handler
vendor_id : [0][0][0][0]
encoder : Lavc59.37.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1(eng): Audio: mp3 (.mp3 / 0x33706D2E), 48000 Hz, stereo, fltp
(default)
Metadata:
creation_time : 2018-05-17T20:57:38.000000Z
handler_name : #Mainconcept MP4 Sound Media Handler
vendor_id : [0][0][0][0]
encoder : Lavc59.37.100 libmp3lame
frame= 165 fps= 52 q=-1.0 Lsize= 551kB time=00:00:05.52 bitrate=
817.8kbits/s speed=1.74x
video:461kB audio:87kB subtitle:0kB other streams:0kB global headers:0kB muxing
overhead: 0.689201%
[libx264 @ 0x7fd91e206000] frame I:1 Avg QP:24.34 size: 27213
[libx264 @ 0x7fd91e206000] frame P:46 Avg QP:25.37 size: 7748
[libx264 @ 0x7fd91e206000] frame B:118 Avg QP:30.86 size: 741
[libx264 @ 0x7fd91e206000] consecutive B-frames: 4.2% 0.0% 3.6% 92.1%
[libx264 @ 0x7fd91e206000] mb I I16..4: 0.8% 38.2% 61.0%
[libx264 @ 0x7fd91e206000] mb P I16..4: 0.4% 1.5% 1.0% P16..4: 38.2% 28.3%
24.4% 0.0% 0.0% skip: 6.1%
[libx264 @ 0x7fd91e206000] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 42.5% 7.1%
2.2% direct: 1.7% skip:46.4% L0:36.8% L1:48.0% BI:15.2%
[libx264 @ 0x7fd91e206000] 8x8 transform intra:45.4% inter:44.7%
[libx264 @ 0x7fd91e206000] coded y,uvDC,uvAC intra: 75.9% 95.1% 82.9% inter:
17.6% 15.2% 5.9%
[libx264 @ 0x7fd91e206000] i16 v,h,dc,p: 44% 25% 23% 8%
[libx264 @ 0x7fd91e206000] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 13% 22% 5% 6%
7% 6% 8% 10%
[libx264 @ 0x7fd91e206000] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 14% 15% 8% 9%
9% 8% 9% 8%
[libx264 @ 0x7fd91e206000] i8c dc,h,v,p: 49% 18% 23% 10%
[libx264 @ 0x7fd91e206000] Weighted P-Frames: Y:17.4% UV:17.4%
[libx264 @ 0x7fd91e206000] ref P L0: 67.5% 15.9% 8.5% 7.7% 0.4%
[libx264 @ 0x7fd91e206000] ref B L0: 88.5% 9.1% 2.4%
[libx264 @ 0x7fd91e206000] ref B L1: 91.4% 8.6%
[libx264 @ 0x7fd91e206000] kb/s:685.25_______________________________________________
ffmpeg-user mailing list
[email protected]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".