FFMPEG is trim and -t ignored for the PSNR filter?










0















I wanted to run a PSNR check on a encoded segment but avoid extracting the segment in a lossless codec first for comparsion. I just wanted to trim the input, however it looks like this is disabled.



My command:



ffmpeg -i original.mp4 -i segment.mp4 -filter_complex "[0:v]trim=10:20,setpts=PTS-STARTPTS[0v];[1:v]setpts=PTS-STARTPTS[1v];[0v][1v]psnr" -f null -


This will run through the whole original input file and not trim the video in the filter.



If I try to trim the input with -ss and -t, only the input -ss flag is working. It will set the input correct but ignore the -t timestamp.



ffmpeg -ss 10 -i original.mp4 -t 10 -i segment.mp4 -filter_complex [0:v][1:v]psnr -f null - 


Different placement of the -t will have no effect.



I also tried to set the duration in trim while keeping the -ss input which is working.



ffmpeg -ss 10 -i original.mp4 -i segment.mp4 -filter_complex "[0:v]trim=duration=10,setpts=PTS-STARTPTS[0v];[1:v]setpts=PTS-STARTPTS[1v];[0v][1v]psnr" -f null - 


I did try this with end and end_frame but neither one worked.



The same applies if I use -lavfi instead of -filter_complex.



I did have a brief look at the sourcecode of the PSNR filter but could not find any refrences to trim or -t.



Is this function blocked or am I doing something wrong?
Would there be an alternative way to doing this without encoding a lossless version of the same segment to compare?










