TR101 is not a standard FFmpeg error code. This specific message typically originates from the client-side media player, web server, or network proxy rather than the encoding process itself. To resolve the issue, you must verify that the MP4 file is correctly formatted for progressive download and check your local server’s HTTP headers for proper MIME types and range request support.
Understanding the Source of TR101
When developers encounter a "TR101" error during local streaming, it is crucial to first identify where this code is being generated. FFmpeg outputs its own errors using codes likeError opening filters, Invalid data found, or exit status codes such as 1 or 255. It does not use alphanumeric codes like TR101 in its console output.
Therefore, this error is almost certainly coming from one of three places:
- The Web Server: If you are serving the file via Nginx, Apache, or IIS, the server might be returning a custom error page or redirect that the client interprets as TR101.
- The Media Player: HTML5 video players (like Video.js, Plyr, or native
<video>tags) often have their own error codes. TR101 may be a proprietary code from a specific library or framework you are using. - A Proxy or Firewall: Local development proxies (like Vite, Webpack dev server, or corporate firewalls) might intercept the request and return an error code if the content type is incorrect or if CORS policies block the stream.
Verifying MP4 Container Integrity
A common cause for playback failures on localhost is an improperly written MP4 header. FFmpeg can produce MP4 files that play fine in VLC but fail in browsers because the "moov" atom (which contains metadata needed for seeking and playback) is placed at the end of the file by default. Browsers require the moov atom to be at the beginning for efficient streaming. To fix this, you must "fast start" or "web-optimize" your MP4 file. Use the following command to remux your existing file without re-encoding the video or audio streams, which preserves quality and speeds up the process:ffmpeg -i input.mp4 -c copy -movflags +faststart output_web.mp4
The flag -movflags +faststart moves the moov atom to the beginning of the file. After generating output_web.mp4, serve this new file from your localhost server and test playback again. If the error persists, proceed to check the codecs used within the container.
Checking Codec Compatibility
Even with a correct container, modern browsers have strict requirements for supported codecs. While H.264 video and AAC audio are universally supported in MP4 containers, other combinations may fail silently or throw generic errors depending on the browser engine. Verify the contents of your MP4 file using FFprobe:ffprobe -v error -show_entries stream=codec_name,codec_type -of default=noprint_wrappers=1:nokey=1 input_web.mp4
Ensure the output lists:
- Video codec:
h264(avoid HEVC/H.265 unless specifically targeting modern browsers with explicit support flags). - Audio codec:
aac(avoid MP3 or AC3 if possible, as support varies).
ffmpeg -i input.mp4 -c:v libx264 -preset fast -crf 23 -c:a aac -b:a 128k output_compatible.mp4
This ensures maximum compatibility with Chrome, Firefox, Safari, and Edge. For more details on hardware-accelerated encoding options that might affect compatibility, see Streaming fMP4 via ffmpeg using H.264_vaapi encoder: A Hardware Solution.
Configuring Local Server Headers
If the file format is correct, the issue may lie in how your local server serves the file. Many modern web servers do not send the correctContent-Type or Accept-Ranges headers by default, which can break progressive download functionality.
For Nginx, ensure your configuration includes:
location ~* \.mp4$ {
add_header Content-Type video/mp4;
add_header Accept-Ranges bytes;
}
For Apache, you may need to add these lines to your .htaccess file or virtual host configuration:
AddType video/mp4 .mp4
Header set Accept-Ranges bytes
Incorrect MIME types can cause the browser to treat the video as a binary download rather than a playable stream, leading to player errors. Additionally, ensure that Cross-Origin Resource Sharing (CORS) is not blocking requests if your frontend application is served from a different port than your static assets.
Diagnostics and Next Steps
If the above steps do not resolve the TR101 error, consider the following diagnostic actions:- Test with a Different Player: Try playing the file in VLC or QuickTime. If it works there but not in the browser, the issue is definitely browser-specific or related to the web implementation.
- Check Console Logs: Look for JavaScript exceptions in the browser console. A failed fetch request or a DOM exception might be wrapped in a custom error object labeled TR101 by your application logic.
- Disable Extensions: Browser extensions (especially ad blockers or privacy tools) can sometimes interfere with local requests. Test in an incognito window.
Frequently Asked Questions
Why does my MP4 play in VLC but not in the browser?
VLC supports a wide range of codecs and container formats that browsers do not. Browsers strictly require H.264/AAC in an MP4 container with the moov atom at the start. Always use-movflags +faststart when preparing files for web delivery.
Is TR101 a known FFmpeg exit code?
No, FFmpeg does not use alphanumeric error codes like TR101. It uses integer exit codes (0 for success, non-zero for failure) and descriptive text messages. Any alphanumeric code is likely from your application layer, web server, or media player library.How do I check if my server is sending correct headers?
Open your browser's Developer Tools, go to the Network tab, click on the request for your MP4 file, and inspect the Response Headers. Look forContent-Type: video/mp4 and Accept-Ranges: bytes. Missing or incorrect values here will break playback.
Can I use HLS instead of direct MP4 streaming?
Yes, HLS (HTTP Live Streaming) is more robust for adaptive bitrate streaming and handles network interruptions better. You can generate HLS playlists using FFmpeg with-f hls, but for simple localhost testing, a properly optimized MP4 is usually sufficient.