News:

--

Main Menu

Handling broken TS files

Started by Blues, March 02, 2018, 04:11:45 PM

Previous topic - Next topic

Blues

I'm using Tvheadend to record FTA channels. The TS files recorded have errors in them and Avidemux cannot handle them. (As a side note I have to mention Handbrake has no problems.) Is there a known tool to fix TS files so Avidemux won't crash when I load them?

eumagga0x2a

No matter how broken a file, crashing is not nice. If the latest nightly crashes as well, please provide samples. Avidemux can cope AFAIR with gaps up to 19 frames. Not sure, which strategies might be promising when extended parts of the stream are corrupted (seeking to the next keyframe maybe?).

Blues

#2
Thanks for looking into this. Well, the sample would be 1.8 GB ... Actually Avidemux can open it and index it, but any action like remuxing into mkv will result in crash. I need to cut the ads out, and currently I'm unable to do it.
I tried several workarounds, so far no success. I can use ffmpeg to fix the video, but then audio goes out of sync. Not sure if ffmpeg has an option to keep sync, looking into this. So far only Handbrake can handle it without any issues, but I haven't found out how to force Handbrake insert keyframes frequently enough to enable me cutting commercials.

I did git pull and built Avidemux today.
Assert failed :0
at line 199, file /home/saul/work/avidemux2/avidemux_plugins/ADM_demuxers/MpegTS/ADM_tsAudio.cpp
ADM_backTrack
ADM_tsAccess::getPacket(unsigned char*, unsigned int*, unsigned int, unsigned long*)



ADM_edAudioTrackFromVideo::getPacket(unsigned char*, unsigned int*, unsigned int, unsigned int*, unsigned long*)
ADM_audioStreamCopy::getPacket(unsigned char*, unsigned int*, unsigned int, unsigned int*, unsigned long*)
muxerFFmpeg::saveLoop(char const*)
admSaver::save()
A_Save(char const*)
A_SaveWrapper(char const*)
ADM_QT4_fileSel::GUI_FileSelWriteExtension(char const*, char const*, void (*)(char const*))
HandleAction_Save(Action)
HandleAction(Action)

QMetaObject::activate(QObject*, int, int, void**)
MainWindow::actionSignal(Action)
MainWindow::searchToolBar(QAction*)

QMetaObject::activate(QObject*, int, int, void**)
QToolBar::actionTriggered(QAction*)

QMetaObject::activate(QObject*, int, int, void**)
QToolButton::triggered(QAction*)
QMetaObject::activate(QObject*, int, int, void**)
QAction::triggered(bool)
QAction::activate(QAction::ActionEvent)

QAbstractButton::mouseReleaseEvent(QMouseEvent*)
QToolButton::mouseReleaseEvent(QMouseEvent*)

Blues

I fixed the audio, now Avidemux stalls on video. It does not crash, it just stops and can be terminated normally. Output from terminals can be seen here:
https://paste.pound-python.org/show/mdhmR1Bq5fD6HQjVMHn5/

RoadRanger

#4
I often use FFMPEG to convert MTS/TS files into something more friendly. Try putting this batch file in a folder with the TS files you need to "fix" and running it.

It assumes you have FFMPEG.exe at the root of your drive.

Blues

Thanks, but as I mentioned before with ffmpeg the audio goes out of sync. Also, the bat file is no use, it smells like Windows, my last Windows had BSoD in 2004, or was it 2003.

eumagga0x2a

Quote from: Blues on March 02, 2018, 06:57:01 PM
Well, the sample would be 1.8 GB ... Actually Avidemux can open it and index it, but any action like remuxing into mkv will result in crash. [...]

Assert failed :0
at line 199, file /home/saul/work/avidemux2/avidemux_plugins/ADM_demuxers/MpegTS/ADM_tsAudio.cpp
ADM_backTrack
ADM_tsAccess::getPacket(unsigned char*, unsigned int*, unsigned int, unsigned long*)


This sample might be helpful to find out, why the packet turns out to be too big for the buffer so we hit the assert (should it be split in smaller chunks?)

The log from MKV the internal ffmpeg fails to decode is not that interesting.

RoadRanger

Quote from: Blues on March 02, 2018, 09:56:33 PM
Thanks, but as I mentioned before with ffmpeg the audio goes out of sync. Also, the bat file is no use, it smells like Windows, my last Windows had BSoD in 2004, or was it 2003.
If you don't run Windows you can still look in my batch file to see the options used - those may fix your audio sync problems. I was having those problems without the "-fflags +genpts".

Blues

I had no video tool to cut it, so I used head and tail to bisect it. Here is 28 MB file which opens in Avidemux, but causes crash when saving.

eumagga0x2a

Perfect, this is exactly the right way to cut MpegTS, thank you very much for the sample.

[TS Packet] PackLen=3848, avalailble=1834
[Ts Demuxer]*********Pes too long*******
[TS Packet]extra crap at the end 1830


Then it asserts as you stated above at ~48 seconds at avidemux2/avidemux_plugins/ADM_demuxers/MpegTS/ADM_tsAudio.cpp:199.

RoadRanger

Quote from: Blues on March 03, 2018, 11:23:44 AM
I had no video tool to cut it, so I used head and tail to bisect it. Here is 28 MB file which opens in Avidemux, but causes crash when saving.
FWIW running this through my batch file and then using Avidemux on it doesn't crash like using the original file :) .

eumagga0x2a


Blues

Thanks. I'm recording these shows and there will be more broken files, that's the nature of over the air transmission over long distance. Hopefully I can cut and recode them without doing voodoo next time.

Jan Gruuthuse

If you're recording DVB-T, there are dvb-t directional yagi antenna to improve reception (radio amateur could provide you with more info). Improving reception would cancel most errors.

Technical info: How to select an antenna for digital TV (DVB-T)

Blues

Thanks, I used to be a radio amateur myself. It so happens I have the best antenna available (HD7698P Platinum HD Series Antenna). The next step would be stacking custom made antennas together. I'm not going to build anything like that on my roof. 80+ km distance is a challenge even with greatest antenna.