Avidemux Forum

Avidemux => Main version 2.6 => Topic started by: gavo on November 05, 2013, 09:09:29 PM

Title: Problem with 1080i ts files
Post by: gavo on November 05, 2013, 09:09:29 PM
Hello.  I am using version 2.6.6  64 bits   under windows 7 and I have problems with files recorded with a Mygica tuner for digital television. The files have ts extension and I found that when I load a standard resolution (SD_576i.txt) the program works well, but with high resolution 1080i (HD_1080i.txt) you can see in the image attached what I get. I have also included the information given by kmplayer for boyh files.
Thanks,

Gavo
Title: Re: Problem with 1080i ts files
Post by: gavo on November 11, 2013, 01:40:36 AM
It seems that there is no solution with avidemux. In that case, does anybody know a program for changing the "ts" container into "mp4" container without loss?
Thanks again.

Gavo
Title: Re: Problem with 1080i ts files
Post by: AQUAR on November 11, 2013, 11:01:34 AM
MBAFF is Macroblock-Adaptive Frame/Field Coding.
So the frames are part interlaced and part progressive.
Maybe try de-interlacing using one of the de-interlacing filters.
Deinterlacing the progressive bits along with the interlaced bits should be okay (I think).

Its worth to try. 
Title: Re: Problem with 1080i ts files
Post by: gavo on November 12, 2013, 11:04:00 PM
Thanks Aquar, but I tried de-interlacing with no results.
Title: Re: Problem with 1080i ts files
Post by: AQUAR on November 13, 2013, 12:11:48 AM
Mean would know if avidemux 2.6.x can accept this kind of encoding.

If you provide a short sample it might help others look at this.
And I can check if on my PC it produces the same result.

One trick that often helps is to remux problematic videos - try tsmuxer.
 
Title: Re: Problem with 1080i ts files
Post by: pchristy on November 13, 2013, 03:04:02 PM
Don't know if this will help with the OPs problem, but here in the UK, HiDef TV takes the form of h264 video and (usually) aac audio. Captured "off-air" signals are usually in a .ts container. However, it is possible to re-mpx them straight into an mp4 or mkv container without re-coding. I usually do this from the command line with ffmpeg (I should add that I'm a Linux user):

ffmpeg -i input.ts -f mp4 -c copy output.mp4

-i defines the input file, -f mp4 tells it to put it in an mp4 container, -c copy tells it to copy all the data streams and output.mp4 is the output file. I've found also that mkv is a lot more tolerant than mp4. Sometimes mp4 gives a/v sync errors that don't seem to happen in mkv.

Might be worth a try as an alternative to avidemux to see if it fixes the problem. Because no transcoding takes place, it is very quick, and you don't have to wait for the file to be indexed.



Title: Re: Problem with 1080i ts files
Post by: AQUAR on November 14, 2013, 12:08:12 AM
ffmeg is crossplatform and it works on windows 7.

It includes ffplay for playback video files.
Would be interesting how ffplay renders this interlaced AVCHD file. 
Title: Re: Problem with 1080i ts files
Post by: gavo on November 14, 2013, 07:33:33 PM
Aquar, I tried using tsmuxer with no results. The program says  "Some tracks not recognized" and the audio is not loaded.  The video "input.ts" in this link http://bitshare.com/?f=4wu8kdgc (http://bitshare.com/?f=4wu8kdgc)
I have also done what Pchristy suggested and in the attached "ffmpeg.txt" you can find the errors.
Perhaps now with the video sample you can  find the problem.
Title: Re: Problem with 1080i ts files
Post by: AQUAR on November 15, 2013, 01:28:19 AM
Get the same result using the 2.6 branch.
And it looks like lavcodec has difficulty demuxing the video and audio tracks (migica specific muxing ?).

I think each second field is only presenting something corrupt (or MBAFF macro blocks maybe!) rather than a complete field.
Hence the greying over most of the frame with bars where the video looks fine.
Avidemux 2.5.6 decodes the complete fields but since the AVC is variable frame rate you MIGHT run into other issues.
Avidemux 2.5.6 also doesn't get at the audio track either so you need to extract it with another program.
But my usual demuxers could not see the audio track (mkvtoolnix, tsmuxer). VLC also wouldn't do it.

It needs someone with more than enduser expertise to look at this. 
Title: Re: Problem with 1080i ts files
Post by: pchristy on November 15, 2013, 08:19:05 AM
gavo / Aquar,

Looking at the ffmpeg.txt file, it appears that ffmpeg is complaining mostly about the audio file (track 1), which it has identified as aac_latm, rather than aac. I've no idea what aac_latm is, and it looks as if ffmpeg doesn't either! I have also seen this on some UK terrestrial HD broadcasts, but always found that Avidemux handled it just fine!

The h264 errors *might* just be lead-in errors because the recording hasn't started on a recognisable frame. Can ffmpeg handle the file if the audio is omitted? If so, you may need a two-pronged approach to sort this, treating the video and audio separately.

Just my 2p worth!

;)

Title: Re: Problem with 1080i ts files
Post by: AQUAR on November 15, 2013, 10:50:01 AM
gavo could use avidemux 2.5.6 for putting the video into a program container.

Project X complains about there being lots of "PTS without a frame".
I guess it doesn't understand this MBAFF coding either.
It also complains about a missing sync word - maybe related to LATM and why avidemux has no audio.

When I do extract the audio track it plays real fast - guess it loses any ties to time stamps.

We need 2p's worth from mean to make sense of this video master piece.

Sorrenson squeeze can properly decode/remux this file.
So as a short term solution - gavo could DL the trial to work on the media files.
Note the astronomical price tag of this program - ie a nice reason to appreciate avidemux. 
Title: Re: Problem with 1080i ts files
Post by: AQUAR on November 15, 2013, 12:57:39 PM
Setup an avisynth script to call directshowsource.
Use the lav splitter for demuxing,
Use divx codec for the aac audio,
or an ffdshow available aac audio codec and downmix to stereo.

Then frame serve Avidemux 2.6 via avsproxy.

Now it plays this file with each field decoded properly and with stereo audio.
Best I can do! 
Title: Re: Problem with 1080i ts files
Post by: gavo on November 19, 2013, 12:51:26 AM
Pchristy, I think you are right about the audio because when I first tried to play these videos with kmplayer there was no sound. The solution was to change the mpeg-ts splitter. The problem is the muxing mode LATM. I am going to ask Mygica if they can give any solution because  I am a newbie for what Aquar suggested . I could change the container into mp4 with avidemux  2.5.6 but the problem is still the audio. I didn't try Sorrenson squeeze because $550 is out of this planet. Now I am going to wait for Mygica answer.
Title: Re: Problem with 1080i ts files
Post by: AQUAR on November 19, 2013, 09:01:57 AM
@ gavo,

I've looked at how others get along with LATM encoded aac audio.
It seems there are very few options when it comes demuxing media files with this type of aac audio.
Some players can do it for playback purposes only, but a straight forward transmuxer for aacc-LATM to aacc-HE just doesn't seem to be around.

Using the LAV splitter and piping the output to a decoder for stereo PCM audio was one way I could do it.
It needs setting the merit of the splitter and using an avs script with avsproxy to frame serve avidemux.
It is not a nice approach.

Have a look at the web site from Donald Graft (http://neuron2.net) as some people are saying that DGAVDEC can do it.
Its donation ware and I've not tried it myself.
Maybe you could use graphstudio to construct a graph and render the audio to a wav file for recoding. 

The other issue you mentioned was the strange display when using avidemux 2.6.6. 
Avidemux relies on open source libraries and maybe the updates have an issue with MBAFF.

It would be good if mean could tell us rookies if avidemux or one of its libraries is the problem.
Or maybe its just a bad media file



Title: Re: Problem with 1080i ts files
Post by: pchristy on November 19, 2013, 01:44:06 PM
gavo,

Its a while since I encountered this problem, but I seem to recall that avidemux 2.6.6 managed to handle the aac_latm file OK. I'm trying to remember what I did with it! I have a feeling that I copied the video, transcoded the audio into something else, and put it all in an MKV (matroska) container. Matroska is a lot less picky than mp4 about what you can put in it!

Luckily my blu-ray player can handle matroska files, so I can watch stuff in a matroska container on my TV.

I don't have the original file that was causing me grief anymore, and it was a while ago that I ran into this. Try the procedure outlined above, and see if that helps. If you manage to get it in a playable mkv container, then it should be possible to do another pass, transcoding the audio again into something mp4 compatible, and putting it into mp4.

Best of luck!

Title: Re: Problem with 1080i ts files
Post by: AQUAR on November 20, 2013, 12:27:08 AM
With the sample provided, avidemux is silent on the audio.
It copies or transcodes the audio into another container alright but then the audio becomes silent on all players.

When using ffdshow this audio is seen as 6 channel rather than 2.
Everything that interprets this audio as stereo fails to make a noise.
Also noticed that the audio track is seen by some splitters as 2 channel 16Khz mp2 (also silent!).

Interesting problem, but it really needs someone that can disect the media sample to determine what is going on here.


 
Title: Re: Problem with 1080i ts files
Post by: pchristy on November 20, 2013, 09:04:17 AM
I've been trying to download the sample, but keep getting an error message when I try (502 Bad Gateway)! However, I have found an interesting thread here:

http://forum.videohelp.com/threads/346182-Processing-UK-Freeview-HD-%28H-264-lev-4-with-AAC-in-LATM-audio%29-for-iPad-PS3

which seems to address the issue. No permanent solution yet, but it looks as if people are at least working on it. And there are a couple of workarounds suggested involving VLC and MP4Box. Well worth a look.....

Title: Re: Problem with 1080i ts files
Post by: pchristy on November 20, 2013, 09:30:45 AM
Follow-up: I've downloaded the sample from the above mentioned thread (a clip of BBC 1 HD), and despite having aac_ltm audio, Avidemux re-muxed it into an mp4 container without problems. I used video copy, audio copy and mp4v2 muxer. The only thing I did which might make a difference is to specifically select the main audio track in the audio drop down menu, and deselect the audio description track.
Title: Re: Problem with 1080i ts files
Post by: AQUAR on November 20, 2013, 11:42:02 AM
@ pchristy,

I've uploaded the sample provided by gavo, so you can see for yourself this weird Mygica dvb recording.
http://www1.datafilehost.com/d/9c8e103c

The whole issue is probably just another case of a poorly captured dvb that is made worse by adding MBAFF and LATM complexities.

Let me know if you find an easy way to transcode the audio from this media sample.

Title: Re: Problem with 1080i ts files
Post by: mean on November 20, 2013, 12:20:10 PM
For reference, LATM/LOAS is normally supported by avidemux
Title: Re: Problem with 1080i ts files
Post by: pchristy on November 20, 2013, 02:38:23 PM
Aquar: Thanks for providing the clip. Yes, Avidemux does get confused by the video. Interestingly, MPlayer plays it just fine! That *ought* to mean that it should be possible to handle it with mencoder! I've had a quick try, but mencoder borks on the audio file. Its a long time since I've used mencoder, so I need to refresh my memory of how to handle odd audio formats with it - but the fact that it plays it is a good start!

Worst case scenario: Use mencoder to sort the video and avidemux to strip out the audio then re-mux them?

I'm going to go away and swat up on mencoder......

Title: Re: Problem with 1080i ts files
Post by: pchristy on November 20, 2013, 04:19:27 PM
Got a little bit further! This will save the video in a manner which can be successfully imported into Avidemux:

ffmpeg -i gavo.ts -f matroska -c copy -map 0:0 test.mkv

(-map 0:0 tells it to save the video only and discard the audio)

However, ffmpeg can't extract the audio in a meaningful way, and when I try and extract it with avidemux, I can't re-import the resulting file to attach to the mkv video! The nearest I got was:

ffmpeg -i gavo.ts -f s16le -acodec pcm_s16le audio.pcm

The resulting audio track played (very slowly!) in Audacity, but I couldn't re-import it into Avidemux.

If I try and save the audio without transcoding:

ffmpeg -i gavo.ts -c copy -map 0:1 test.aac

then again, avidemux objects when I try and import it.

I should add that I'm not used to trying to attach audio files with avidemux, so it could be a syntax error on my part (wrong suffix?) as I can play the test.aac file just fine in mplayer!

So to summarise: I can sort the video, but not the audio! Anyone any ideas?



Title: Re: Problem with 1080i ts files
Post by: AQUAR on November 21, 2013, 01:05:11 AM
@ mean
Could you be so kind as to look at this clip and see if it is just a case of bad time stamps.
I am just curious, as the frame based version isn't bothered with the video component at all.


@ pchristy

That's how far I got as well. 

Except to note that:
Avidemux 2.5.6 has no problem with the video component.
Avidemux 2.6.6 borks at decoding the second field.

Using the LAV splitter will get at the audio so we can extract the audio alright.
Hence using avisynth plus avidemux we can deal with this strange clip.

People were talking about creating a LATM-AACC to LATM-HE (stereo) transcoder but nothing has happened since a year or so.

Since gavo hasn't returned to this thread gavo has maybe given up or still waiting for some response from mygica.
Title: Re: Problem with 1080i ts files
Post by: gavo on November 21, 2013, 05:06:49 AM
I am still here looking around on other forums but waiting for Mygica reply.
Title: Re: Problem with 1080i ts files
Post by: pchristy on November 21, 2013, 08:40:36 AM
OK, I've managed to extract the audio using mplayer, but it has to be transcoded:

mplayer gavo.ts -vc null -vo null -ao pcm:fast:file=test.wav

Not the fastest, but it does produce a file that can be imported into avidemux. So to summarise:

1) Extract video with ffmpeg: <ffmpeg -i gavo.ts -f matroska -c copy -map 0:0 test.mkv>
2) Extract audio with mplayer: <mplayer gavo.ts -vc null -vo null -ao pcm:fast:file=test.wav>
3) Multiplex the two back together using Avidemux.

