secondplace
secondplace

Reputation: 578

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

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?

Upvotes: 0

Views: 253

Answers (1)

Gyan
Gyan

Reputation: 92998

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.

Upvotes: 1

Related Questions