Implement better input index detection in ffmpeg muxer