FFMPEG : Obtain the system time corresponding to each frame present in a video












1















I am currently recording the screen using the below command on Windows 10 system,



ffmpeg.exe -loglevel quiet -f gdigrab -framerate 30 -i desktop -vf mpdecimate,setpts=N/FRAME_RATE/TB -vcodec libx264 -pix_fmt yuv420p -preset slow -crf 0 -threads 0 nodups.mkv


If I record a video for 5 mins, where 4 minutes out of it is idle. The final video obtained is only 1 minute. I want to know the system time corresponding to a specific frame from this 1 minute video.
I tried making use of the command to obtain the frame information from this 1 minute video for 40th frame like : ffmpeg -i nodups.mkv -vf select='eq(n,40)',showinfo -f null -
This outputs me



[Parsed_showinfo_1 @ 000002455fce5dc0] n:   0 pts:   1333 pts_time:1.333   pos:   158601 fmt:yuv420p sar:0/1 s:1600x900 i:P iskey:0 type:P checksum:885ECCE2 plane_checksum:[7D89AD8E DC745BDC 0E23C369] mean:[158 128 128] stdev:[101.7 4.5 4.0


Is there a way to obtain the system time when this frame was captured using FFMPEG ? Any inputs will help.










share|improve this question





























    1















    I am currently recording the screen using the below command on Windows 10 system,



    ffmpeg.exe -loglevel quiet -f gdigrab -framerate 30 -i desktop -vf mpdecimate,setpts=N/FRAME_RATE/TB -vcodec libx264 -pix_fmt yuv420p -preset slow -crf 0 -threads 0 nodups.mkv


    If I record a video for 5 mins, where 4 minutes out of it is idle. The final video obtained is only 1 minute. I want to know the system time corresponding to a specific frame from this 1 minute video.
    I tried making use of the command to obtain the frame information from this 1 minute video for 40th frame like : ffmpeg -i nodups.mkv -vf select='eq(n,40)',showinfo -f null -
    This outputs me



    [Parsed_showinfo_1 @ 000002455fce5dc0] n:   0 pts:   1333 pts_time:1.333   pos:   158601 fmt:yuv420p sar:0/1 s:1600x900 i:P iskey:0 type:P checksum:885ECCE2 plane_checksum:[7D89AD8E DC745BDC 0E23C369] mean:[158 128 128] stdev:[101.7 4.5 4.0


    Is there a way to obtain the system time when this frame was captured using FFMPEG ? Any inputs will help.










    share|improve this question



























      1












      1








      1








      I am currently recording the screen using the below command on Windows 10 system,



      ffmpeg.exe -loglevel quiet -f gdigrab -framerate 30 -i desktop -vf mpdecimate,setpts=N/FRAME_RATE/TB -vcodec libx264 -pix_fmt yuv420p -preset slow -crf 0 -threads 0 nodups.mkv


      If I record a video for 5 mins, where 4 minutes out of it is idle. The final video obtained is only 1 minute. I want to know the system time corresponding to a specific frame from this 1 minute video.
      I tried making use of the command to obtain the frame information from this 1 minute video for 40th frame like : ffmpeg -i nodups.mkv -vf select='eq(n,40)',showinfo -f null -
      This outputs me



      [Parsed_showinfo_1 @ 000002455fce5dc0] n:   0 pts:   1333 pts_time:1.333   pos:   158601 fmt:yuv420p sar:0/1 s:1600x900 i:P iskey:0 type:P checksum:885ECCE2 plane_checksum:[7D89AD8E DC745BDC 0E23C369] mean:[158 128 128] stdev:[101.7 4.5 4.0


      Is there a way to obtain the system time when this frame was captured using FFMPEG ? Any inputs will help.










      share|improve this question
















      I am currently recording the screen using the below command on Windows 10 system,



      ffmpeg.exe -loglevel quiet -f gdigrab -framerate 30 -i desktop -vf mpdecimate,setpts=N/FRAME_RATE/TB -vcodec libx264 -pix_fmt yuv420p -preset slow -crf 0 -threads 0 nodups.mkv


      If I record a video for 5 mins, where 4 minutes out of it is idle. The final video obtained is only 1 minute. I want to know the system time corresponding to a specific frame from this 1 minute video.
      I tried making use of the command to obtain the frame information from this 1 minute video for 40th frame like : ffmpeg -i nodups.mkv -vf select='eq(n,40)',showinfo -f null -
      This outputs me



      [Parsed_showinfo_1 @ 000002455fce5dc0] n:   0 pts:   1333 pts_time:1.333   pos:   158601 fmt:yuv420p sar:0/1 s:1600x900 i:P iskey:0 type:P checksum:885ECCE2 plane_checksum:[7D89AD8E DC745BDC 0E23C369] mean:[158 128 128] stdev:[101.7 4.5 4.0


      Is there a way to obtain the system time when this frame was captured using FFMPEG ? Any inputs will help.







      video ffmpeg duplicates timestamp video-capture






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 20 '18 at 11:04







      User

















      asked Nov 20 '18 at 10:38









      UserUser

      236




      236
























          1 Answer
          1






          active

          oldest

          votes


















          2














          Use



          ffmpeg.exe -f gdigrab -framerate 30 -i desktop -filter_complex settb=1/1000,setpts=RTCTIME/1000-1500000000000,mpdecimate,split[out][ts];[out]setpts=N/FRAME_RATE/TB[out] -map [out] -vcodec libx264 -pix_fmt yuv420p -preset fast -crf 0 -threads 0 nodups.mkv -map [ts] -f mkvtimestamp_v2 nodups.txt -vsync 0



          FFmpeg supports a data format called mkvtimestamp_v2 which stores timestamps as text in millisecond precision. So, in the command above, the input timestamps are first converted to millisecond precision with settb, then setpts is used to assign the wallclock time to each frame. But because the text format has a limited precision, we need to reduce the timestamp. That's done by subtracting 15e11. The after the mpdecimate, we split the result, sending one copy for encoding and one for metadata output.



          nodups.txt will look like this



          # timecode format v2
          42721944800
          42721944867
          42721944933
          42721945200
          ...


          For frame no. X, select the Xth entry, add 15e11 (1500000000000) and then convert to a human timestamp from e.g. https://www.epochconverter.com/






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53391150%2fffmpeg-obtain-the-system-time-corresponding-to-each-frame-present-in-a-video%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            Use



            ffmpeg.exe -f gdigrab -framerate 30 -i desktop -filter_complex settb=1/1000,setpts=RTCTIME/1000-1500000000000,mpdecimate,split[out][ts];[out]setpts=N/FRAME_RATE/TB[out] -map [out] -vcodec libx264 -pix_fmt yuv420p -preset fast -crf 0 -threads 0 nodups.mkv -map [ts] -f mkvtimestamp_v2 nodups.txt -vsync 0



            FFmpeg supports a data format called mkvtimestamp_v2 which stores timestamps as text in millisecond precision. So, in the command above, the input timestamps are first converted to millisecond precision with settb, then setpts is used to assign the wallclock time to each frame. But because the text format has a limited precision, we need to reduce the timestamp. That's done by subtracting 15e11. The after the mpdecimate, we split the result, sending one copy for encoding and one for metadata output.



            nodups.txt will look like this



            # timecode format v2
            42721944800
            42721944867
            42721944933
            42721945200
            ...


            For frame no. X, select the Xth entry, add 15e11 (1500000000000) and then convert to a human timestamp from e.g. https://www.epochconverter.com/






            share|improve this answer




























              2














              Use



              ffmpeg.exe -f gdigrab -framerate 30 -i desktop -filter_complex settb=1/1000,setpts=RTCTIME/1000-1500000000000,mpdecimate,split[out][ts];[out]setpts=N/FRAME_RATE/TB[out] -map [out] -vcodec libx264 -pix_fmt yuv420p -preset fast -crf 0 -threads 0 nodups.mkv -map [ts] -f mkvtimestamp_v2 nodups.txt -vsync 0



              FFmpeg supports a data format called mkvtimestamp_v2 which stores timestamps as text in millisecond precision. So, in the command above, the input timestamps are first converted to millisecond precision with settb, then setpts is used to assign the wallclock time to each frame. But because the text format has a limited precision, we need to reduce the timestamp. That's done by subtracting 15e11. The after the mpdecimate, we split the result, sending one copy for encoding and one for metadata output.



              nodups.txt will look like this



              # timecode format v2
              42721944800
              42721944867
              42721944933
              42721945200
              ...


              For frame no. X, select the Xth entry, add 15e11 (1500000000000) and then convert to a human timestamp from e.g. https://www.epochconverter.com/






              share|improve this answer


























                2












                2








                2







                Use



                ffmpeg.exe -f gdigrab -framerate 30 -i desktop -filter_complex settb=1/1000,setpts=RTCTIME/1000-1500000000000,mpdecimate,split[out][ts];[out]setpts=N/FRAME_RATE/TB[out] -map [out] -vcodec libx264 -pix_fmt yuv420p -preset fast -crf 0 -threads 0 nodups.mkv -map [ts] -f mkvtimestamp_v2 nodups.txt -vsync 0



                FFmpeg supports a data format called mkvtimestamp_v2 which stores timestamps as text in millisecond precision. So, in the command above, the input timestamps are first converted to millisecond precision with settb, then setpts is used to assign the wallclock time to each frame. But because the text format has a limited precision, we need to reduce the timestamp. That's done by subtracting 15e11. The after the mpdecimate, we split the result, sending one copy for encoding and one for metadata output.



                nodups.txt will look like this



                # timecode format v2
                42721944800
                42721944867
                42721944933
                42721945200
                ...


                For frame no. X, select the Xth entry, add 15e11 (1500000000000) and then convert to a human timestamp from e.g. https://www.epochconverter.com/






                share|improve this answer













                Use



                ffmpeg.exe -f gdigrab -framerate 30 -i desktop -filter_complex settb=1/1000,setpts=RTCTIME/1000-1500000000000,mpdecimate,split[out][ts];[out]setpts=N/FRAME_RATE/TB[out] -map [out] -vcodec libx264 -pix_fmt yuv420p -preset fast -crf 0 -threads 0 nodups.mkv -map [ts] -f mkvtimestamp_v2 nodups.txt -vsync 0



                FFmpeg supports a data format called mkvtimestamp_v2 which stores timestamps as text in millisecond precision. So, in the command above, the input timestamps are first converted to millisecond precision with settb, then setpts is used to assign the wallclock time to each frame. But because the text format has a limited precision, we need to reduce the timestamp. That's done by subtracting 15e11. The after the mpdecimate, we split the result, sending one copy for encoding and one for metadata output.



                nodups.txt will look like this



                # timecode format v2
                42721944800
                42721944867
                42721944933
                42721945200
                ...


                For frame no. X, select the Xth entry, add 15e11 (1500000000000) and then convert to a human timestamp from e.g. https://www.epochconverter.com/







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 20 '18 at 14:00









                GyanGyan

                31.5k22668




                31.5k22668






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53391150%2fffmpeg-obtain-the-system-time-corresponding-to-each-frame-present-in-a-video%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    MongoDB - Not Authorized To Execute Command

                    How to fix TextFormField cause rebuild widget in Flutter

                    in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith