Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help : Stream Concat issue. #840

Open
808Code opened this issue Jun 10, 2024 · 0 comments
Open

Help : Stream Concat issue. #840

808Code opened this issue Jun 10, 2024 · 0 comments

Comments

@808Code
Copy link

808Code commented Jun 10, 2024

These are the list of my video streams :

streams = [crop(405, 720, 0, 0)[None] <1419607ede0d>,
crop(405, 720, 168.0, 0)[None] <60513abfe190>,
crop(405, 720, 105.0, 0)[None] <146a20b22810>,
crop(405, 720, 170.0, 0)[None] <5c287e877550>,
crop(405, 720, 722.5, 0)[None] <2f24c0d564b0>,
crop(405, 720, 0, 0)[None] <1e03ffc24d4a>]```

Where 0 and 5 are returns of these function:

def zoom_out_stream(input_file, start_time, end_time, width, height):
  return (
    ffmpeg.input(input_file, ss=start_time, to=end_time).filter(
        'scale', f'min({width},iw)', f'min({height},ih)', force_original_aspect_ratio='decrease'
    ).filter(
        'pad', width+1, height+1, -1, -1, 'black'
    ).filter('crop', width, height , 0, 0)
  )

while others are return of these :

def zoom_in_stream(input_file, start_time, end_time, width, height,x, y):
    return (
        ffmpeg
        .input(input_file, ss=start_time, to=end_time)
        .filter('crop', width, height , x, y)
    )

When i try to concat the above mentioned lists with the code :

concatenated_stream = ffmpeg.concat(*streams)


output_settings = {
    'c:v': 'libx264',  # Video codec
    'preset': 'ultrafast',  # Preset for encoding speed
}

# Output filename
output_filename ='output.mp4'

# Build ffmpeg command
ffmpeg_cmd = ffmpeg.output(concatenated_stream, output_filename, **output_settings)

try:
    ffmpeg_cmd.run(capture_stdout=True, capture_stderr=True)
except ffmpeg.Error as e:
    print('stdout:', e.stdout.decode('utf8'))
    print('stderr:', e.stderr.decode('utf8'))
    raise e

I keep getting the error :

Stream mapping:
  Stream #0:0 (h264) -> scale
  Stream #1:0 (h264) -> crop
  Stream #2:0 (h264) -> crop
  Stream #3:0 (h264) -> crop
  Stream #4:0 (h264) -> crop
  Stream #5:0 (h264) -> scale
  concat -> Stream #0:0 (libx264)
Press [q] to stop, [?] for help
[Parsed_concat_10 @ 0x5ab6baa53080] Input link in0:v0 parameters (size 404x720, SAR 1:1) do not match the corresponding output link in0:v0 parameters (404x720, SAR 1216:1215)
[Parsed_concat_10 @ 0x5ab6baa53080] Failed to configure output pad on Parsed_concat_10
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #5:0
Conversion failed!

Any idea how i can solve this all the streams have been cropped to the same width and height as mentioned in the streams list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant