Extracting text subtitles using ffmpeg libraries - ffmpeg

I'm writing a C program that uses the ffmpeg's libav* libs, and using Dranger's tutorial, I can decode both audio and video correctly. Currently, I'm trying to extract subtitles. I actually don't want to decode them on time and display them on the video, but actually extract the subtitle text out of the container.
For example, on the cli,
ffmpeg -i video.mkv -map 0:4 -scodec copy out.ass
would give me the ass file back. (For some reason, srts only return the text.)
I've tried messing with AVSubtitle, avcodec_decode_subtitle2, etc., but they're returning the subtitles line by line. I would like the timecodes in srts, header information in ass, etc. All I want is the entire subtitle text file that was muxed into the container.

In the case of .mkv files, you could use mkvextract. You may need to use mkvinfo first to identify which track you want to extract.
Since you want to do this from your own C program, you would probably want to use the Matroska libraries instead of the command line tools.

Related

End Part of .WAV file is not converted to .MP3 file

As you can see the in the above image, the end part of the .wav file is not represented in the mp3 file. Here, I am making use of avcodec_decode_audio4() api to decode each packet, and using lame_encode_buffer() api to encode it in mp3 format. Here, I am seeing this issue for MONO streams( 1.wav -> 1.mp3 ). I just wanted to know why is this occuring, even when I am providing all the .wav file content. I am suspecting there is some caching that is happening, due to which I am unable to get whole data into the mp3 file. Any help here would be appreciated.
Add a section of silence at the end of the WAV file then reconvert to mp3

Pass option or argument in ffmpeg

I'm doing some modification into af_silencedetect.c file, one of the ffmpeg many filters and I want to pass a unique option in when I run ffmpeg. I need ffmpeg to save silence that it found and put them in different log file with unique ID that I'm passing, because I'm running multiple ffmpegs at the same time. Here is what I try to do:
ffmpeg -i audio.mp3 -vn -af silencedetect=n=-50dB:d=1:id=01 -f mp3 out.mp3
How to do that? How to create new parameter and pass it in and grep it inside ffmpeg?
I have been working a bit on ffmpeg and I know that it is a bit painful to start development of new features. They are very few infos for developers and the answers on the ffmpeg mailing list are not always helpful.
Note: The following instructions suppose you are able to compile ffmpeg. Run the "ffmpeg_g" program with gdb, it is the debug version of ffmpeg.
So for adding options you have to look to this line.
For each option you want add a line in this array and set the parameters in this order :
{option name, description, offset in the context object, type, default value, min value, max value, flags}
Note: see other files for possible options types.
Then for each option add a member in the context structure.
And finally use your options with the context object that you obtain with this instruction.
That's all, I hope it will help you.

How to specify the output format of a powerpoint video export in vbscript

To create a video from a powerpoint presentation I can use for example
ppFile.CreateVideo fileName, false, 1, 793, 2, 100
How can I define the format of the output file.
Obviously I can call the fileName foo.mp4 or foo.wav but I have my doubts that this really changes the way the video is encoded as apposed to just changing the suffix of the file.
What is the default encoding method and how can one select a different encoding method?
Thanks
The output is WMV, if you want a different format you must convert using a transcoding utility, for example the ffmpeg command line tool.

Merge two or more video files of any format using FFmpeg in iPhone

Is there any direct command in FFmpeg to merge videos in iPhone. I need to do this programmatically by setting the command line argument to the FFmpeg containing the input movie files to merge and the output file name.
I just wanted to merge two .mov movie files using FFmpeg. I was trying to do this in iPhone where I was creating a command line argument containing two video fies to merge as an input parameter and the destination video file as output parameter and then calling main method of FFmpeg. But for merging videos using FFmpeg first we need to convert it to mpg format and then pass the movie files in mpg format in the command line format. This is the only way found to merge the video using FFmpeg as far as I know. Is there anybody out there done this in a different way?
To paraphrase the FFmpeg FAQ entry "How can I join video files?"
Transcode to a format that supports direct concatenation (MPEG-1, MPEG-2 PS, DV) and then back to the desired format.
Use the concat protocol to get the same effect without the intermediate files.
Use named pipes to avoid the intermediate files.
Do any of the above with the lossless yuv4mpegpipe or raw formats.

What's the VOBsub subtitle format?

Where can I find documentation/sample code of the VOBsub subtitles format? The one that's an .idx and a .sub file.
I need to create a program that generates those subtitles. I've been looking on Google but only found how to rip them from DVD.
Thanks
VOBsub extracts the DVD subtitles raw PES from a DVD and dumps this to a .sub file. It also creates a .idx Index file with the times and byteoffsets for each and every single subtitle. The format has support for multiple tracks and can also be embedded in MP4 (by Nero) and Matroska files.
Technical specs vobsub
Technical specs from Matroska.org
Example files: Specs_and_idx-sub_files.rar
Have a look at these open source implementations:
BDSup2Sub (Java)
Subtitle Edit (C#)
guliverkli by gabest (C++) check out VSFilter and VSRip; original implementation
Son2VobSub.rar (C++)
And then there are the media players like VLC. You can also check out these threads on doom9:
http://forum.doom9.org/archive/index.php/t-87171.html
http://forum.doom9.org/archive/index.php/t-99815.html
I think your best approach would be to have a look at the sourcecode of some of the open-source media players. Some of them will have the code to interpret an .idx or .sub subtitle file.
This might be a useful starting point:
http://sourceforge.net/projects/guliverkli/

Resources