Kodi Community Forum

Full Version: mpeg2 ts files not playing properly in kodi [Solution]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I hope this is in the right place and helps out someone in community.

I wanted to share this solution and little script that I have made to re-mux any mpeg2 files with a ts extension to mp4 as I have found that some mpeg2.ts files will not play in Kodi properly. I can confirm that the output files work for me on Kodi 16.1

I have used ffmpeg and written a short bash script using a loop to re-mux all files contained in a folder from mpeg2.ts to mp4.

If you don't have ffmpeg you can install it as a command line tool in OS X using homebrew or on Linux using your package manager of choice.

For an individual file you can just use a single command

Code:
ffmpeg -i /PATH/TO/CONTAINING/FOLDER/S03E01.ts -acodec copy -vcodec copy /PATH/TO/DESTINATION/FOLDER/S03E01.mp4

If you have multiple files that need converting then you can put them in a folder and run this script, just change the path to containing folder in the script.

Code:
#!/bin/bash
# convert mpeg2-ts files to mp4
cd /mnt/2tb_hd/con/
for a in *.ts ; do
    f="${a[@]/%ts/mp4}"
    ffmpeg -i "$a" -acodec copy -vcodec copy "$f"
    sleep 20
done

This gets the job done quite quickly on my Raspberry Pi 2 running arch ARM.


Hope this helps someone out Smile

-----

Edit. I have altered the original script as it would not work if filenames contained white spaces. Now working fine with all badly names files Tongue
Can you share one of the problematic files?
According to your command you copy the audio and the video codec, I see no reason why the ts file should not play with kodi.
Yes I will upload one later, any particular host you would like me to use?

The original file was pixelated and sound was really ahead of the video. This occured on both kodi-rbp 16.1-4 and also on 2 droid boxes both running kodi 16.1

Some info about the files

Code:
File Size Processed: 2.87 GB, Play Time: 00h:31m:32s
1920 x 1080, 29.97 fps (24.38 fps Telecine), 64.00 Mbps (12.25 Mbps Average).
Average Video Quality: 61.31 KB/Frame, 0.24 Bits/Pixel.
AC3 Audio: 3/2 Channels (L, C, R, SL, SR) + LFE, 48.0 kHz, 384 kbps.
Dialog Normalization: -24.0 dB, Center Mix Level: -3.0 dB, Surround Mix Level: -3.0 dB
0 of 46143 video frames found with errors.
0 of 59138 audio frames found with errors.
0 corrupted video bytes in file.
0.000000 seconds of video timestamp gaps.
0.000000 seconds of audio timestamp gaps.

Size...........: 2.79 GiB
Container......: MPEG-TS
Runtime........: 30mn 18s

Video.Track
Codec..........: MPEG VIDEO
Bitrate........: 12.1 Mbps
Aspect.Ratio...: 16:9
Resolution.....: 1920x1080
Frame.Rate.....: 29.970 fps

Audio.Track
Codec..........: AC-3
Bitrate........: 384 Kbps
Channels.......: 2 channels
Compression....: Lossy
Language.......: English

I know I haven't transcoded anything but I think it was an issue with the mepg-ts container.
I have just copied the file from my external drive and tested in Kodi 16.1 for OS X and it plays fine. It also plays in Quicktime player.

Could it be an issue with the RPi version of Kodi, also on 2 x Amlogic droid boxes I had the exact same issue. The file is stored on a 2TB EXT4 drive connected to the RPi that runs Kodi-rbp on arch ARM and the drive is shared using samba to the droid boxes. After running the script the resulting mp4 files play perfectly so something is definitely causing a problem for the Pi and Droid boxes with the mpeg2-ts container.

Here is one of the original files that caused the issue.

https://transfer.pcloud.com/download.htm...1eUBDEhnBy

Probably a different issue but I had the same problem with mkv versions of this season of SV. Are there some missing dependencies that I need for Kodi-rbp. I have omxplayer-git 494.791d7df-1 xorg-xrefresh 1.0.5-1 and xorg-xset 1.2.3-1 on arch and I run Kodi in standalone. Everything else I do on my Pi I use ssh.

I may try playing one of the ts files and use top to check memory / cpu usage.
Try with libreelec on that affected hardware. We have no idea what arch patches around with kodi, which ffmpeg it replaces and so on ...
I verified it on a v17 running on Ubuntu / intel nuc -> works perfectly.
I have discussed this issue with a developer of kodi addons who said it is a Raspberry Pi issue but I also have had the same issue on 2 x droid boxes that are connected to the pi's external drive over samba. Maybe something is missing from the rbp and droid versions of kodi as opposed to the 64 bit ubuntu / os x / win versions of kodi. I haven't tried on openelec or libreelec but from what I have heard it is still an issue on those distros.

I don't use the Pi for just kodi. I run many packages including samba, rtorrent, irssi, etc. Arch is the best option for me as it is a bare bones linux system and I have built up the system to do many tasks which it does well. I don't require a window manager, desktop etc as everything but kodi is configured over ssh. Kodi is launched in standalone on boot as I have enabled the service with systemctl.

According to the arch wiki mpeg 1/2/4 are supported on the full version of Kodi however kodi-rbp is the package of kodi that will run on the pi and the only info on that package on the wiki is....

Taken from the arch wiki
Quote:Kodi runs smoothly on both the Raspberry Pi (RPi) and the RPi 2. Some helpful tips to consider:

Install the kodi-rbp package instead of kodi from the Arch Linux ARM repository.
This package ships with a systemd service to run in standalone mode.
The memory reserved for GPU is 64 MB by default. This is insufficient for GPU accelerated HD video playback. Users can increase this value via a simple edit to the gpu_mem tag in /boot/config.txt. A value of at least 128 MB is recommended.
Install omxplayer-git, xorg-xrefresh and xorg-xset to get hardware acceleration working.
Add the udev rule SUBSYSTEM=="tty", KERNEL=="tty0", GROUP="tty", MODE="0666" to /etc/udev/rules.d/raspberrypi.rules to enable typing with a physical keyboard.

Maybe someone with a pi running openelec or libreelec would like to try the file on their system to test it as we know it works in OS X, Ubuntu and Win. Also someone on droid may like to try it just to rule out my droid boxes causing the problem.

I'm happy to just remux to mp4 for now, it doesn't take long on my pi and it works Smile
So, I was having a similar problem... Video wouldn't play on .ts files from an cifs/smb mount.  Turns out, I just needed to enable buffering and bump up the buffer to 40MB.  See here:

https://kodi.wiki/view/HOW-TO%3AModify_the_video_cache

Makes sense... it's a network path, but Kodi detected it as local because of the local mount path.

Pat