Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using a program to hardcode subs into an AVI file. The problem is that is recompresses the video using a codec. I don't see why this is necessary and causes a noticeable loss of quality. Is there a program that will put the subs in without having to recompress the video so that there is no loss in video quality?

share|improve this question

4 Answers 4

up vote 8 down vote accepted

No. The hardsubs modify the video content and so recompressing it is necessary.

share|improve this answer
    
What codec should be used to minimize loss of video quality? –  tony_sid Dec 30 '10 at 7:41
3  
That is a question that entire doctorate theses have been written about. –  Ignacio Vazquez-Abrams Dec 30 '10 at 7:43
    
At the moment, h264 is probably the best (in terms of quality/size ratio) consumer lossy codec available. On the same basis, Lagarith is probably the most useful lossless codec (going beyond Lagarith is usually pointless). –  Matthieu Cartier Dec 30 '10 at 12:12

I think as it is typically used, hard subtitles mean they are embedded into the image data, which by definition requires re-compression. Soft subtitles are added as separate files, e.g. .srt. However, there is a middle way in embedded subtitles. Embedded subtitles are added into the video container as a separate track, which means they will be included in the file but not require re-compression.

For Divx-format the best tool is Windows based application AVIAddXSubs. It can embed Idx/Sub/Srt subtitles.

For MP4 and some other alternatives, Handbrake can embed soft subtitles. Read more at their wiki

share|improve this answer
    
Based on the asker's other questions, I'm fairly sure they already have a MKV with embedded softsubs. –  Ignacio Vazquez-Abrams Dec 30 '10 at 15:03
    
Yes, you may be right but I was assuming the asker wanted an AVI file. AVI can include subs without recompression using AVIAddXSubs and a DivX/Xvid compatible player. If the MKV had a h264 video stream, the same could be accomplished with Handbrake and the MP4 container (example for iPad or Apple TV). –  RipperDoc Dec 31 '10 at 2:28
    
Soft subtitles may be embedded in containers such as MKV, but not all devices may be able to play them (I'm thinking about you, Playstation 3!) –  ttarchala Jul 14 '11 at 10:21

You can use mplayer to play the video with subtitles, and then output everything to a raw yuv file (-vo yuv4mpeg). If you play a movie, this outputted file will be really huge, hundreds of gigabytes, so make sure that it will not cause issues.

After the file has been outputted, it can be compressed by using ffmpeg and then H264 codec.

share|improve this answer

The recompression is necessary because you alter the frame data if you overlay text on the frame itself. So the workflow goes Decompress frame > Modify it to add text > recompress frame.

You can use a lossless codec for the file with the subtitles added. One would be huffyuv, h.264 and Dirac also seem to have lossless profiles. (This will result in identical quality to the original file, with a much larger filesize)

Theoretically, it might be possible to write an application that only re-encode the blocks that are changed by the subtitles, but this likely needs to embedded deep into codec code... That should allow limiting the areas of which quality is affected... I'm not aware of anything like that that exists though... (It would also need to be written specifically for each codec, while altering a decompressed frame allows existing encoder and decoder libraries to be used, as well as recompressing in a different format)

Ideally, you should use lossless compressed files until editing is finished and the export the final file with the preferred compression. This only works for videos that you produce however.

Another option, that might be acceptable, is to add the subtitles as an additional data stream (this will allow them to be turned off though). MPEG-4 Timed text is one such subtitle format, Ogg Writ is another. (But neither of them seem to support an AVI container) (With these, the subtitles is just another track, like the audio and video that is rendered when the file is played)

It might also work tto recompress using a better codec (likely Dirac, H.264 or H.265, depending on input format) to attempt to limit the loss of quality without a huge increase in file size.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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