Re: [FFmpeg-user] How to get he total number of frames
Am 12.03.21 um 17:00 schrieb Peter White: On Fri, Mar 12, 2021 at 03:51:11PM +0100, Nicolas George wrote: Peter White (12021-03-12): but that is because a packet needs to be decoded first to get the frame. Please be complete in your statements: ... with some obscure codecs or if libavcodec happens to have been compiled without parsers... To be honest, that was not entirely clear until just now. Otherwise counting the packets is perfectly fine, as I have already explained. That point did not come across in this clarity. Thank you for setting my mind at ease. :) +1 -Ulf ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
On Fri, Mar 12, 2021 at 03:51:11PM +0100, Nicolas George wrote: > Peter White (12021-03-12): > > but that is because a packet needs to be decoded first to get the frame. > > Please be complete in your statements: > > ... with some obscure codecs or if libavcodec happens to have been > compiled without parsers... To be honest, that was not entirely clear until just now. > Otherwise counting the packets is perfectly fine, as I have already > explained. That point did not come across in this clarity. Thank you for setting my mind at ease. :) Cheers, Peter ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
Peter White (12021-03-12): > but that is because a packet needs to be decoded first to get the frame. Please be complete in your statements: ... with some obscure codecs or if libavcodec happens to have been compiled without parsers... Otherwise counting the packets is perfectly fine, as I have already explained. Regards, -- Nicolas George signature.asc Description: PGP signature ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
> On Mar 12, 2021, at 01:10, Peter White wrote: > > Anyway, ffmpeg is not the right tool, as I myself have learned in this > very thread. ffprobe -count_frames should be used. Yes it is rather slow > but that is because a packet needs to be decoded first to get the frame. Hi Peter, It's an interesting challenge and approach you've posed. I understand the interest in literally counting video frames, but for your purposes would simple math be just as reliable and much faster? Assuming files with fixed frame rates, where your frame rate and total time can be reported to the millisecond, I suspect (but haven't tested) you'll get the exact same frame count whether you use ffprobe or a simple calculation. ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
On Fri, Mar 12, 2021 at 02:11:14AM -0500, Mark Filipak (ffmpeg) wrote: > On 2021-03-11 18:37, Reino Wijnsma wrote: > > On 2021-03-09T20:43:21+0100, Mark Filipak (ffmpeg) > > wrote: > > > On 2021-03-09 03:58, Michael Koch wrote: > > > > These links might help: > > > > https://stackoverflow.com/questions/2017843/fetch-frame-count-with-ffmpeg > > > > https://superuser.com/questions/1512575/why-total-frame-count-is-different-in-ffmpeg-than-ffprobe > > > > > > > > Michael > > > > > > Those links are really hard to follow and it's fruitless to try to find > > > what's there that works vs. what doesn't work. > > > > > > From Ulf Zibis: > > > can one please tell me, how I can get the total number of frames of a > > > video? > > > > > > Was Ulf's question actually answered? I think not. > > > > How can you say that? These urls do exactly that. They offer a couple of > > solutions on how to get the total number of frames. > > What is so hard to follow? > > > Re, https://stackoverflow.com/questions/2017843/fetch-frame-count-with-ffmpeg. > I think this: > 'ffmpeg -i input.mkv -map 0:v:0 -c copy -f null -' As was established in this discussion, ffmpeg is simply not the right tool for that. I, who suggested using it, know better now. Thanks BTW to Nicolas. > [1] Specifically, videos copied from DVDs with 'drawtext...text=%{n}' but > that show burned-in frame number beginning with '1' (or '2' or '3' ..). > Example: > Frame #s 1..3596 <=burned-in > @ 30/1.001fps <=confirmed > with 2:00.071 running time <= 3598.[516483..] to 3598.[5464..] actual frames Obviously, there cannot be fractions of frames, hence you always need to round up. > "frame= 3596 fps= 30 q=15.8 Lsize= 87555kB time=00:02:00.03 > bitrate=5975.2kbits/s dup=0 drop=1 speed=0.988x" <= last line of log > -- What is a person to believe? And that is exactly what happened here. But to reiterate what Nicolas pointed out, the copy codec effectively disables decoding and hence counts *packets* not frames. Anyway, ffmpeg is not the right tool, as I myself have learned in this very thread. ffprobe -count_frames should be used. Yes it is rather slow but that is because a packet needs to be decoded first to get the frame. ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
On 2021-03-11 18:37, Reino Wijnsma wrote: On 2021-03-09T20:43:21+0100, Mark Filipak (ffmpeg) wrote: On 2021-03-09 03:58, Michael Koch wrote: These links might help: https://stackoverflow.com/questions/2017843/fetch-frame-count-with-ffmpeg https://superuser.com/questions/1512575/why-total-frame-count-is-different-in-ffmpeg-than-ffprobe Michael Those links are really hard to follow and it's fruitless to try to find what's there that works vs. what doesn't work. From Ulf Zibis: can one please tell me, how I can get the total number of frames of a video? Was Ulf's question actually answered? I think not. How can you say that? These urls do exactly that. They offer a couple of solutions on how to get the total number of frames. What is so hard to follow? Re, https://stackoverflow.com/questions/2017843/fetch-frame-count-with-ffmpeg. I think this: 'ffmpeg -i input.mkv -map 0:v:0 -c copy -f null -' does not report the number of frames for input.mkv. I think it reports the number of frames output by the default encoder. Based on much experimentation with sources that have frame numbers burned in, I don't trust this approach as ffmpeg often silently skips input frames at the beginning of streams -- I often see this [1] -- and ffmpeg doesn't always indicate dropped frames elsewhere -- I often see this. If the point is to absolutely know the number of input frames (perhaps to know whether ffmpeg is dropping any frames), I don't think this is the way to do it. I could be wrong because I'm so ignorant. But burned-in frame numbers don't lie. : [1] Specifically, videos copied from DVDs with 'drawtext...text=%{n}' but that show burned-in frame number beginning with '1' (or '2' or '3' ..). Example: Frame #s 1..3596 <=burned-in @ 30/1.001fps <=confirmed with 2:00.071 running time <= 3598.[516483..] to 3598.[5464..] actual frames "frame= 3596 fps= 30 q=15.8 Lsize= 87555kB time=00:02:00.03 bitrate=5975.2kbits/s dup=0 drop=1 speed=0.988x" <= last line of log -- What is a person to believe? : This is confusing: "This is a slow method. Because the whole file must be decoded --> you're using -c copy, so no decoding. – Gyan Jul 27 '18 at 5:00" There's more, but I've probably made my point. I think my second request to this list (after asking for the meanings of 'tbr', 'tbn', and 'tbc' and not getting anything definitive) was a request for command lines that are known to work. I was trying to figure out what the cryptic documentation was trying to 'say' -- CLI examples posted by people who are in trouble are not good examples. I was pretty brutally attacked for making such an outrageous request. I've learned a lot since then, but of course with no place to put it, all that knowledge and unique perspective and experience is wasted. ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
On 2021-03-09T20:43:21+0100, Mark Filipak (ffmpeg) wrote: > On 2021-03-09 03:58, Michael Koch wrote: >> These links might help: >> https://stackoverflow.com/questions/2017843/fetch-frame-count-with-ffmpeg >> https://superuser.com/questions/1512575/why-total-frame-count-is-different-in-ffmpeg-than-ffprobe >> >> Michael > > Those links are really hard to follow and it's fruitless to try to find > what's there that works vs. what doesn't work. > > From Ulf Zibis: > can one please tell me, how I can get the total number of frames of a video? > > Was Ulf's question actually answered? I think not. How can you say that? These urls do exactly that. They offer a couple of solutions on how to get the total number of frames. What is so hard to follow? -- Reino ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
On 2021-03-09 03:58, Michael Koch wrote: Am 09.03.2021 um 09:46 schrieb Ulf Zibis: Am 09.03.21 um 09:26 schrieb Peter White: On Tue, Mar 09, 2021 at 09:13:14AM +0100, Ulf Zibis wrote: Hi,, can one please tell me, how I can get the total number of frames of a video? ffmpeg -i input -an -sn -c copy -f null - This basically copies all frames into the void but you get the total count this way in the stats line. Much thanks. This at least gives a ballpark figure. Is there a way to get the exact frame count? These links might help: https://stackoverflow.com/questions/2017843/fetch-frame-count-with-ffmpeg https://superuser.com/questions/1512575/why-total-frame-count-is-different-in-ffmpeg-than-ffprobe Michael Those links are really hard to follow and it's fruitless to try to find what's there that works vs. what doesn't work. From Ulf Zibis: can one please tell me, how I can get the total number of frames of a video? Was Ulf's question actually answered? I think not. I'd like to know the answer. Here's a cmd script that I have implemented in the Windows 'SentTo' context menu: @ECHO OFF ECHO Tip: Use "Save As" to save this list.>"%TEMP%\%~nx1 timestamps.txt" ECHO.>>"%TEMP%\%~nx1 timestamps.txt" ffprobe -hide_banner -sexagesimal -select_streams v -i %1 2>>"%TEMP%\%~nx1 timestamps.txt" ffprobe -hide_banner -sexagesimal -select_streams v -show_frames -of flat -i %1 | FINDSTR /L "key_frame=1 best_effort_timestamp">>"%TEMP%\%~nx1 timestamps.txt" "%TEMP%\%~nx1 timestamps.txt" DEL /Q "%TEMP%\%~nx1 timestamps.txt" '~nx' strips enclosing quotes (if present) and extracts the file's name & extension (example: video.mkv). '%~nx1 timestamps.txt' saves the video.mkv list as 'video.mkv timestamps.txt'. "%TEMP%\%~nx1 timestamps.txt" opens the list in my editor. The last line of the list produced by the cmd script shows the frame number of the ending frame -- Add 1 to get the number of frames. The list also shows this metadata: "NUMBER_OF_FRAMES-eng: 95286", but that number is bogus; the mkv actually has only 3596 frames. Yes, the ffprobe command is slow. That's why I'd like to know a quick check of number of frames if indeed such a method exists. ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
Am 09.03.21 um 11:48 schrieb Peter White: On Tue, Mar 09, 2021 at 11:07:21AM +0100, Ulf Zibis wrote: Am 09.03.21 um 10:43 schrieb Ulf Zibis: Am 09.03.21 um 09:57 schrieb Peter White: The frame count *is* exact. The way to get there is just not that pretty. If anybody on this list knows a better one, step up, please. I suspect that the last "progression" line shows the exact count, as it may only report the last progression state a few µs before the operation is completed. Can one please clarify this? I don't know if I understood your request correctly ... Thanks for your request. It was clarified by Moritz' answer. -Ulf ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
Am 09.03.21 um 14:22 schrieb Nicolas George: Ulf Zibis (12021-03-09): So for correctness, ffmpeg should report packets instead frames in its progress output line, at least with -c copy ... or please correct me. Would you insist on people saying that the mailman brings envelopes instead of letters too? I'm not aware, if mailman technically is able to enclose more than one letter in an envelope, but an analogue postman indeed can deliver multiple letters in one envelope, and according your statement, multimedia streams can envelope multiple frames in one packet. -Ulf ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
Am 09.03.21 um 11:53 schrieb Moritz Barsnick: On Tue, Mar 09, 2021 at 11:07:21 +0100, Ulf Zibis wrote: Am 09.03.21 um 10:43 schrieb Ulf Zibis: I suspect that the last "progression" line shows the exact count, as it may only report the last progression state a few µs before the operation is completed. Can one please clarify this? The progess line is printed periodically, and additionally after the end of processing. Therefore the last visible line does not omit any stats. Much thanks. This "heals" my suspectedness. On the other hand, according Nicolas George there seems to be a possible incorrectness according packets count. Anyway, in my case the packed count seems exact enough. I transcoded a MPEG2 file with 25 fps to Matroska and was wondering, that the output has 50 fps, so I wanted to verify, if the output really has ~ twice frames than the input. -Ulf ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
Ulf Zibis (12021-03-09): > So for correctness, ffmpeg should report packets instead frames in its > progress output line, at least with -c copy ... or please correct me. Would you insist on people saying that the mailman brings envelopes instead of letters too? Regards, -- Nicolas George signature.asc Description: PGP signature ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
Am 09.03.21 um 13:07 schrieb Nicolas George: -c copy tells ffmpeg to dispense with the decoder, which means it does not count frames but packets. Have you tried telling ffprobe to count packets? So for correctness, ffmpeg should report packets instead frames in its progress output line, at least with -c copy ... or please correct me. -Ulf ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
On Tue, Mar 09, 2021 at 11:26:49PM +1030, Rodney Baker wrote: > On Tuesday, 9 March 2021 23:17:34 ACDT Peter White wrote: > > On Tue, Mar 09, 2021 at 01:07:41PM +0100, Nicolas George wrote: > > > Peter White (12021-03-09): > > > > ffmpeg -i input.mkv -an -sn -c copy -f null - > > > > > > -c copy tells ffmpeg to dispense with the decoder, which means it does > > > not count frames but packets. Have you tried telling ffprobe to count > > > packets? > > > > I have now, but it returns 'N/A'. Now that I see that, I might have > > tried it way back when, even, and have forgotten about it. > > > > ffprobe -count_packets -select_streams v:0 -show_entries > [...] > > Stream #0:0: Video: hevc (Main 10), yuv420p10le(tv, bt709), 768x432 [SAR > > 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc (default) Metadata: > > BPS-eng : 1021384 > > DURATION-eng: 00:21:40.71600 > > NUMBER_OF_FRAMES-eng: 31186 > > Isn't this exactly what you're looking for? > [...] Yes, in this particular case the frame count was written to the metadata but one cannot rely on that as was established previously. A universal solution is the aim. Plus, I tend not to trust metadata that can be arbitrarily manipulated. Peter ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
On Tue, Mar 09, 2021 at 01:50:20PM +0100, Nicolas George wrote: > Peter White (12021-03-09): > > I have now, but it returns 'N/A'. Now that I see that, I might have > > tried it way back when, even, and have forgotten about it. > > > > ffprobe -count_packets -select_streams v:0 -show_entries > > stream=nb_read_frames > ^^^ > ^^ Oops, missed that one. Thanks! Peter ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
On Tuesday, 9 March 2021 23:17:34 ACDT Peter White wrote: > On Tue, Mar 09, 2021 at 01:07:41PM +0100, Nicolas George wrote: > > Peter White (12021-03-09): > > > ffmpeg -i input.mkv -an -sn -c copy -f null - > > > > -c copy tells ffmpeg to dispense with the decoder, which means it does > > not count frames but packets. Have you tried telling ffprobe to count > > packets? > > I have now, but it returns 'N/A'. Now that I see that, I might have > tried it way back when, even, and have forgotten about it. > > ffprobe -count_packets -select_streams v:0 -show_entries [...] > Stream #0:0: Video: hevc (Main 10), yuv420p10le(tv, bt709), 768x432 [SAR > 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc (default) Metadata: > BPS-eng : 1021384 > DURATION-eng: 00:21:40.71600 > NUMBER_OF_FRAMES-eng: 31186 Isn't this exactly what you're looking for? [...] -- == Rodney Baker VK5ZTV rodney.ba...@iinet.net.au CCNA #CSCO12880208 == ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
On Tue, Mar 09, 2021 at 01:41:38PM +0100, Nicolas George wrote: > Peter White (12021-03-09): > > Is there a meaningful difference in this context? > > The fact that you need to ask is proof enough that it is needed. I understand that a packet is what the demuxer sends to the decoder which in turn decodes it into a frame. But decoding is not necessary if I only want the *number* of frames not their content. Hence the question if *in this context* there is a difference. If I need to decode a frame to count it, then the counting operation is not feasible. > > Now we are getting somewhere. No, I have not, because I did not know it > > can do that. But above question remains: does packet count always equal > > frame count? What might be pitfalls with this approach? > > The frame count could be different than the packet count with some > codecs, indeed, but I am not aware of any specific case. I had a suspicion that might be. Would you agree that in the vast majority of cases it is safe to assume frame count equals packet count? > Anyway, using -c copy gives the same result. Not quite, see my other message, please. Peter ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
Peter White (12021-03-09): > I have now, but it returns 'N/A'. Now that I see that, I might have > tried it way back when, even, and have forgotten about it. > > ffprobe -count_packets -select_streams v:0 -show_entries stream=nb_read_frames ^^^ ^^ Regard, -- Nicolas George signature.asc Description: PGP signature ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
On Tue, Mar 09, 2021 at 01:07:41PM +0100, Nicolas George wrote: > Peter White (12021-03-09): > > ffmpeg -i input.mkv -an -sn -c copy -f null - > > -c copy tells ffmpeg to dispense with the decoder, which means it does > not count frames but packets. Have you tried telling ffprobe to count > packets? I have now, but it returns 'N/A'. Now that I see that, I might have tried it way back when, even, and have forgotten about it. ffprobe -count_packets -select_streams v:0 -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 input.mkv ffprobe version n4.3.1-221-gd08bcb Copyright (c) 2007-2021 the FFmpeg developers built with AMD clang version 11.0.0 (CLANG: AOCC_2.3.0-Build#85 2020_11_10) (based on LLVM Mirror.Version.11.0.0) configuration: --cc='ccache clang' --cxx='ccache clang++' --objcc='ccache clang' --dep-cc='ccache clang' --extra-cflags='-march=native' --extra-cxxflags='-march=native' --extra-objcflags='-march=native' --enable-hardcoded-tables --enable-shared --enable-gpl --enable-version3 --enable-nonfree --disable-runtime-cpudetect --enable-libx264 --enable-libx265 --enable-libvorbis --enable-gnutls --enable-opengl --enable-libopus --enable-libfreetype --enable-libfontconfig --enable-libfribidi --enable-libsoxr --enable-libzvbi --enable-libmp3lame --enable-ladspa --enable-lv2 --enable-libbs2b --enable-libdrm --enable-libvpx --enable-libbluray libavutil 56. 51.100 / 56. 51.100 libavcodec 58. 91.100 / 58. 91.100 libavformat58. 45.100 / 58. 45.100 libavdevice58. 10.100 / 58. 10.100 libavfilter 7. 85.100 / 7. 85.100 libswscale 5. 7.100 / 5. 7.100 libswresample 3. 7.100 / 3. 7.100 libpostproc55. 7.100 / 55. 7.100 Input #0, matroska,webm, from 'input.mkv': Metadata: creation_time : 2021-02-16T19:59:37.00Z ENCODER : Lavf58.45.100 Duration: 00:21:40.91, start: -0.007000, bitrate: 1319 kb/s Chapter #0:0: start 0.00, end 432.557000 Metadata: title : 00:00:00.000 Chapter #0:1: start 432.557000, end 866.824000 Metadata: title : 00:07:12.557 Chapter #0:2: start 866.824000, end 1267.475000 Metadata: title : 00:14:26.824 Chapter #0:3: start 1267.475000, end 1300.906000 Metadata: title : 00:21:07.475 Stream #0:0: Video: hevc (Main 10), yuv420p10le(tv, bt709), 768x432 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc (default) Metadata: BPS-eng : 1021384 DURATION-eng: 00:21:40.71600 NUMBER_OF_FRAMES-eng: 31186 NUMBER_OF_BYTES-eng: 166066371 _STATISTICS_WRITING_APP-eng: mkvmerge v45.0.0 ('Heaven in Pennies') 64-bit _STATISTICS_WRITING_DATE_UTC-eng: 2021-02-16 19:59:37 _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES Stream #0:1(eng): Audio: opus, 48000 Hz, 5.1, fltp (default) Metadata: title : English ENCODER : Lavc58.91.100 libopus BPS-eng : 230805 DURATION-eng: 00:21:40.76000 NUMBER_OF_FRAMES-eng: 65039 NUMBER_OF_BYTES-eng: 37527832 _STATISTICS_WRITING_APP-eng: mkvmerge v45.0.0 ('Heaven in Pennies') 64-bit _STATISTICS_WRITING_DATE_UTC-eng: 2021-02-16 19:59:37 _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES Stream #0:2(eng): Audio: aac (HE-AAC), 48000 Hz, stereo, fltp Metadata: title : English BPS-eng : 63925 DURATION-eng: 00:21:40.90600 NUMBER_OF_FRAMES-eng: 30490 NUMBER_OF_BYTES-eng: 10395117 _STATISTICS_WRITING_APP-eng: mkvmerge v45.0.0 ('Heaven in Pennies') 64-bit _STATISTICS_WRITING_DATE_UTC-eng: 2021-02-16 19:59:37 _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES Stream #0:3(eng): Subtitle: subrip Metadata: title : English BPS-eng : 72 DURATION-eng: 00:21:36.16900 NUMBER_OF_FRAMES-eng: 370 NUMBER_OF_BYTES-eng: 11676 _STATISTICS_WRITING_APP-eng: mkvmerge v45.0.0 ('Heaven in Pennies') 64-bit _STATISTICS_WRITING_DATE_UTC-eng: 2021-02-16 19:59:37 _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES N/A Peter ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
Peter White (12021-03-09): > Is there a meaningful difference in this context? The fact that you need to ask is proof enough that it is needed. > Now we are getting somewhere. No, I have not, because I did not know it > can do that. But above question remains: does packet count always equal > frame count? What might be pitfalls with this approach? The frame count could be different than the packet count with some codecs, indeed, but I am not aware of any specific case. Anyway, using -c copy gives the same result. Regards, -- Nicolas George signature.asc Description: PGP signature ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
On Tue, Mar 09, 2021 at 01:07:41PM +0100, Nicolas George wrote: > Peter White (12021-03-09): > > Would you mind answering the OP's question with a command line example, > > then? > > I help people who help themselves, thus avoiding Russel's paradox. Sorry, I don't know that one and cannot grasp it at the moment, but I guess it is similar to teaching a starving man how to fish instead of just giving him one fish? I haven't seen much teaching yet, though. Not even a pointer other than: ffprobe can do that. > > I am well aware of that, but nobody said anything about parsing. > > Oh? Please, explain to me how you extract the number of frames from the > statistics line without parsing it? By reading the line, which technically is parsing as well, but I am more flexible than any stupid script. > > ffprobe -v error -count_frames -select_streams v:0 -show_entries > > stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 input.mkv > > Do not use "-v error" if you want help. Sorry, why would it matter what other output comes from above command? See: > > No need for output because it takes to long to complete: roughly one > > minute for a 20 minute video as opposed to virtually no time with: > > > > ffmpeg -i input.mkv -an -sn -c copy -f null - > > -c copy tells ffmpeg to dispense with the decoder, which means it does > not count frames but packets. Is there a meaningful difference in this context? I did have a similar solution in a script, using PyAV, which counted packets instead of frames, because it is faster. > Have you tried telling ffprobe to count packets? Now we are getting somewhere. No, I have not, because I did not know it can do that. But above question remains: does packet count always equal frame count? What might be pitfalls with this approach? Peter ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
UNSUBSCRIBE ! Best regards, Jim Hollingsworth On Mar 9, 2021, at 6:16 AM, Phil Rhodes via ffmpeg-user wrote: I hit this once some time ago when creating an application which was intended to assign start timecodes to recorded video files and for which we needed a frame-accurate count. In that case the files were AVIs, which theoretically may have a header including a frame count, but in practice we found that this was often either missing, not set, or inaccurate in files we found in the wild, and there are further issues specifically with AVI over a certain length. Other file types have similar problems. My conclusion was that the only reliable way to get a frame count is to have something like ffmpeg go over the file frame by frame. With the command lines suggested here (which are, if I remember correctly, close to what I used) then it tends to be reasonably fast and, as I say, I'm not sure there's much other option if you need a reasonable amount of reliability on arbitrary files. If you're in a situation where all your files come from a known source and you are confident they will always have frame count headers that will always be accurate, great, but otherwise I'd recommend doing roughly what's been suggested here. P On Tuesday, 9 March 2021, 10:54:09 GMT, Peter White wrote: Unless it happens to be one of those special cases that don't have that info in their metadata, like matroska: ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
Peter White (12021-03-09): > Would you mind answering the OP's question with a command line example, > then? I help people who help themselves, thus avoiding Russel's paradox. > I am well aware of that, but nobody said anything about parsing. Oh? Please, explain to me how you extract the number of frames from the statistics line without parsing it? > ffprobe -v error -count_frames -select_streams v:0 -show_entries > stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 input.mkv Do not use "-v error" if you want help. > > No need for output because it takes to long to complete: roughly one > minute for a 20 minute video as opposed to virtually no time with: > > ffmpeg -i input.mkv -an -sn -c copy -f null - -c copy tells ffmpeg to dispense with the decoder, which means it does not count frames but packets. Have you tried telling ffprobe to count packets? Regards, -- Nicolas George signature.asc Description: PGP signature ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
On Tue, Mar 09, 2021 at 12:39:09PM +0100, Nicolas George wrote: > Peter White (12021-03-09): > > Sorry, I didn't mean to offend. > > I was not offended, I was amused. > > > Is there a proper universal way to do this with ffprobe that does not > > take ages to complete? Honest question. > > Of course. As I already said, FFprobe can do the same thing as FFmpeg, > but its output is meant for parsing. Would you mind answering the OP's question with a command line example, then? > Your solution will break as soon as we change a tiny detail in the > statistics line. I am well aware of that, but nobody said anything about parsing. But if there is an equivalent to my suggestion with ffprobe I would gladly use that and henceforth recommend it. > Show us your complete command line and console output if you have > trouble. ffprobe -v error -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 input.mkv No need for output because it takes to long to complete: roughly one minute for a 20 minute video as opposed to virtually no time with: ffmpeg -i input.mkv -an -sn -c copy -f null - Peter ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
Peter White (12021-03-09): > Sorry, I didn't mean to offend. I was not offended, I was amused. > Is there a proper universal way to do this with ffprobe that does not > take ages to complete? Honest question. Of course. As I already said, FFprobe can do the same thing as FFmpeg, but its output is meant for parsing. Your solution will break as soon as we change a tiny detail in the statistics line. Show us your complete command line and console output if you have trouble. Regards, -- Nicolas George signature.asc Description: PGP signature ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
On Tue, Mar 09, 2021 at 12:13:53PM +0100, Nicolas George wrote: > Peter White (12021-03-09): > > Unless it happens to be one of those special cases that don't have that > > info in their metadata, like matroska: > > Did I suggest to limit to the output of -show_format or -show_streams? Sorry, I didn't mean to offend. > > Other than being a little ugly, my way seems to yield the correct result > > with any video. I like universal solutions, so I stuck with it, and > > recommended it. > > FFprobe yields the correct result, and in a cleaner way. Just use it > properly. Is there a proper universal way to do this with ffprobe that does not take ages to complete? Honest question. Plus, the ffmpeg command is relatively easy, if one uses ffmpeg on a regular basis. OTOH I seldomly use ffprobe, as do many of the other users, I suspect, so ffmpeg comes more natural. Peter ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
I hit this once some time ago when creating an application which was intended to assign start timecodes to recorded video files and for which we needed a frame-accurate count. In that case the files were AVIs, which theoretically may have a header including a frame count, but in practice we found that this was often either missing, not set, or inaccurate in files we found in the wild, and there are further issues specifically with AVI over a certain length. Other file types have similar problems. My conclusion was that the only reliable way to get a frame count is to have something like ffmpeg go over the file frame by frame. With the command lines suggested here (which are, if I remember correctly, close to what I used) then it tends to be reasonably fast and, as I say, I'm not sure there's much other option if you need a reasonable amount of reliability on arbitrary files. If you're in a situation where all your files come from a known source and you are confident they will always have frame count headers that will always be accurate, great, but otherwise I'd recommend doing roughly what's been suggested here. P On Tuesday, 9 March 2021, 10:54:09 GMT, Peter White wrote: Unless it happens to be one of those special cases that don't have that info in their metadata, like matroska: ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
Peter White (12021-03-09): > Unless it happens to be one of those special cases that don't have that > info in their metadata, like matroska: Did I suggest to limit to the output of -show_format or -show_streams? If you want information about frames, guess what you should use? > Other than being a little ugly, my way seems to yield the correct result > with any video. I like universal solutions, so I stuck with it, and > recommended it. FFprobe yields the correct result, and in a cleaner way. Just use it properly. Regards, -- Nicolas George signature.asc Description: PGP signature ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
On Tue, Mar 09, 2021 at 10:41:41AM +0100, Nicolas George wrote: > Peter White (12021-03-09): > > If anybody on this list knows a better one, step up, please. > > ffprobe, of course. Unless it happens to be one of those special cases that don't have that info in their metadata, like matroska: https://stackoverflow.com/a/28376817 Other than being a little ugly, my way seems to yield the correct result with any video. I like universal solutions, so I stuck with it, and recommended it. Peter ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
On Tue, Mar 09, 2021 at 11:07:21 +0100, Ulf Zibis wrote: > Am 09.03.21 um 10:43 schrieb Ulf Zibis: > > I suspect that the last "progression" line shows the exact count, > > as it may only report the last progression state a few µs before > > the operation is completed. > > Can one please clarify this? The progess line is printed periodically, and additionally after the end of processing. Therefore the last visible line does not omit any stats. Moritz ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
On Tue, Mar 09, 2021 at 11:07:21AM +0100, Ulf Zibis wrote: > > Am 09.03.21 um 10:43 schrieb Ulf Zibis: > > > > Am 09.03.21 um 09:57 schrieb Peter White: > > > The frame count *is* exact. The way to get there is just not that > > > pretty. If anybody on this list knows a better one, step up, please. > > > > I suspect that the last "progression" line shows the exact count, as it may > > only report the last progression state a few µs before the operation is > > completed. > > Can one please clarify this? I don't know if I understood your request correctly but here goes: ffmpeg -i example.mkv -an -sn -c copy -f null - ... Stream mapping: Stream #0:0 -> #0:0 (copy) Press [q] to stop, [?] for help frame=31186 fps=0.0 q=-1.0 Lsize=N/A time=00:21:40.59 bitrate=N/A speed=2.67e+03x video:162174kB audio:0kB subtitle:0kB other streams:0kB global headers:2kB muxing overhead: unknown As you can see, in the second to last line in the first field is the frame count. Since the copy codec gets used, I can see no reason why this should not always show the exact total frame count of any video. Also, note that I used a matroska file as an example, since it is one of the mentioned special cases mentioned here: https://stackoverflow.com/a/28376817 I had the same question you posted once and think I saw that one or a similar answer. After some ado I came to the conclusion that the aforementioned way is the most robust and universal one. But if I am wrong, I would very much like to be corrected. Peter ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
On Tue, 9 Mar 2021 at 10:26, Jim Hollingsworth wrote: > Unsubscribe!!! Before the inevitable flames: to unsubscribe, please read the footer of the email you replied to and follow the instructions there. For convenience: > https://ffmpeg.org/mailman/listinfo/ffmpeg-user > To unsubscribe, visit link above, or email > ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe". Cheers, Rob ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
Unsubscribe!!! On Mar 9, 2021, at 4:41 AM, Nicolas George wrote: Peter White (12021-03-09): > If anybody on this list knows a better one, step up, please. ffprobe, of course. Regards, -- Nicolas George ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
Am 09.03.21 um 10:43 schrieb Ulf Zibis: Am 09.03.21 um 09:57 schrieb Peter White: The frame count *is* exact. The way to get there is just not that pretty. If anybody on this list knows a better one, step up, please. I suspect that the last "progression" line shows the exact count, as it may only report the last progression state a few µs before the operation is completed. Can one please clarify this? -Ulf ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
Am 09.03.21 um 09:57 schrieb Peter White: On Tue, Mar 09, 2021 at 09:46:43AM +0100, Ulf Zibis wrote: Am 09.03.21 um 09:26 schrieb Peter White: On Tue, Mar 09, 2021 at 09:13:14AM +0100, Ulf Zibis wrote: Hi,, can one please tell me, how I can get the total number of frames of a video? ffmpeg -i input -an -sn -c copy -f null - This basically copies all frames into the void but you get the total count this way in the stats line. Much thanks. This at least gives a ballpark figure. Is there a way to get the exact frame count? The frame count *is* exact. The way to get there is just not that pretty. If anybody on this list knows a better one, step up, please. I suspect that the last "progression" line shows the exact count, as it may only show the last reprted progression state before the operation is completed. -Ulf ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
Peter White (12021-03-09): > If anybody on this list knows a better one, step up, please. ffprobe, of course. Regards, -- Nicolas George signature.asc Description: PGP signature ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
Am 09.03.2021 um 09:46 schrieb Ulf Zibis: Am 09.03.21 um 09:26 schrieb Peter White: On Tue, Mar 09, 2021 at 09:13:14AM +0100, Ulf Zibis wrote: Hi,, can one please tell me, how I can get the total number of frames of a video? ffmpeg -i input -an -sn -c copy -f null - This basically copies all frames into the void but you get the total count this way in the stats line. Much thanks. This at least gives a ballpark figure. Is there a way to get the exact frame count? These links might help: https://stackoverflow.com/questions/2017843/fetch-frame-count-with-ffmpeg https://superuser.com/questions/1512575/why-total-frame-count-is-different-in-ffmpeg-than-ffprobe Michael ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
On Tue, Mar 09, 2021 at 09:46:43AM +0100, Ulf Zibis wrote: > > Am 09.03.21 um 09:26 schrieb Peter White: > > On Tue, Mar 09, 2021 at 09:13:14AM +0100, Ulf Zibis wrote: > > > Hi,, > > > > > > can one please tell me, how I can get the total number of frames of a > > > video? > > ffmpeg -i input -an -sn -c copy -f null - > > > > This basically copies all frames into the void but you get the total > > count this way in the stats line. > > Much thanks. This at least gives a ballpark figure. Is there a way to get the > exact frame count? The frame count *is* exact. The way to get there is just not that pretty. If anybody on this list knows a better one, step up, please. Peter ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
Am 09.03.21 um 09:26 schrieb Peter White: On Tue, Mar 09, 2021 at 09:13:14AM +0100, Ulf Zibis wrote: Hi,, can one please tell me, how I can get the total number of frames of a video? ffmpeg -i input -an -sn -c copy -f null - This basically copies all frames into the void but you get the total count this way in the stats line. Much thanks. This at least gives a ballpark figure. Is there a way to get the exact frame count? -Ulf ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] How to get he total number of frames
On Tue, Mar 09, 2021 at 09:13:14AM +0100, Ulf Zibis wrote: > Hi,, > > can one please tell me, how I can get the total number of frames of a video? ffmpeg -i input -an -sn -c copy -f null - This basically copies all frames into the void but you get the total count this way in the stats line. Peter ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".