Its a bit long winded, but it works here! And I can't easily check the sync on the clip provided, but it seems OK as far as I can tell. Of course the fact that the audio works with mplayer implies that it ought to be possible to do it in one hit with mencoder. I'll give it a try later.....

Title: Re: Problem with 1080i ts files
Post by: AQUAR on November 21, 2013, 11:09:43 AM
A simpler way if gavo doen't want to mess with CLI.

VLC can demux and transcode this audio without any problem.
(and everyone has VLC - no!)

Transcode the audio to MP3 using VLC - convert/save.
Then in avidemux 2.5.6,  replace the internal audio with the MP3 (via audio external track).
After that just remux in copy mode into a container of your choice.

Made an .avi using this approach and it played fine.
Only caveat is that the sample is to small to check for audio sync.

Pity avidemux 2.6.6 has an issue with parsing the video track out of the media clip, else it would be even better.


Title: Re: Problem with 1080i ts files
Post by: pchristy on November 21, 2013, 12:33:58 PM
I've not had any luck with mencoder, which seems to bork on the video file. It can handle the audio just fine.

I've never had much luck with VLC. It can be a total pain to build on Linux, and the hardware acceleration (needed for HiDef video) simply doesn't work on either of my systems (NVidia or AMD/Ati). MPlayer, on the other hand, plays back HiDef perfectly, with minimum processor load, even on a humble, single-core netbook!

