A simple trick to play AVI XviD/DivX videos on Samsung TV without re-encoding

pachura

Standard Member
Hello,

I've recently bought Samsung QLED Q95T (2020 EU model, currently on firmware 1460) and I'm quite happy with it!

One of the first things I tried on my new TV was checking the playback of different video files. I was aware it does not support DTS audio (nor TrueHD), so this was expected; however, I was quite disappointed it does not play my AVI XviD/DivX files.

I'm aware this format is getting quite old now, but it is still somewhat popular, and I still have plenty of such files (kids' cartoons etc.). And what is especially strange, Samsung's built-in media player still supports such prehistoric codecs as MPEG-1 and MotionJPEG, and even proprietary ones as FLV (Flash Video) and Microsoft's WMV...

A commonly suggested solution on the web is to re-encode your XviD videos into MP4s containing AVC (H.264) video inside. While this surely works, it involves re-compressing already compressed video - so it further degrades its quality. Also, takes time - not only to re-encode, but to choose appropriate encoding parameters...

So, I started experimenting, and I found out that simply changing codec ID (also known as FourCC) in the AVI file from XVID (or, less common DIVX or DX50) into FMP4 fixes the problem!

(For videos encoded with the oldest DivX version, the FourCC is DIV3, and has to be changed to MP43).

If you only have a few AVI files to fix, you can use AVI FourCC Code Changer 1.00. For batch processing, you can use the following FFmpeg command line:

Code:
ffmpeg -i source.avi -c copy -vtag FMP4 source_fixed.avi

While applying this fix, you can at the same time correct another common problem with XviD videos known as Packed bitstream or Packed B-frames. In general, it is about increasing video file's compatibility by reorganizing it a bit. Here's the full commandline to apply both fixes:

Code:
ffmpeg -i source.avi -c copy -bsf:v mpeg4_unpack_bframes -vtag FMP4 source_fixed.avi
 

Pr0xiMUS

Novice Member
Thanks for great tip. It is really a shame that Samsung remove Xvid/DivX playback from new TV's, it just doesn't make any sense ...

Anyhow, here is a powershell script you can put in root of USB stick and it will fix all AVI files on whole USB.
 

Quijibo

Novice Member
Thanks, this is great, though I have a NAS with a few GB of files to update now. Will hopefully be able to use the PowerShell.

I've only tested with a few files using this code.
ffmpeg -i source.avi -c copy -bsf:v mpeg4_unpack_bframes -vtag FMP4 source_fixed.avi
(Using the code without fixing the B-Frames fix made the files a bit choppy/jumpy.)

I got this warning message - is it something to worry about in future or is there a way to fix it now?
Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
 

halfbaked

Standard Member
Like me, if you have thousands of movies in avi format, it's not an option to convert all of them.
So I found a workaround. If you have an old laptop, connect your usb drive with movies on it to the laptop. with the latest version of vlc media player on the laptop, play the movie. go to the playback menu, renderer and cast it to your tv over home wifi. I have a chromecast device connected to my tv as well. problem solved.
and to make your life even easier by controlling your laptop from a smartphone, get an app called splashtop on your smartphone and the pc version of it on the laptop. login to both versions of splashtop and you can control your laptop from your phone = play any movie on your laptop and cast it to your tv. up yours samsung!
 

mysiakm

Novice Member
I registered to this forum just to say big THANK YOU to the OP @pachura. I've just purchased Samsung QE50Q65A and when I tried to play my favorite old TV shows, none of them was working. Took a while to realize that it's because Samsung models from 2021 don't play DivX/Xvid (what a ridiculous decision). I was ready to send the TV back, but then I stumbled upon this post and the FourCC trick works wonders.

I processed about 3000 avi files in just a few minutes with FourCC changer app - it uses "search and replace" approach, so I just put all my files in the queue (search in Total commander for "*.avi" and drag&drop the result) and went through them a few times, altering the match criteria each time (DIVX/FMP4; XVID/FMP4; DIV5/FMP4; DIV3/MP43). Now all the files play just fine.

So..thanks again! :)
 

VA1DER

Novice Member
It's not that the new Samsung TVs don't support MPEG4-part 2, they do and quite well. It's that they have limited support for AVI at all and there have been legal issues for commercial entities to support DivX 4CC codes due to trademark problems. They don't want to pay DivX royalties and I don't blame them. Why XviD got caught in that I have no idea.

Whatever you think about transcoding, fair enough, but you should at the very least remux your content. A 4CC change is really just a bandaid. Next time around AVI support will just go away. It really is a terrible file format. Better to use mp4 or mkv. Remuxing is relatively painless and far faster than transcoding.
 

