Using subtitles in TS file and convert them to avi video

damjan
Posts: 2
Joined: 07 Jan 2011, 14:18

Using subtitles in TS file and convert them to avi video

Postby damjan » 07 Jan 2011, 14:37

Hello!

I have TS file with these streams:
PID 0x32A has PES-ID 0xE0 (MPEG Video) (4888 #27)
PID 0x322 has PES-ID 0xC0 (MPEG Audio) (8460 #46)
PID 0x4B4 has PES-ID 0xBD (private stream 1) (18612 #100)
PID 0x1C86 has PES-ID 0xBD (private stream 1) (SubID 0x20) (84600 #451)

I have no problems with video conversion like TS to AVI.
But, I want also add subtitles to video. Is this possible with Quick Media Converter?

Thanks,

Damjan
User avatar
Cocoon-Dev
Site Admin
Posts: 1152
Joined: 24 Sep 2007, 00:54

Re: Using subtitles in TS file and convert them to avi video

Postby Cocoon-Dev » 07 Jan 2011, 20:58

Hello,
welcome on the forum.

If only the first subtitle is needed : yes else no because FFmpeg take only the first map per default for the audio-video-subtitle.
Now you can add in expert mode the differents subtitle language with the "map" command but it is for the expert and you need to known the FFmepg commands.

Have a nice day.
thx for donating
http://www.cocoonsoftware.com/paypaldonate-us.htm
Team Cocoon
damjan
Posts: 2
Joined: 07 Jan 2011, 14:18

Re: Using subtitles in TS file and convert them to avi video

Postby damjan » 08 Jan 2011, 13:01

Thank you for answer.

I have another request or question. Where can I find some examples, to integrate subtitles into video stream with FFmpeg and where should I put options in QMC.

TS file information is:
======================================================================
General
ID/String : 66
CompleteName : F:\TechniSat\Recorded\4.000.Cudezna dezela.ts
Format : MPEG-TS
FileSize/String : 53.2 MiB
Duration/String : 2mn 16s
OverallBitRate/String : 3243 Kbps

Video
ID/String : 810 (0x32A)
MenuID/String : 2405 (0x965)
Format : MPEG Video
Format_Version : Version 2
Format_Profile : Main@Main
Format_Settings_BVOP/String : Yes
Format_Settings_Matrix/String : Default
CodecID : 2
Duration/String : 2mn 16s
BitRate_Mode/String : VBR
BitRate/String : 2501 Kbps
BitRate_Nominal/String : 15.0 Mbps
Width/String : 640 pixel3
Height/String : 576 pixel3
DisplayAspectRatio/String : 16:9
FrameRate/String : 25.000 fps3
ColorSpace : YUV
ChromaSubsampling : 4:2:0
BitDepth/String : 8 bit3
ScanType/String : Interlaced
ScanOrder/String : TFF
Bits-(Pixel*Frame) : 0.271
StreamSize/String : 40.6 MiB (76%)

Audio #1
ID/String : 802 (0x322)
MenuID/String : 2405 (0x965)
Format : MPEG Audio
Format_Version : Version 1
Format_Profile : Layer 2
Format_Settings_Mode : Joint stereo
CodecID : 4
Duration/String : 2mn 16s
BitRate_Mode/String : CBR
BitRate/String : 192 Kbps
Channel(s)/String : 2 channel2
SamplingRate/String : 48.0 KHz
Video_Delay/String : -917ms
StreamSize/String : 3.13 MiB (6%)
Language/String : sl

Audio #2
ID/String : 1204 (0x4B4)
MenuID/String : 2405 (0x965)
Format : AC-3
Format/Info : Audio Coding 3
Format_Settings_ModeExtension : CM (complete main)
CodecID : 6
Duration/String : 2mn 16s
BitRate_Mode/String : CBR
BitRate/String : 384 Kbps
Channel(s)/String : 2 channel2
ChannelPositions : Front: L R
SamplingRate/String : 48.0 KHz
BitDepth/String : 16 bit3
Video_Delay/String : -928ms
StreamSize/String : 6.26 MiB (12%)

Text
ID/String : 7302 (0x1C86)
MenuID/String : 2405 (0x965)
Format : DVB Subtitle
CodecID : 6
Language/String : sl

Menu
ID/String : 5222 (0x1466)
MenuID/String : 2405 (0x965)
Duration/String : 2mn 16s
List/String : 802 (0x322) (MPEG Audio, sl) / 810 (0x32A) (MPEG Video) / 1204 (0x4B4) (AC-3) / 7302 (0x1C86) (DVB Subtitle, sl)
Language/String : sl / / / sl[/code]
======================================================================

Thanks again,

Damjan
User avatar
Cocoon-Dev
Site Admin
Posts: 1152
Joined: 24 Sep 2007, 00:54

Re: Using subtitles in TS file and convert them to avi video

Postby Cocoon-Dev » 09 Jan 2011, 10:33

Hello,

the best is to go in first to the following site for the basic explanations: http://www.ffmpeg.org
After make a search in Google or here in the posts with the followings keys words : ffmpeg :map

Now in QMC in expert mode, you have only needed to use the command line without de "$ ffmpeg -i mr.vob" at the begin and at the end "mr.avi" for the first example.
Input the command line in the field command line and check the box use command line only.
Command line.jpg
command line expert mode
Command line.jpg (22.12 KiB) Viewed 4685 times


Or
MAPPING CHANNELS

Coming back to the .vob file ripped from a DVD with tccat, it's commonplace for such multimedia files to have multiple audio streams embedded in them. Indeed, the DVD standard provides for up to 8 audio streams. Unless instructed otherwise, ffmpeg will operate on the first available sound track. It so happens that I have such a .vob file on-disk, so let's see what ffmpeg thinks of it:

$ ffmpeg -i mr.vob
FFmpeg version SVN-r9607, Copyright (c) 2000-2007 Fabrice Bellard, et al.
{snipped}
Seems that stream 0 comes from film source: 25.00 (25025/1001) -> 25.00 (25/1)
Input #0, mpeg, from 'mr.vob':
Duration: 00:03:16.2, start: 620.890956, bitrate: 7704 kb/s
Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p, 720x576, 6799 kb/s, 25.00 fps(r)
Stream #0.1[0x89]: Audio: dts, 48000 Hz, stereo, 768 kb/s
Stream #0.2[0x80]: Audio: ac3, 48000 Hz, 5:1, 384 kb/s
Stream #0.3[0x83]: Audio: ac3, 48000 Hz, stereo, 96 kb/s
Stream #0.4[0x82]: Audio: ac3, 48000 Hz, stereo, 96 kb/s
Stream #0.5[0x84]: Audio: ac3, 48000 Hz, stereo, 192 kb/s
Stream #0.6[0x2d]: Subtitle: dvdsub
Stream #0.7[0x2c]: Subtitle: dvdsub
Stream #0.8[0x2b]: Subtitle: dvdsub
Stream #0.9[0x2a]: Subtitle: dvdsub
Stream #0.10[0x29]: Subtitle: dvdsub
Stream #0.11[0x28]: Subtitle: dvdsub
Stream #0.12[0x27]: Subtitle: dvdsub
Stream #0.13[0x26]: Subtitle: dvdsub
Stream #0.14[0x25]: Subtitle: dvdsub
Stream #0.15[0x24]: Subtitle: dvdsub
Stream #0.16[0x23]: Subtitle: dvdsub
Stream #0.17[0x22]: Subtitle: dvdsub
Stream #0.18[0x21]: Subtitle: dvdsub
Stream #0.19[0x20]: Subtitle: dvdsub

The first stream, #0.0, is the video stream. Stream #0.1 is the DTS-encoded sound track and #0.2 is its AC3-encoded Dolby 5:1 equivalent. Stereo audio streams #0.3 through #0.5 are soundtracks with commentaries. Say I want to create a mono MP3 from this with the commentary from the third audio stream, #0.3. If I don't tell ffmpeg which one to use, it'll go ahead and transcode the first one it finds, the DTS stream in this case. I don't want that. This is where the "-map" option comes in handy:

$ ffmpeg -i mr.vob -map 0:3 -vn -acodec mp3 -ar 22050 -ab 96k -ac 1 mr.mp3

"-map input:stream" tells ffmpeg to process the given stream. As we'll see later on, ffmpeg can process input from several files. "input" is the zero-based index of the input file we want to use − 0 for the first, 1 for the second etc. "stream" is the number of the stream within this file that we want to use, also zero-based. "-map 0:3" therefore means that we want to use the fourth stream in the first (and only, in this case) input file.

"-map" can also be used to create a new movie from this .vob file using, for example stream #0.0 for the video and #0.5 for the audio. If any streams in a video file are mapped with "-map" then they must all be specified explicitly. In this case the first "-map" option specifies the stream to use for the video and the second one specifies which stream to use for the audio:

$ ffmpeg -i mr.vob -map 0:0 -map 0:5 -vcodec mpeg4 -b 1000k \
-s 640x360 -acodec mp3 -ar 22050 -ab 64k -ac 1 -f avi mr.avi

MULTIPLE SOURCES

One of the pieces of equipment adorning my video rig here at home is a DVD recorder. Almost invariably, I record direct onto a DVD+RW so that I can take the program I'm recording apart, rework the audio track (boost the volume level among other things), put it back together again, archive the modified program onto a DVD±R and put the DVD+RW back into circulation for the next recording.

Once the audio track has been extracted and reworked, I can reassemble the movie in either of two manners:

1. Also extract the mpeg2video data from the .vob file and then multiplex it and the reworked audio (duly converted to MP2 or AC3) with mplex, or
2. Ask ffmpeg to pull the video in from the original .vob file and the audio from the reworked .wav audio file and transcode it on-the-fly.

Solution 1 is already the object of another howto page (which needs finishing now that I think of it). This is how we use solution 2:

$ ffmpeg -i oldmovie.vob -i altered_audio.wav -map 0:0 -map 1:0 -target ntsc-dvd \
-b required_video_bit_rate -aspect 16:9 newmovie.mpg

Or, if you'd rather use MP2 audio and a lower audio bit rate:

$ ffmpeg -i oldmovie.vob -i altered_audio.wav -map 0:0 -map 1:0 -target ntsc-dvd \
-b required_video_bit_rate -acodec mp2 -ab audio_bit_rate -aspect 16:9 newmovie.mpg

Obviously replace "16:9" with "4:3" if you're reworking a 4:3 aspect ratio movie. Also, this assumes that the first stream in the .vob file is the video stream, so you'll need to adjust the "-map 0:0" accordingly if, for example the video stream is the second stream as is the case with my DVD recorder, in which case you'll need "-map 0:1" instead. Either way round, this is the stream that'll be used for the video in the output file. The audio stream is mapped to "-map 1:0". The "1" means "second file" (remember, the list is zero-based) and the ":0" means "first stream".

DELAYING THE AUDIO OR THE VIDEO

Depending on how your original files were generated, it could happen that the sound and the picture become out of sync when you start processing them with ffmpeg. Thankfully, there's a mechanism that will allow you to stagger the audio and video with respect to each other in the output, thus bringing them back into alignment − the "-itsoffset" option, which is used this way:

$ ffmpeg -i input_1 -itsoffset 00:00:03.5 -i input_2 ...........

In this example, input_2 will be delayed by 3.5 seconds. In other words, The content of input_1 will start at the beginning of the movie generated by ffmpeg, and the content in input_2 will start 3.5 seconds into the movie.

In real life you're unlikely to come across such an extreme case of A/V skew. I do, however, come across cases regularly that need correcting by a fraction of a second. Using MPlayer to fast-forward into the movie you're generating and then the + and - keys to add more or less delay in 100ms increments gives you a good idea of how much delay to use and whether it's the sound or the picture that needs delaying.

Remember to put the source that needs delaying after the "-itsoffset" option. Thus, if the audio comes in too soon and needs delaying:

$ ffmpeg -i video_source -itsoffet delay -i audio_source -map 0:x -map 1:y ......

Conversely, if the audio comes in too late and the video therefore needs delaying:

$ ffmpeg -i audio_source -itsoffet delay -i video_source -map 1:x -map 0:y ......

Note how the "-map" options specify video from the second source and audio from the first in this second example.

Note also that video_source and audio_source can be the same file. Nothing's to stop you from fixing (or breaking) the A/V sync within the same original movie.


Have a nice day.
thx for donating
http://www.cocoonsoftware.com/paypaldonate-us.htm
Team Cocoon

Return to “Subtitles”

Who is online

Users browsing this forum: No registered users and 2 guests