Anyway, that's a couple of potential workarounds for gavo, so I'm going to give my brain a rest!

;)

Title: Re: Problem with 1080i ts files
Post by: styrol on November 21, 2013, 12:45:49 PM
Maybe I missed something but the sample can be converted into a "valid" mp4 file by just reencoding the audio using ffmpeg:
ffmpeg -i Input.ts -c:a aac -cutoff 15000 -b:a 128k -strict experimental -async 1 -c:v copy -sn -threads 8 -y Ouput.mp4
The sample is to small to check for audio sync.

FFmpeg output:
ffmpeg version 2.1-tessus Copyright (c) 2000-2013 the FFmpeg developers
  built on Oct 28 2013 04:17:07 with llvm-gcc 4.2.1 (LLVM build 2336.1.00)
  configuration: --prefix=/Users/tessus/data/ext/ffmpeg/sw --as=yasm --extra-version=tessus --disable-shared --enable-static --disable-ffplay --enable-gpl --enable-pthreads --enable-postproc --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-libspeex --enable-bzlib --enable-zlib --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libxavs --enable-version3 --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvpx --enable-libgsm --enable-libopus --enable-fontconfig --enable-libfreetype --enable-libass --enable-libbluray --enable-filters --enable-runtime-cpudetect
  libavutil      52. 48.100 / 52. 48.100
  libavcodec     55. 39.100 / 55. 39.100
  libavformat    55. 19.104 / 55. 19.104
  libavdevice    55.  5.100 / 55.  5.100
  libavfilter     3. 90.100 /  3. 90.100
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
[..]
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (aac_latm -> aac)
video:4510kB audio:95kB subtitle:0 global headers:0kB muxing overhead 0.153012%


Title: Re: Problem with 1080i ts files
Post by: pchristy on November 21, 2013, 03:20:46 PM
Styrol: Interesting!  I just tried your command and whilst it threw up a load of error messages, it did appear to work!

My ffmpeg is :  ffmpeg version N-56829-gf5b27b6, built on Oct 3rd from a git download, so its reasonably up-to-date.

Loads of video errors:

[h264 @ 0x221cca0] sps_id out of range
[h264 @ 0x221cca0] non-existing PPS referenced
[h264 @ 0x221cca0] sps_id out of range
[h264 @ 0x221cca0] non-existing PPS 0 referenced
[h264 @ 0x221cca0] decode_slice_header error
[h264 @ 0x221cca0] non-existing PPS 0 referenced
[h264 @ 0x221cca0] decode_slice_header error
<snip>

presumably due to it not starting in the right place, and also this for the audio:

[mpegts @ 0x2218c80] PES packet size mismatch
Error while decoding stream #0:1: Invalid data found when processing input

but having said that, it does produce a file that plays, and can be loaded into Avidemux for further tweaking!

Well done, that man! Have a cigar!

;D


Title: Re: Problem with 1080i ts files
Post by: pchristy on November 21, 2013, 04:28:24 PM
Following on from Styrol's post, I notice that there has been a new ffmpeg release - 2.1.1 - released yesterday (20th Nov).

I've just built this and can confirm that this handles the video in one hit, with a minimal cli:

ffmpeg -i gavo.ts -f mp4 -strict -2 -vcodec copy -async 1 gavo.mp4

-i defines the input file, -f specifies mp4 format output, -strict -2 tells it to allow the (experimental) aac audio codec, -vocdec copy speaks for itself, and async 1 tells it to sync the start of the video with the audio. gavo.mp4 is the output file. If you don't specify an audio codec, ffmpeg will default to aac if mp4 is specified.

I still get a lot of error codes, but it does produce a working mp4 file!

I normally use -async 1200 when transcoding, as this will allow the audio/video sync to be corrected gradually. -async 1 simply lines it up at the start and assumes that both are running at the same speed.

