question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Simple stream selection?

See original GitHub issue

I’m trying to do some simple stream selection. Using ffmpeg directly, I’d use the map option. However, when trying to do this using ffmpeg-python, I can’t seem to get it correct. The map argument is getting put into a bracket, which doesn’t work.

>>> import ffmpeg
>>> infile = ffmpeg.input('test.mkv')
>>> stream = infile['1']
>>> outfile = ffmpeg.output(stream, 'test-out.mkv')
>>> ffmpeg.compile(outfile)
['ffmpeg', '-i', 'test.mkv', '-map', '[0:1]', 'test-out.mkv']

This fails with the error Output with label '0:1' does not exist in any defined filter graph, or was already used elsewhere.

What is the proper way to do stream selection when you don’t need complex video graphs?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
kkroeningcommented, Jul 11, 2018

@whichken I think your example syntax in the first comment makes the most sense:

import ffmpeg
infile = ffmpeg.input('test.mkv')
outfile = ffmpeg.output(infile['1'], 'test-out.mkv')

And similarly for multiple streams:

infile = ffmpeg.input('test.mkv')
outfile = ffmpeg.output(infile['1'], infile['2'], 'test-out.mkv')

I consider it a bug that -map [0:1] is produced instead of -map 0:1. Will try to make a fix soon.

1reaction
kkroeningcommented, Jul 11, 2018

Or perhaps eventually this shorthand would make things simpler:

infile = ffmpeg.input('test'.mk4')
outfile = ffmpeg.output(infile[[1, 2]], 'test-out.mkv')

or fluently:

(
    ffmpeg
    .input('test.mk4')
    [[1, 2]]
    .output('test-out.mkv')
    .run()
)

The [] operator would basically take either a single identifier (e.g. ['v']) or a list of identifiers (e.g. [[1, 2]]). This is similar to how a library like Pandas operates.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Simplestream
Award-winning and best-in-class provider of next-generation TV solutions and OTT services to some of the biggest players in the broadcast, sport, and media ......
Read more >
The ultimate live streaming guide for beginners | Livestream
Don't pause your dreams to live stream. Check out our beginner's guide on how to live stream and the equipment you need to...
Read more >
Live Streaming Setup: The Only Guide Beginners Will Ever ...
About to make your livestreaming debut? Try Lightstream Studio 2. It's easy to use, no downloads are required, and you'll look professional.
Read more >
How to Start Streaming: Ultimate Guide - Restream
Use these tips to promote your live stream. What is a basic streaming setup? Live streaming setup. As a beginner, you need four...
Read more >
8 OBS tips to make your stream run smoothly
When NVENC/VCE/QSV is selected this will use your graphics card to do your encoding ... You can set your Video Bitrate in Settings...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found