FFmpeg Outputted Videos Not Seekable in Chrome & Edge: Solution
Have you ever encountered an issue with FFmpeg outputted videos not being seekable in Chrome or Edge? This article will help you understand the context and provide a detailed solution.
Understanding Subtitles and Seekability
Before diving into the solution, let's first understand the concept of subtitles and seekability.
- Subtitles: They are textual versions of a film or television program's dialogue that appear on screen. Subtitles can be vital for accessibility purposes.
- Seekability: It is the ability to navigate within a video, such as jumping straight to a particular timestamp or scene.
Now, if you find that seekability does not work in your FFmpeg-generated videos when viewed in Chrome or Edge, it may be related to subtitle processing.
The Problem
When FFmpeg processes video and subtitle streams, issues may occur that prevent seekability in some browsers, like Chrome and Edge.
Upon seeking, such videos often either:
- Stay stubbornly on the initial timestamp
- Load slowly or fail to load altogether
The Solution
A viable workaround has been found to maintain seekability in FFmpeg-generated videos while supporting subtitles in Chrome and Edge. Bento4, a media toolkit, can help process the files adequately.
Here are the detailed steps for ensuring seekability in your FFmpeg-generated videos:
- Encode the video using FFmpeg
- mux/demux the video by using Bento4 tools
- Optimize the resulting fragmented MP4 for web streaming
Step 1: Encode the video using FFmpeg
Prepare your video for processing by transcoding it using your desired FFmpeg command.
Step 2: Mux/Demux the video using Bento4 tools
Using Bento4 tools like MP4Box, you can mux/demux the video for proper subtitle processing.
MP4Box -add input.mp4:subtitle.srt -new output.mp4Step 3: Optimize the output for web streaming
Now, to make sure your video is ready for web streaming, optimize the video file by using tools like GPAC and FFmpeg.
MP4Box -dash 1000 -rap -frag 1000 -bsseg 5000 -profile baseline output.mp4
FFmpeg -i optimized_output.mp4 -c:v libx264 -crf 23 -profile:v baseline -movflags +faststart output_final.mp4
In this article, you gained insights into the root cause of FFmpeg-generated videos' lack of seekability in Chrome and Edge when supporting subtitles. By following the three-step process outlined using FFmpeg, Bento4 tools, and GPAC, you're now equipped to produce seekable videos compatible with these browsers.
References
- Bento4 (https://github.com/axiomatic/mp4box)
- GPAC (https