Is it possible to add a subtitle file (srt) to an existing mkv file?
I can easily embed the srt file in a new mkv file, but it is quite time-consuming.
If it is not possible just to add a srt file to the mkw container can anyone explain why?
I’m using MKVToolNix ver. 9.5.0
Cheers
/Jonas
As suggested I found an explaining answer in a superuser group.
"It cannot just be added at the end. The srt file needs to be splitted into the individual lines and interleaved with the video and audio blocks through the whole file. The clusters and cues need to be adjusted for all tracks, headers need to be added and updated. It is a complicated process."
https://www.matroska.org/technical/diagram/index.html
Related
I have a video in fragmented form which is an output of an Azure Media Services Live Event (Smooth Streaming).
I'm trying to concatenate the segments to get a single MP4 file, however I've run into a A/V sync problem - no matter what I do (time-shifting/speeding up/slowing down/using FFmpeg filters), the audio delay is always floating. To get the output MP4 file, I tried concatenating the segments for video and audio streams (both at OS file level and with FFmpeg) and then muxing with FFmpeg.
I've tried everything I found on the web and I'm always ending up with exactly the same result. What's important, when I play the source from the manifest file, it's all good. That made me skim through the manifest once again, and I realized there's CodecPrivateData value which I'm not using anywhere in the process. What is it? Could it somehow help solving my problem?
Mystery solved: the manifest file contains the list of stream discontinuities, which need to be taken into account when concatenating the streams.
What I did so far:
I learned with this answer that I can use negative mapping to remove unwanted streams (extra audio, subtitles) from my video files.
I them proceeded to apply it to a few dozen files in a folder using a simple for /r loop on Windows' cmd. Since I thought this process as some kind of trim, I didn't care about my original files and wanted ffmpeg to replace them, which of course it cannot.
I tried to search a bit further and find ways to work around this issue without simply using a new destination an manually replacing files afterwards, but had no luck.
However a lot of my findings seemed to indicate that ffmpeg has capabilities to use external temporary files for some of it's functions, even though I couldn't really find more onto it.
What I want to do:
So is there any way that I can make ffmpeg remove those extra streams and them replace the original file somehow. I'll also be needing to use this to multiple file, by I don't think this would be a big issue...
I really need this to be done with ffmpeg, as learning the tool to it's full extent is a long-therm goal of mine and I want to keep working on that curve, but as for batch/cmd, I prefer it because I haven't properly learned a programming language yet (even if I often meddle with a few), but I would be happy to use suggestions of any kind for handling ffmpeg!
Thank you!
Not possible with ffmpeg alone
ffmpeg can't do in-place file changes.
The output must be a new file.
However, deleting/removing/replacing to original file with the new file should be trivial in your batch script.
I saw some vague references while searching and also stumbled upon the cache protocol and -hls_flags temp_file
The cache protocol allows some limited seeking during playback of live inputs. -hls_flags temp_file is only usable with the HLS muxer and creates a file named filename.tmp which is then renamed once the active segment completes. Neither are usable for what you want to do.
Say we have many video records that we want merge with -vcodec copy (or equivalent syntax). Without reencoding, without loss of quality. And few records (minor set), with another codecs, parameters and so on. So we can use ffprobe for file, that represent majority of sources. We get lot of information.
But can we get here commandline hints for ffmpeg, that could be used to convert another (not yet "compatible") files to this same format? At least for one selected stream of "master" file, for example.
Question is not about some scpecific output codec and so on.
There is no exsitsing tool to to this. You would need to write one.
Each video stream inside a video file can only include same codec. So I recommend you to at first step, merge files with same codec with -vcodec copy. The check if which codec is mostly available in your merged files (e.g. CodecA). At second step, convert other merged files with other codecs to CodecA. Finally, merge all files (which all have now CodecA) with -vcodec copy.
Please keep in mind that if the video files are in different sizes, you have to reencode them.
I'm developing a system using ffmpeg to store some ip camera videos.
i'm using the segmentation command for store each 5 minutes a video for camera.
I have a wpf view where i can search historycal videos by dates. In this case i use the ffmpeg command concat to generate a video with the desire duration.
All this work excelent, my question is: it's possible concatenate the current file of the segmentation? i need for example, make a serch from the X date to the current time, but the last file is not generated yet by the ffmpeg. when i concatenate the files, the last one is not showing because is not finish the segment.
I hope someone can give me some guidance on what I can do.
Some video formats can always be playable during the build process. That is, you can make a copy of the unfinished segmentation directly and use it to merge.
I suggest you use flv or ts format to do this. mp4 is not supported. Also note that there is a delay from encoding to actually writing to the disk.
I'm not sure if direct copy will cause some data problems at the end of the segmentation file, but ffmpeg will ignore this part of the data during the merge process, so the merged video should be fine.
I am using the SampleGrabber filter to get the frames of an AVI file and alter them before writing them to another (new) AVI file using the File writer filter.
The problem that I am facing is that the new AVI file size is greater then the original file. I removed the SampleGrabber filter thinking that it might be my code causing the problem, but still the new file size is greater then the original file. I tested it with graphedit.
The filters used were File reader->AVI Splitter->AVI Mux->File writer.
I really want to preserve the file size. Is there any other filter or property that I have to set. At the moment I am only adding the Filters in GraphBuilder and rendering the file.
I am using DirectShowLib.Net.
I just did a quick test using
File source (async) -> AVI splitter -> AVI mux -> file writer
in graphedit and the output file always seems to come out the same size as the input for me. The only thing I can think of is that your input file might be compressed. It might be worth inspecting the input file with an app like gspot to determine that. As I understand it DirectShow will sometimes insert appropriate filters in order to make a connection, so if you're trying to connect your file source to an AVI splitter it may insert a decompressor if needed. Hope that's of some use