0

I'm trying to map specific streams to specific output indexes. The command I'm using is more complex but it can be reduced to this simple example

ffmpeg -i input.mkv -y -map 0:0 -c:5 copy -f mp4 out.mp4

I expected this to copy stream 0 from input.mkv into stream 5 of out.mp4. The issue is that it copies it into stream 0 (I guess it's using a counter?). Why is that and how can I force it to assign it a different index number?

Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))

0

It's using a counter! To get it to be stream #5, map 5 streams before it :)

That said, mp4box will allow you to set a custom track ID.

mp4box -set-track-id 1:5 file.mp4

This changes existing track with ID 1 to 5. Use mp4box -info file.mp4 to get existing IDs.

However, this will still show up as stream 0 in ffmpeg. But mediainfo and mp4box will show it as having ID 5.

  • I think the command should fail(i.e. Error<5 higher than the number of total streams>) instead to fallback to various counters. Basically -c:5 param is ignored. – mike Dec 4 '17 at 23:35
  • Actually I have found that -c:$ID provided is not used regardless of the number of streams. Even if you just want to copy the streams in reverse order (i.e. first stream to become the 2nd and the 2nd stream to become the first) ffmpeg ignores this and writes them in the same order(first stream from input to first stream from output and same for the 2nd stream) ` ffmpeg -i "input.mkv" -y -map 0:0 -c:1 copy -map 0:1 -c:0 copy -f mp4 x.mp4` results in ` Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (copy) ` – mike Dec 4 '17 at 23:43
  • Sequence of streams in output is determined by order of map assignments. Stream specifiers for other options like -c only set the value for that output stream # for that option. So, -map 0:1 -map 0:0 will place 2nd input stream first in the output. – Gyan Dec 5 '17 at 5:11
-1

请问现在可以了吗? 采用数字id无法容易区分 360p 720p

我研究了2天 没有研究成功

New contributor
com Services is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.