Xabe.FFmpeg icon indicating copy to clipboard operation
Xabe.FFmpeg copied to clipboard

Pre-Input Stream Parameters are incorrectly placed before all Stream Inputs

Open adanvdo opened this issue 2 years ago • 2 comments

There is unfortunately no good way to handle seeking in a conversion that contains separate audio and video stream files. Here are the issues I am encountering.

Scenario: I have one IVideoStream and one IAudioStream obtained from separate URLs

  1. When I SetSeek on the Video stream and Audio stream separately, it is not applied to the audio when it is converted. After the conversion is complete, the combined output media includes the correct video segment, but the audio clip starts at 0:00

  2. When I SetSeek on the conversion, I get the same result. The seek is not properly applied to the audio stream and the output contains Video and Audio that are not properly synchronized.

  3. The same issue occurs when I attempt to pass SetSeek and Duration as User Defined Parameters. It seems the library only applies the seek to the first stream in the conversion.

  4. When using IVideoStream.Split and IAudioStream.Split, the seek is properly applied to both streams, but the process takes a very long time with no progress output. It is several times slower doing it this way, which wouldnt necessarily be the worst thing if only there was some progress output to let you know ffmpeg is working.

I'm continuing to experiment with this to see if there is anything I might be missing, but ultimately I think the problem is that any pre-input parameters are only applied to the first stream source, and not applied to any subsequent stream sources.

adanvdo avatar Sep 16 '22 15:09 adanvdo

I have found the problem. For some reason, Conversion.Build puts any pre-input parameters before all of the inputs.

-ss 0:02:00.000 -ss 0:02:00.000 -i "[input path 1]" -i "[input path 2]" -map 0:0 -map 1:0 -n -t 00:00:10 "[output path]"

I will try to find the cause of this.

adanvdo avatar Sep 19 '22 01:09 adanvdo

I have modified the title of this issue, because it applies to all pre-input parameters defined for a stream. I was able to fix the problem by doing the following:

  1. Remove GetStreamPreInputs method
  2. Change the GetInputs() method to prepend Pre-Input parameters for the stream before the input value

image

With this change, pre-input parameters defined for individual streams are now put in the correct place, just before the input

adanvdo avatar Sep 19 '22 02:09 adanvdo