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

Anshul Maheshwari anshul.ffmpeg at gmail.com
Thu Dec 4 13:45:40 CET 2014


On Thu, Dec 4, 2014 at 5:43 PM, Nicolas George <george at nsup.org> wrote:

> 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
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> Yes your logic is working fine when you know where is video stream and
where is audio stream.
while with stream_idx, even if I you dont know where is video and audio it
works.
but seeing so may of your use case, I feel you are right,

I think there should be some more way of specifying 0+1, we should also
able to specify 0v+0a
means 1st video and 1st audio in stream.
other wise there are lots of chances of wrong mapping. In my particular use
case I take input from rtp.
and the guys does not have any standard for 1st will be video or audio.

As you said before as per stephan's comment you are making stricter
parsing, please consider something like 0v + 0a.

Thanks
-Anshul


More information about the ffmpeg-devel mailing list