So a recent build of ffmpeg will do the whole thing in one hit!

;D

Title: Re: Problem with 1080i ts files
Post by: gavo on November 21, 2013, 09:51:08 PM
Well, I am back with what I think is the solution. It is not from Mygica but from a spanish forum.
I must say that my first purpose was to change the container and that's why I came to avidemux. Indeed, version 2.66 works well with ts files in Standard Definition. The problem came with High Definition files. I found that someone suggested using eac3to for demuxing but it was useless. The solution is to use last version of MediaCoder. What is still curious is that when you load the file in MediaCoder you can play it but if you want to change the container to MP4 or MKV copying video and audio, the resulting file is empty.
I don't know if I can solve this but if not, the trick is to uncheck the copy option and select a new audio codec. Perhaps in some files you can loose a bit of sync but this can be easily correct with avidemux. 
Thanks to all of you who spent time with this awful file and I hope this may be useful for someone else.
Title: Re: Problem with 1080i ts files
Post by: styrol on November 21, 2013, 10:18:28 PM
Quote from: gavo on November 21, 2013, 09:51:08 PM
What is still curious is that when you load the file in MediaCoder you can play it but if you want to change the container to MP4 or MKV copying video and audio, the resulting file is empty.
Decoding audio and video from a TS container is one thing, remuxing audio and video into another container is a rather different thing. The problem in your case is the AAC audio track in a special bitstream format "LATM". The MP4 muxer has to know it.
Title: Re: Problem with 1080i ts files
Post by: AQUAR on November 22, 2013, 12:11:18 AM
Since gavo is on the windows platform.
The windows build's for this new version are also now available (http://ffmpeg.zeranoe.com/builds/).

Plenty of ways for processing the mygica media files now.

But it still leaves our favorite version 2.6.6 in the naughty bin with bad video and silent audio.
I wonder if the new libavcodec used by ffmpeg will change this?
 
Title: Re: Problem with 1080i ts files
Post by: mean on November 22, 2013, 07:28:18 AM
audio => because it is not AAC LC but AAC SBR, i have to update the latm parsing code
Title: Re: Problem with 1080i ts files
Post by: AQUAR on November 22, 2013, 11:10:57 AM
@ mean
Thanks for that.

This strange clip was a good intro about the audio format profile : HE-AAC v1
and muxing mode : LATM.
Title: Re: Problem with 1080i ts files
Post by: AQUAR on November 23, 2013, 10:45:28 AM
Just for interest.

The fraunhofer web site has various aac test files (some with graphics) for compatibility checks.
https://www2.iis.fraunhofer.de/AAC/index.html
None of the audio tracks are LATM encapsulated so they should play on avidemux.
Title: Re: Problem with 1080i ts files
Post by: mean on November 24, 2013, 03:38:49 PM
Audio track should work now
Only object type 2 & 5 (AAC LC, AAC LC+SBR)
Title: Re: Problem with 1080i ts files
Post by: AQUAR on November 24, 2013, 08:57:47 PM
Tried with the audio + graphics test files from the fraunhofer web site.
All seems good for LC and HE v1.
Title: Re: Problem with 1080i ts files
Post by: mean on November 28, 2013, 07:00:01 AM
Should be better now, make sure you remove the .idx2 file
(build in progress)
Title: Re: Problem with 1080i ts files
Post by: AQUAR on November 28, 2013, 09:29:10 AM
Thanks mean for the extra splitter code.

I tested it, and r8972 demuxes the fields of this sample clip just fine.

Hopefully gavo will notice that he can now use avidemux to process his mygica dvb recordings.
If its for PC use he could blend deinterlace to get rid of the jaggies.

Just one observation when doing progressive recoding on this interlaced .h264 clip:
Muxing into avi will show a frame rate metadata of 50 fps (original field rate?).
Muxing the same into mkv will show frame rate metadata of 25 fps (plus original frame rate 50 fps).