Skip to content

Conversation

@kkroening
Copy link
Owner

@kkroening kkroening commented Jul 6, 2017

The split operator now does the right thing:

import ffmpeg

overlay_file = ffmpeg.input('overlay.png')
split = (ffmpeg
    .input('input.mp4')
    .hflip()
    .split()
)
(ffmpeg
    .concat(
        split[0].vflip(),
        split[1]
    )
    .output('out.mp4')
)

screen shot 2017-07-06 at 3 55 28 am

This paves the way to having both multi-input and multi-output components. To access particular outputs of a multi-output node, use either the .stream function or bracket shorthand:

split = in.split()
split0 = split.stream(0)
split1 = split[1]

I decided to forego the automatic split stuff for now. It was probably more work to add multi-output support right away, but I think it's more correct in the long run. The automatic splitting will eventually happen as a pre-processing step and produce the same kind of graph as though the split were inserted manually.

@depau
Copy link
Collaborator

depau commented Jul 6, 2017

Great! I'll test it on Saturday and let you know.

@depau
Copy link
Collaborator

depau commented Jul 9, 2017

This doesn't seem to work with merge_output. I tried to adjust the code but ended up messing up everything, so I just quit trying

import ffmpeg

i = ffmpeg.input("test.ogg")
s = i.split()
l = [s[i].output("out"+str(i)) for i in range(5)]

print(l)
[output(filename='out0')[None] <165772f6fba8>,
 output(filename='out1')[None] <1fb1f5f0ca46>,
 output(filename='out2')[None] <1f417509efbd>,
 output(filename='out3')[None] <1451115eaeca>,
 output(filename='out4')[None] <2e7c02df8060>]
o = ffmpeg.merge_outputs(*l)
---------------------------------------------------------------------------

TypeError                                 Traceback (most recent call last)

<ipython-input-8-7629009c961a> in <module>()
----> 1 o = ffmpeg.merge_outputs(*l)


[removed]/ffmpeg-python/ffmpeg/_ffmpeg.py in merge_outputs(*streams)
     38     """Include all given outputs in one ffmpeg command line
     39     """
---> 40     return MergeOutputsNode(streams, merge_outputs.__name__).stream()
     41 
     42 


[removed]/ffmpeg-python/ffmpeg/nodes.py in __init__(self, stream, name)
    176             outgoing_stream_type=OutputStream,
    177             min_inputs=1,
--> 178             max_inputs=None
    179         )
    180 


TypeError: __init__() missing 2 required positional arguments: 'args' and 'kwargs'

@kkroening
Copy link
Owner Author

kkroening commented Jul 9, 2017

Ooooooh looks like there aren't any tests for merge_outputs! Regression alert.

I'll make a fix.

@kkroening
Copy link
Owner Author

Ok should be fixed.

Also note that I made it so that merge_outputs is not required. If desired, you can instead do this:

in_ = ffmpeg.input('in.mp4').hflip()
out1 = ffmpeg.output('out1.mp4')
out2 = ffmpeg.output('out1.mp4')
ffmpeg.run([out1, out2], overwrite_output=True)

The merge_outputs + .overwrite_output style is still available as well.

And you can do the same thing with get_args or view:

ffmpeg.view([out1, out2])

Basically anything that takes a stream_spec can take a single stream, list of streams, or stream dict.

@kkroening
Copy link
Owner Author

This probably won't affect you, but I also uncovered this edgecase-ish bug: #23

@kkroening
Copy link
Owner Author

Let me know if this fixes it for you. Thanks for testing

@depau
Copy link
Collaborator

depau commented Jul 10, 2017

Okay it seems to work now with merge_outputs.

Graph rendering

It gives out this which looks quit good to me:

ffmpeg -i test.ogg \
-filter_complex [0]split[s0][s1][s2][s3][s4];[s0]hflip[s5];[s5]vflip[s6] \
-map [s6] out0wfilters \
-map [s1] out1 \
-map [s2] out2 \
-map [s3] out3 \
-map [s4] out4

@depau
Copy link
Collaborator

depau commented Jul 10, 2017

Nope. See split documentation. It needs the number of splits.
https://ffmpeg.org/ffmpeg-filters.html#split_002c-asplit

I added it manually to the command line and now works. Let me see what I can do with the code.

Conflicts:
	ffmpeg/_filters.py
	ffmpeg/_utils.py
	ffmpeg/nodes.py
	ffmpeg/tests/test_ffmpeg.py
@kkroening
Copy link
Owner Author

Should be fixed now. I'm gonna merge this. Let me know if there are any issues.

@kkroening kkroening merged commit 7669492 into master Jul 12, 2017
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

Successfully merging this pull request may close these issues.

3 participants