ffmpeg-python
ffmpeg-python copied to clipboard
Support for concat 'demuxer' instead of concat filter?
Hi folks,
Thank you for creating ffmpeg-python! I'm running a very simple concat operator using ffmpeg-python like so:
def concatVideos(args):
files = []
streams =[]
for fileName in os.listdir(args.directorySrc):
files.append(fileName)
fileName = os.path.join(args.directorySrc, fileName)
for f in files:
streams.append(ffmpeg.input(fileName))
dest = '/home/user/full.mp4'
ffmpeg.concat(*streams).output(dest).run()
And its running super slow, here is the output i see from my script:
[Parsed_concat_0 @ 0x560af8a22460] Buffer queue overflow, dropping.=6348.7kbits/s speed=0.324x
Last message repeated 17 times
[Parsed_concat_0 @ 0x560af8a22460] Buffer queue overflow, dropping.=5929.5kbits/s speed=0.328x
Last message repeated 29 times
[Parsed_concat_0 @ 0x560af8a22460] Buffer queue overflow, dropping.=6091.4kbits/s speed=0.335x
When I run the same concatenation from command line:
$ cat /tmp/filelist
file '/mnt/smb/src/18.10.27_121205.mp4'
file '/mnt/smb/src/18.10.27_123438.mp4'
file '/mnt/smb/src/18.10.27_131923.mp4'
$ ffmpeg -f concat -safe 0 -i /tmp/filelist -c copy full.mp4
I get a much faster operation:
frame=10218 fps=2243 q=-1.0 Lsize= 522251kB time=00:02:50.43 bitrate=25101.8kbits/s speed=37.4x
Turns out the command line version is using the concat 'demuxer' which is significantly faster, this is documented here: https://trac.ffmpeg.org/wiki/Concatenate Curious if ffmpeg-python has any support for this type of speedy operation :)
(
ffmpeg
.input('/tmp/filelist', format='concat', safe=0)
.output('full.mp4', c='copy')
.run()
)
format='concat', safe=0) ^ SyntaxError: invalid syntax
(
ffmpeg
.input('/tmp/filelist', format='concat', safe=0)
.output('full.mp4', c='copy')
.run()
)
Why does this fail?
Hey,
having a related issue that I thought I'd add here. I'm trying to concat two streams with
vid1 = ffmpeg.input(v1filename)
vid2 = ffmpeg.input(v2filename)
result = ffmpeg.concat(vid1,vid2)
out = ffmpeg.output(result, 'final.mkv',c="copy")
This only gives me
Streamcopy requested for output stream 0:0, which is fed from a complex filtergraph. Filtering and streamcopy cannot be used together.
Is use of the concat demuxer (instead of the filter) not possible with the ffmpeg.concat function, supplying the streams directly instead of a text file?
input
Is there a way to provide fps or framerate?
With framerate I got: Option framerate not found.
With fps: Unrecognized option 'fps'.
Error splitting the argument list: Option not found
Thanks!!
format='concat', safe=0) ^ SyntaxError: invalid syntax
Works for me with Python 3.12.1 and ffmpeg-python 0.2.
Is use of the concat demuxer (instead of the filter) not possible with the ffmpeg.concat function, supplying the streams directly instead of a text file?
As of release 0.2 ffmpeg-python simply doesn't provide any syntactic sugar around creating file lists for the concat demuxer. The concat() function is just able to construct concat filter arguments.