mysiakm

Novice Member
Remuxing doesn't fix anything (it was the first thing I tried). AVI isn't a problem at all, it's codec - as soon as the TV tries to play DivX/Xvid, it fails to do so. However thumbnails and other info loads properly. With changed 4CC, all AVI files play properly.

Btw. it seems that Samsung and Divx renewed their license agreement, but I couldn't get any info from Samsung support if it concerns already released TV models - Samsung Electronics Renews Licensing Agreement with DivX for its Consumer Electronics Devices
 

VA1DER

Novice Member
Remuxing doesn't fix anything (it was the first thing I tried). AVI isn't a problem at all, it's codec - as soon as the TV tries to play DivX/Xvid, it fails to do so. However thumbnails and other info loads properly. With changed 4CC, all AVI files play properly.

My bad, I thought ffmpeg changed the vtag for ASP codecs on a remux to .mp4 automatically, but I see now that it doesn't. I think it might have used to. In any case, I suppose the remux doesn't matter much for you personally, though it will still give better compatibility with other devices. My ROKU devices, for example, have relegated all AVI to the dustbin.

To remux and retag the command is, of course:
Code:
$ ffmpeg -y -i OLD.avi -c copy -vtag FMP4 NEW.mp4

Other vtags that might work:
  • SEDG (Identifies Samsung's own MPEG4 codec)
  • MPG4/MP42/MP43 (Identifies Microsoft's MPEG 4 v1, v2, and v3 codecs respectively)
I would actually suggest sticking with one of the Microsoft ones if they work on your TV, that will have the widest compatibility with other devices without re-encoding.

Btw. it seems that Samsung and Divx renewed their license agreement, but I couldn't get any info from Samsung support if it concerns already released TV models - Samsung Electronics Renews Licensing Agreement with DivX for its Consumer Electronics Devices

Yes, I had heard that. That is a DivX press release, not a Samsung one though. My understanding is that the old deal was a flat rate Samsung paid DivX for unlimited distribution, and word on the street is that the new one is based on per-unit. I suspect Samsung told DivX that they weren't renewing, and since DivX as a company is becoming increasingly irrelevant they begged for a face-saving renewal that would let them announce that a deal was in place without much (if any) money actually having to change hands. After all, if Samsung doesn't put DivX into any of their units they pay nothing.

I myself recently bit the bullet and re-encoded all my old MPEG4 ASP stuff to HEVC. Any computer with a recent-ish Nvidia video card will do hardware encoding and it transcodes on my two -year old Nvidia card at up to 30+ times playback speed.

Code:
$ ffmpeg -y -i "OLDavi" -c:v hevc_nvenc -2pass true -b:v 800k -minrate 0 -maxrate 1600k -bufsize 60000k -preset slow -c:a aac -b:a 96k "NEW.mp4"

BTW it's not a true two-pass. The Nvidia encoder just looks ahead a bunch of frames for better VBR selection. But I get videos basically indistinguishable from the original at 2/3rds the original ASP video's bitrate. You can do the same thing with the built-in Intel video card to accelerate encoding too, just not quite as fast. Just change hevc_nvenc to hevc_qsv.

Just food for thought.
 

michoopro

Novice Member
Thanks for great tip. It is really a shame that Samsung remove Xvid/DivX playback from new TV's, it just doesn't make any sense ...

Anyhow, here is a powershell script you can put in root of USB stick and it will fix all AVI files on whole USB.

Will this script save the original file modification date? I have thousands AVI files from years 2001-2021, I need to repair them but with original modified date - it's important for me.
 

PacoH

Novice Member
Wow. I can’t believe a Samsung TV doesn’t support XviD or DivX. DivX would require paying royalties but so what? You paid enough for the TV to support that. And XviD is free open source so there’s no excuse for not supporting that. Both codecs are an echo from the distant past but, as pointed out, there are certain genres of media files that use them, mostly old files. XviD was the preferred codec for pirated videos so maybe Samsung is trying to distance themselves from that scene.

Like mysiakm, I too stumbled upon this thread after searching for days for a way to change the codec metadata of DivX avi files so I could play DivX encoded AVIs in Oplayer for Android, a fork of VLC Media Player. Files with the FourCC codec tag DX50 (DivX 5) trigger the dreaded message, “Codec Not Authorized - Sorry, Please buy DivX license to play this.”

Screenshot_20220901-230714_OPlayer~2.jpg


Yeah, right. Pay for an obsolete codec, that there is no way to apply to my Samsung tablet anyway, because the VLC devs weren’t clever enough to just bypass this restriction? I don't think so. I guessed, correctly, that all I had to do was to edit the DX50 metadata tag to, say, open source XviD, and it would probably play. XviD was reverse engineered from DivX so all media players could play DivX files for free. But try and find a way to simply edit the codec tag. I used all kinds of search terms and found nothing of value until I found this thread by searching for ‘FourCC’. I am forever grateful to pachura for publishing this thread. I tried his method and it worked but there is no way I would ever create a new, often large, file just to change a metadata tag. But at least I knew which tag to change and then it was up to me to find a simple free way to change it from the command line. I am using a Mac and I always seek out command line solutions so I can then write an automated bash script to do anything. OK, BUT finding such a solution proved to be more elusive than it ought to be. I tried the recommended ‘AVI FourCC-Changer’ and ‘AVIFourCCFix’, which at least edit the FourCC codec tag in place, so no creating a new file, but they are both GUI tools so can’t be automated in a script. At long last I found exactly what I was looking for. cfourcc, a UNIX/LINUX tool for changing the FOURCC of an MPEG4 or DivX file on the command line. Though it is written for UNIX/LINUX, I was able to compile and run it on my Mac. You could probably do the same on Windows with Cygwin. It is very simple to use and only changes one or two 4-byte text words in an avi file. I checked this using a binary diff tool. I’ll post a separate post here with details.
 

PacoH

Novice Member
Simple command line tool to change the FourCC tag of AVI files, in place, without having to create a new file

I looked high and low for just such a tool. I finally found this tool which is probably the only one of its kind. In fact, the author makes just such a claim.

cfourcc
"cfourcc is a UNIX/LINUX tool for changing the FOURCC of an MPEG4 or DivX file on the command line."

Although it is a UNIX/LINUX tool, I had no problem compiling and running this tool on my Mac. It could probably be used on Windows with Cygwin.

It's sole purpose is to detect and change the FourCC codec tag and, optionally, the description codec tag.

Installation is easy. Download the source code from GitHub and open the zip or tar archive, preserving the file structure, in a directory, and:

Just type 'make all'.
Be a root user and type 'make install'
Known Bugs
Can't read *.avi file > 4GiB

Code:
cfourcc -h

usage :
     cfourcc [-i] file.avi
     cfourcc -u DIVX file.avi
     cfourcc -d DIVX file.avi
     cfourcc -h

     -h           Prints this help ;)
     -i           Prints FOURCC information (default)
     -f           Force changing FOURCC on unsupported file (dangerous)
     -u CODE           Sets FOURCC ‘used’ codec
     -d CODE           Sets FOURCC ‘description’ codec

      ** refer to codeclist.txt––https://github.com/mypapit/cfourcc/blob/master/codeclist.txt––documentation for a list of FOURCC

Here is an example of how to use it:

Using Test file: fail-2.avi

Identify currently used FourCC codec and description codec:

Code:
cfourcc -i fail-2.avi

FOURCC of ‘fail-2.avi’ :
Description : divx
Use : DX50

Change used FourCC codec:

Code:
cfourcc -u XVID fail-2.avi

cfourcc -i fail-2.avi

FOURCC of ‘fail-2.avi’ :
Description : divx
Use : XVID

Optionally change description codec:

Code:
cfourcc -d XVID fail-2.avi

cfourcc -i fail-2.avi

FOURCC of ‘fail-2.avi’ :
Description : XVID
Use : XVID

It’s that simple.

I did a binary byte-by-byte comparison, using cmp, between the original and the changed file and it only changed two 4-byte words which contained the codec and description text.

Code:
113 144 d    130 X
114 151 i    126 V
115 166 v    111 I
116 170 x    104 D

189 104 D    130 X
190 130 X    126 V
191  65 5    111 I
192  60 0    104 D

The first column is the byte offset for each character. You can see the changes made with corresponding octal values to the right.

I wrote a bash script to loop through all avi files in a directory, change the FourCC codec and description codec tags of the ones that use a DivX variant, and save the old tags to a text file with the name of the avi file in case I need to change them back later.

Note that I changed both the FourCC and the description tags to XVID. I know that VLC can decode that. You can instead change tags to FMP4 as in the OP if your player can’t decode XviD.
 

The latest video from AVForums

Fidelity in Motion's David Mackenzie talks about his work on disc encoding & the future of Blu-ray
Subscribe to our YouTube channel
Support AVForums with Patreon

Top Bottom