[FFmpeg-devel] [PATCH 2/2] Adding closed caption decoder

Nicolas George george at nsup.org
Thu Dec 4 13:13:12 CET 2014


Le quartidi 14 frimaire, an CCXXIII, Anshul a écrit :
> Yes while doing that only I realized,  if we use "i" then cc must be in
> first stream.
> When I had multiple stream(with audio), then I was not able to map subcc
> to my video stream.
> using stream_idx , we are saying that if we can use  out0+subcc and
> out1+subcc.
> "i" logic fails when there is audio in 1st stream, there was no way i 
> could get the subtitle
> if my first stream is not the one where closed caption are present.

I tested various combinations, and I find it works with my "i" version and
not with your "stream_idx" version. You can try this:

http://samples.ffmpeg.org/MPEG2/subcc/ClosedCaptions/Starship_Troopers.vob
http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket1482/NCIS.wtv

st=~/tmp/samples/Starship_Troopers_with_subcc.vob
ncis=~/tmp/samples/NCIS_with_subcc_stream.wtv
input="movie=${st}:s=0+1[out0+subcc][out1];movie=${ncis}:s=2+0[out2+subcc][out3]"
function prefix { sed "s/^/$1 : /" }

./ffmpeg_g -loglevel error -f lavfi -i $input -y \
  -map 0:s:0 -f srt >(prefix 1_) \
  -map 0:s:1 -f srt >(prefix _2)

(the captions in ALL CAPS are from ST, the other ones from NCIS)

The mapping logic is this:

- "${st}:s=0+1[out0+subcc][out1]": take stream #0 (video) and #1 (audio)
  from ${st} and make them stream #0 and #1 for the device.

- "${ncis}:s=2+0[out2+subcc][out3]": take stream #2 (video) and #0 (audio)
  from ${ncis} and make them stream #2 and #3 for the device.

- "out0+subcc": output stream #0 (video from $st) has CC, make it the first
  extra stream, i.e. #4 for the device.

- "out2+subcc": output stream #2 (video from $ncis) has CC, make it the next
  extra stream, i.e. #5 for the device.

- "-map 0:s:0": take the first subtitle stream, i.e. #4, i.e. CC for #2,
  i.e. CC for video from $st.

- "-map 0:s:1": take the second subtitle stream, i.e. #5.

In other words:

  lavfi:4 = CC for lavfi:0 = CC for st:0
  lavfi:5 = CC for lavfi:2 = CC for ncis:2

CC streams are created in output stream index order, or, in other words, in
order of their <X> index in "out<X>+subcc".

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141204/b12ba50d/attachment.asc>


More information about the ffmpeg-devel mailing list