share|improve this question




























    0















    I wanted to run a PSNR check on a encoded segment but avoid extracting the segment in a lossless codec first for comparsion. I just wanted to trim the input, however it looks like this is disabled.



    My command:



    ffmpeg -i original.mp4 -i segment.mp4 -filter_complex "[0:v]trim=10:20,setpts=PTS-STARTPTS[0v];[1:v]setpts=PTS-STARTPTS[1v];[0v][1v]psnr" -f null -


    This will run through the whole original input file and not trim the video in the filter.



    If I try to trim the input with -ss and -t, only the input -ss flag is working. It will set the input correct but ignore the -t timestamp.



    ffmpeg -ss 10 -i original.mp4 -t 10 -i segment.mp4 -filter_complex [0:v][1:v]psnr -f null - 


    Different placement of the -t will have no effect.



    I also tried to set the duration in trim while keeping the -ss input which is working.



    ffmpeg -ss 10 -i original.mp4 -i segment.mp4 -filter_complex "[0:v]trim=duration=10,setpts=PTS-STARTPTS[0v];[1:v]setpts=PTS-STARTPTS[1v];[0v][1v]psnr" -f null - 


    I did try this with end and end_frame but neither one worked.



    The same applies if I use -lavfi instead of -filter_complex.



    I did have a brief look at the sourcecode of the PSNR filter but could not find any refrences to trim or -t.



    Is this function blocked or am I doing something wrong?
    Would there be an alternative way to doing this without encoding a lossless version of the same segment to compare?










    share|improve this question


























      0












      0








      0








      I wanted to run a PSNR check on a encoded segment but avoid extracting the segment in a lossless codec first for comparsion. I just wanted to trim the input, however it looks like this is disabled.



      My command:



      ffmpeg -i original.mp4 -i segment.mp4 -filter_complex "[0:v]trim=10:20,setpts=PTS-STARTPTS[0v];[1:v]setpts=PTS-STARTPTS[1v];[0v][1v]psnr" -f null -


      This will run through the whole original input file and not trim the video in the filter.



      If I try to trim the input with -ss and -t, only the input -ss flag is working. It will set the input correct but ignore the -t timestamp.



      ffmpeg -ss 10 -i original.mp4 -t 10 -i segment.mp4 -filter_complex [0:v][1:v]psnr -f null - 


      Different placement of the -t will have no effect.



      I also tried to set the duration in trim while keeping the -ss input which is working.



      ffmpeg -ss 10 -i original.mp4 -i segment.mp4 -filter_complex "[0:v]trim=duration=10,setpts=PTS-STARTPTS[0v];[1:v]setpts=PTS-STARTPTS[1v];[0v][1v]psnr" -f null - 


      I did try this with end and end_frame but neither one worked.



      The same applies if I use -lavfi instead of -filter_complex.



      I did have a brief look at the sourcecode of the PSNR filter but could not find any refrences to trim or -t.



      Is this function blocked or am I doing something wrong?
      Would there be an alternative way to doing this without encoding a lossless version of the same segment to compare?










      share|improve this question
















      I wanted to run a PSNR check on a encoded segment but avoid extracting the segment in a lossless codec first for comparsion. I just wanted to trim the input, however it looks like this is disabled.



      My command:



      ffmpeg -i original.mp4 -i segment.mp4 -filter_complex "[0:v]trim=10:20,setpts=PTS-STARTPTS[0v];[1:v]setpts=PTS-STARTPTS[1v];[0v][1v]psnr" -f null -


      This will run through the whole original input file and not trim the video in the filter.



      If I try to trim the input with -ss and -t, only the input -ss flag is working. It will set the input correct but ignore the -t timestamp.



      ffmpeg -ss 10 -i original.mp4 -t 10 -i segment.mp4 -filter_complex [0:v][1:v]psnr -f null - 


      Different placement of the -t will have no effect.



      I also tried to set the duration in trim while keeping the -ss input which is working.



      ffmpeg -ss 10 -i original.mp4 -i segment.mp4 -filter_complex "[0:v]trim=duration=10,setpts=PTS-STARTPTS[0v];[1:v]setpts=PTS-STARTPTS[1v];[0v][1v]psnr" -f null - 


      I did try this with end and end_frame but neither one worked.



      The same applies if I use -lavfi instead of -filter_complex.



      I did have a brief look at the sourcecode of the PSNR filter but could not find any refrences to trim or -t.



      Is this function blocked or am I doing something wrong?
      Would there be an alternative way to doing this without encoding a lossless version of the same segment to compare?







      ffmpeg






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 14 '18 at 15:54







      secondplace

















      asked Nov 14 '18 at 15:18









      secondplacesecondplace

      459




      459






















          1 Answer
          1






          active

          oldest

          votes


















          1














          The original command is almost fine. However, the order of inputs should be swapped, and if there's any audio, that should be disabled.



          ffmpeg -i original.mp4 -i segment.mp4 -filter_complex "[0:v]trim=10:20,setpts=PTS-STARTPTS[0v];[1:v]setpts=PTS-STARTPTS[1v];[1v][0v]psnr" -an -f null -


          Also, in the snippet below



          ffmpeg -ss 10 -i original.mp4 -t 10 -i segment.mp4


          if you meant to limit the duration of original.mp4, then -t 10 should be placed before -i original.mp4.






          share|improve this answer























          • i cannot confirm this. if i switch the videos it will still run the full length of the original input. also it makes no difference if it would be working. if the two videos are switched since they are still compared to eachother and would give exactly the same result regarding the placement. also the -t flag, i stated in my original post that -t will be ignored no matter where i place it.

            – secondplace
            Nov 14 '18 at 16:35












          • PSNR is not a symmetrical metric so the order of the inputs matter. Share the full log.

            – Gyan
            Nov 14 '18 at 16:40











          • please test it for yourself. since this is not related to my initial question it would be confusing to add the log about something else to the above question. i can give you the two results lines here: $ffmpeg -i $input1 -i $input2 -filter_complex "[0:v][1:v]psnr" -f null - PSNR y:45.763443 u:48.766435 v:50.143376 average:46.673590 min:45.239254 max:50.089223 $ffmpeg -i $input1 -i $input2 -filter_complex "[1:v][0:v]psnr" -f null - PSNR y:45.763443 u:48.766435 v:50.143376 average:46.673590 min:45.239254 max:50.089223

            – secondplace
            Nov 14 '18 at 16:44











          • I meant the log of your first command. I can reproduce the asymmetry of PSNR here.

            – Gyan
            Nov 14 '18 at 16:52











          • I was wrong about the -t flag and it worked being placed infront! i must have missed that in all my testing and moving things around. additionally it looks like the trim is working too but the PSNR filter will run through the whole video regardless... which confused me. thank you for pushing the right buttons and make me double and triple check. (btw, I still cannot confirm different PSNR results by switching the videos.)

            – secondplace
            Nov 14 '18 at 17:25










          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%2f53303433%2fffmpeg-is-trim-and-t-ignored-for-the-psnr-filter%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









          1














          The original command is almost fine. However, the order of inputs should be swapped, and if there's any audio, that should be disabled.



          ffmpeg -i original.mp4 -i segment.mp4 -filter_complex "[0:v]trim=10:20,setpts=PTS-STARTPTS[0v];[1:v]setpts=PTS-STARTPTS[1v];[1v][0v]psnr" -an -f null -


          Also, in the snippet below



          ffmpeg -ss 10 -i original.mp4 -t 10 -i segment.mp4


          if you meant to limit the duration of original.mp4, then -t 10 should be placed before -i original.mp4.






          share|improve this answer























          • i cannot confirm this. if i switch the videos it will still run the full length of the original input. also it makes no difference if it would be working. if the two videos are switched since they are still compared to eachother and would give exactly the same result regarding the placement. also the -t flag, i stated in my original post that -t will be ignored no matter where i place it.

            – secondplace
            Nov 14 '18 at 16:35












          • PSNR is not a symmetrical metric so the order of the inputs matter. Share the full log.

            – Gyan
            Nov 14 '18 at 16:40











          • please test it for yourself. since this is not related to my initial question it would be confusing to add the log about something else to the above question. i can give you the two results lines here: $ffmpeg -i $input1 -i $input2 -filter_complex "[0:v][1:v]psnr" -f null - PSNR y:45.763443 u:48.766435 v:50.143376 average:46.673590 min:45.239254 max:50.089223 $ffmpeg -i $input1 -i $input2 -filter_complex "[1:v][0:v]psnr" -f null - PSNR y:45.763443 u:48.766435 v:50.143376 average:46.673590 min:45.239254 max:50.089223

            – secondplace
            Nov 14 '18 at 16:44











          • I meant the log of your first command. I can reproduce the asymmetry of PSNR here.

            – Gyan
            Nov 14 '18 at 16:52











          • I was wrong about the -t flag and it worked being placed infront! i must have missed that in all my testing and moving things around. additionally it looks like the trim is working too but the PSNR filter will run through the whole video regardless... which confused me. thank you for pushing the right buttons and make me double and triple check. (btw, I still cannot confirm different PSNR results by switching the videos.)

            – secondplace
            Nov 14 '18 at 17:25















          1














          The original command is almost fine. However, the order of inputs should be swapped, and if there's any audio, that should be disabled.



          ffmpeg -i original.mp4 -i segment.mp4 -filter_complex "[0:v]trim=10:20,setpts=PTS-STARTPTS[0v];[1:v]setpts=PTS-STARTPTS[1v];[1v][0v]psnr" -an -f null -


          Also, in the snippet below



          ffmpeg -ss 10 -i original.mp4 -t 10 -i segment.mp4


          if you meant to limit the duration of original.mp4, then -t 10 should be placed before -i original.mp4.






          share|improve this answer























          • i cannot confirm this. if i switch the videos it will still run the full length of the original input. also it makes no difference if it would be working. if the two videos are switched since they are still compared to eachother and would give exactly the same result regarding the placement. also the -t flag, i stated in my original post that -t will be ignored no matter where i place it.

            – secondplace
            Nov 14 '18 at 16:35












          • PSNR is not a symmetrical metric so the order of the inputs matter. Share the full log.

            – Gyan
            Nov 14 '18 at 16:40











          • please test it for yourself. since this is not related to my initial question it would be confusing to add the log about something else to the above question. i can give you the two results lines here: $ffmpeg -i $input1 -i $input2 -filter_complex "[0:v][1:v]psnr" -f null - PSNR y:45.763443 u:48.766435 v:50.143376 average:46.673590 min:45.239254 max:50.089223 $ffmpeg -i $input1 -i $input2 -filter_complex "[1:v][0:v]psnr" -f null - PSNR y:45.763443 u:48.766435 v:50.143376 average:46.673590 min:45.239254 max:50.089223

            – secondplace
            Nov 14 '18 at 16:44











          • I meant the log of your first command. I can reproduce the asymmetry of PSNR here.

            – Gyan
            Nov 14 '18 at 16:52











          • I was wrong about the -t flag and it worked being placed infront! i must have missed that in all my testing and moving things around. additionally it looks like the trim is working too but the PSNR filter will run through the whole video regardless... which confused me. thank you for pushing the right buttons and make me double and triple check. (btw, I still cannot confirm different PSNR results by switching the videos.)

            – secondplace
            Nov 14 '18 at 17:25













          1












          1








          1







          The original command is almost fine. However, the order of inputs should be swapped, and if there's any audio, that should be disabled.



          ffmpeg -i original.mp4 -i segment.mp4 -filter_complex "[0:v]trim=10:20,setpts=PTS-STARTPTS[0v];[1:v]setpts=PTS-STARTPTS[1v];[1v][0v]psnr" -an -f null -


          Also, in the snippet below



          ffmpeg -ss 10 -i original.mp4 -t 10 -i segment.mp4


          if you meant to limit the duration of original.mp4, then -t 10 should be placed before -i original.mp4.






          share|improve this answer













          The original command is almost fine. However, the order of inputs should be swapped, and if there's any audio, that should be disabled.



          ffmpeg -i original.mp4 -i segment.mp4 -filter_complex "[0:v]trim=10:20,setpts=PTS-STARTPTS[0v];[1:v]setpts=PTS-STARTPTS[1v];[1v][0v]psnr" -an -f null -


          Also, in the snippet below



          ffmpeg -ss 10 -i original.mp4 -t 10 -i segment.mp4


          if you meant to limit the duration of original.mp4, then -t 10 should be placed before -i original.mp4.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 14 '18 at 16:01









          GyanGyan

          33.4k22870




          33.4k22870












          • i cannot confirm this. if i switch the videos it will still run the full length of the original input. also it makes no difference if it would be working. if the two videos are switched since they are still compared to eachother and would give exactly the same result regarding the placement. also the -t flag, i stated in my original post that -t will be ignored no matter where i place it.

            – secondplace
            Nov 14 '18 at 16:35












          • PSNR is not a symmetrical metric so the order of the inputs matter. Share the full log.

            – Gyan
            Nov 14 '18 at 16:40











          • please test it for yourself. since this is not related to my initial question it would be confusing to add the log about something else to the above question. i can give you the two results lines here: $ffmpeg -i $input1 -i $input2 -filter_complex "[0:v][1:v]psnr" -f null - PSNR y:45.763443 u:48.766435 v:50.143376 average:46.673590 min:45.239254 max:50.089223 $ffmpeg -i $input1 -i $input2 -filter_complex "[1:v][0:v]psnr" -f null - PSNR y:45.763443 u:48.766435 v:50.143376 average:46.673590 min:45.239254 max:50.089223

            – secondplace
            Nov 14 '18 at 16:44











          • I meant the log of your first command. I can reproduce the asymmetry of PSNR here.

            – Gyan
            Nov 14 '18 at 16:52











          • I was wrong about the -t flag and it worked being placed infront! i must have missed that in all my testing and moving things around. additionally it looks like the trim is working too but the PSNR filter will run through the whole video regardless... which confused me. thank you for pushing the right buttons and make me double and triple check. (btw, I still cannot confirm different PSNR results by switching the videos.)

            – secondplace
            Nov 14 '18 at 17:25

















          • i cannot confirm this. if i switch the videos it will still run the full length of the original input. also it makes no difference if it would be working. if the two videos are switched since they are still compared to eachother and would give exactly the same result regarding the placement. also the -t flag, i stated in my original post that -t will be ignored no matter where i place it.

            – secondplace
            Nov 14 '18 at 16:35












          • PSNR is not a symmetrical metric so the order of the inputs matter. Share the full log.

            – Gyan
            Nov 14 '18 at 16:40











          • please test it for yourself. since this is not related to my initial question it would be confusing to add the log about something else to the above question. i can give you the two results lines here: $ffmpeg -i $input1 -i $input2 -filter_complex "[0:v][1:v]psnr" -f null - PSNR y:45.763443 u:48.766435 v:50.143376 average:46.673590 min:45.239254 max:50.089223 $ffmpeg -i $input1 -i $input2 -filter_complex "[1:v][0:v]psnr" -f null - PSNR y:45.763443 u:48.766435 v:50.143376 average:46.673590 min:45.239254 max:50.089223

            – secondplace
            Nov 14 '18 at 16:44











          • I meant the log of your first command. I can reproduce the asymmetry of PSNR here.

            – Gyan
            Nov 14 '18 at 16:52











          • I was wrong about the -t flag and it worked being placed infront! i must have missed that in all my testing and moving things around. additionally it looks like the trim is working too but the PSNR filter will run through the whole video regardless... which confused me. thank you for pushing the right buttons and make me double and triple check. (btw, I still cannot confirm different PSNR results by switching the videos.)

            – secondplace
            Nov 14 '18 at 17:25
















          i cannot confirm this. if i switch the videos it will still run the full length of the original input. also it makes no difference if it would be working. if the two videos are switched since they are still compared to eachother and would give exactly the same result regarding the placement. also the -t flag, i stated in my original post that -t will be ignored no matter where i place it.

          – secondplace
          Nov 14 '18 at 16:35






          i cannot confirm this. if i switch the videos it will still run the full length of the original input. also it makes no difference if it would be working. if the two videos are switched since they are still compared to eachother and would give exactly the same result regarding the placement. also the -t flag, i stated in my original post that -t will be ignored no matter where i place it.

          – secondplace
          Nov 14 '18 at 16:35














          PSNR is not a symmetrical metric so the order of the inputs matter. Share the full log.

          – Gyan
          Nov 14 '18 at 16:40





          PSNR is not a symmetrical metric so the order of the inputs matter. Share the full log.

          – Gyan
          Nov 14 '18 at 16:40













          please test it for yourself. since this is not related to my initial question it would be confusing to add the log about something else to the above question. i can give you the two results lines here: $ffmpeg -i $input1 -i $input2 -filter_complex "[0:v][1:v]psnr" -f null - PSNR y:45.763443 u:48.766435 v:50.143376 average:46.673590 min:45.239254 max:50.089223 $ffmpeg -i $input1 -i $input2 -filter_complex "[1:v][0:v]psnr" -f null - PSNR y:45.763443 u:48.766435 v:50.143376 average:46.673590 min:45.239254 max:50.089223

          – secondplace
          Nov 14 '18 at 16:44





          please test it for yourself. since this is not related to my initial question it would be confusing to add the log about something else to the above question. i can give you the two results lines here: $ffmpeg -i $input1 -i $input2 -filter_complex "[0:v][1:v]psnr" -f null - PSNR y:45.763443 u:48.766435 v:50.143376 average:46.673590 min:45.239254 max:50.089223 $ffmpeg -i $input1 -i $input2 -filter_complex "[1:v][0:v]psnr" -f null - PSNR y:45.763443 u:48.766435 v:50.143376 average:46.673590 min:45.239254 max:50.089223

          – secondplace
          Nov 14 '18 at 16:44













          I meant the log of your first command. I can reproduce the asymmetry of PSNR here.

          – Gyan
          Nov 14 '18 at 16:52





          I meant the log of your first command. I can reproduce the asymmetry of PSNR here.

          – Gyan
          Nov 14 '18 at 16:52













          I was wrong about the -t flag and it worked being placed infront! i must have missed that in all my testing and moving things around. additionally it looks like the trim is working too but the PSNR filter will run through the whole video regardless... which confused me. thank you for pushing the right buttons and make me double and triple check. (btw, I still cannot confirm different PSNR results by switching the videos.)

          – secondplace
          Nov 14 '18 at 17:25





          I was wrong about the -t flag and it worked being placed infront! i must have missed that in all my testing and moving things around. additionally it looks like the trim is working too but the PSNR filter will run through the whole video regardless... which confused me. thank you for pushing the right buttons and make me double and triple check. (btw, I still cannot confirm different PSNR results by switching the videos.)

          – secondplace
          Nov 14 '18 at 17:25



















          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%2f53303433%2fffmpeg-is-trim-and-t-ignored-for-the-psnr-filter%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

          Kleinkühnau

          Makov (Slowakei)

          Deutsches Schauspielhaus