PDA

View Full Version : AVCHD and opensource tools


vlada
19th August 2009, 12:25
Hi,

recently I tried to convert a AVCHD video from Panasonic camcorder. I tried many different tools but most of them fail in transcoding the video in different ways.

Avidemux opens the video, but seeking doesn't work. If you convert the video, it duplicates frames and the final output is slowed down twice (I didn't use any deinterlace filters).

The same happens with FFmpegSource AviSynth filter.

DgAVCDec causes some blocking artifacts.

CLI ffmpeg transcoder produces 2x faster video then original.

Do you know any simple and working process to convert AVCHD video to SD AVI/MPEG-4?

It seems that FFmpeg can't handle the 50i H.264 correctly for some reason. And since most opensource tools are based on FFmpeg, they have the same bug.

Myrsloik
19th August 2009, 16:36
I suggest you report it on the FFmpeg bug tracker then. If you do, all your favorite tools will begin to work. I don't know of any other good options.

poisondeathray
19th August 2009, 16:51
Did you try DirectShowSource() + Divx h.264 decoder or ffdshow in avisynth ? (or coreavc pro, but not opensource) . It works for both interlaced PAL & NTSC AVCHD from other cameras

Maybe something peculiar about your camera? What model?

Guest
19th August 2009, 16:52
I don't know of any other good options. DGAVCDecNV.

nm
19th August 2009, 17:56
It seems that FFmpeg can't handle the 50i H.264 correctly for some reason.
Generally it can, but perhaps your stream is somehow special. A sample clip would be nice, and report to FFmpeg if you'd like to get things fixed.

vlada
20th August 2009, 08:03
neuron2> Thanks for your suggestion and for your tools, but unfortunately I don't have a nVidia graphics.

poisondeathray> DirectShowSource (with Haali's splitter). This solution seems to work. Unfortunately I don't know the exact model which was used to take the video.

nm> I'm not 100% sure if the problem is directly in FFmpeg. But the problems can be seen in many FFmpeg based programs. I will provide a sample later when I get home.

7ekno
25th August 2009, 03:07
Are you sure it's 50i?!? Panasonic cameras can play "tricks" in AVCHD by duplicating frames ...

I get the exact same problem with AVCHDlite's fake 50p ;)

The only way I get a duplicate of the exact stream is to use DSS2 (DirectShowSource2 from a Haali Splitter install directory, it reports the 50 fps right, and it also shows the duplicate frames) ...

FFMpegSource2 only shows 25fps, DGTools (DGAVCIndex, DGAVCIndexNV, DGTools) reports 50fps but only shows the moving frames (not the duplicate statics, no matter what it's indexed with, no matter if the "honor pulldown" flag is set or not!), DirectShowSource isn't frame accurate (so any non linear functions tend to produce jumpy frames) ...

Example clips that stuff all these filters up (MTS file with AVC video and AC3 audio, straight from a Panasonic AVCHDlite device):
00000.MTS (http://www.mediafire.com/file/vjzytkenzyi/00000.MTS.rar), 00001.MTS (http://www.mediafire.com/file/lmhn2zzigmg/00001.MTS.rar), 00002.MTS (http://www.mediafire.com/file/madjydtjjx0/00002.MTS.rar)

For now, I am using DSS2() if I need a duplicate of the stream transcoded or processed, but even DSS2 is reporting too many frames in the stream (so it can crash at the end of an encode unless I also use Trim(0,reported frames - 4), if I am manipulating the stream I will use FFmpegSource2 + AssumeFPS(25) + MSU_FRC(2) ...

They are funny streams, no doubt, because if you play the streams you will notice frame 0, and frame 1 are actually different images, then frame 2 is a duplicate of frame 1, then frame 3 is different again with that pattern repeated throughout ...

7ek

Guest
25th August 2009, 03:52
Do you know what syntax element is used to signal these duplicates?

7ekno
25th August 2009, 07:26
Do you know what syntax element is used to signal these duplicates?

Nah, I can't work it out ... I can't even tell if the duplicates frames are actually encoded, signaled or referenced ...

7ek

vlada
26th August 2009, 15:10
7ekno> I'm pretty sure my video is 50i. It was taken by a camcorder (not a camera) and all Panasonic camcorders record to 50i only AFAIK. I'm sorry I haven't provided the sample yet, but I hope to do it tonight.

vlada
27th August 2009, 11:33
Hi,

a sample is at http://www.sendspace.com/file/ypcop0. I cut and remuxed it to TS container. But the results are the same as with the original MTS file.

7ekno
29th August 2009, 08:54
Hi,

a sample is at http://www.sendspace.com/file/ypcop0. I cut and remuxed it to TS container. But the results are the same as with the original MTS file.

MeGUI handled it right with the standard DGAVC tools using the "NVidia De-interlacer" in the DGx Source tab (in the MeGUI "tools" menu you will have to index it to DGA first, then use the MeGUI Avisynth script creator with appropriate de-interlace filters) ... the source is 1440x1080 @ 50i, so your choice of de-interlacer and resizer (although I would do the resizing via DAR signaling in the stream) will be important ;)

7ek

vlada
30th August 2009, 19:09
7ekno> Did you use HW or SW decoder (DGAVCDec vs. DGAVCDecNV)?

Guest
30th August 2009, 21:00
Has to be the NV version to use PureVideo (NVidia De-interlacer).

7ekno
7th September 2009, 13:32
7ekno> Did you use HW or SW decoder (DGAVCDec vs. DGAVCDecNV)?

NV, It's completely worth it for PureVideo's de-interlacing quality and speed ;)

7ek

vlada
9th September 2009, 14:02
I did some more tests with my AVCHD samples. The results are really strange.

DirectShowSource with Haali's splitter and ffdshow decodes the video OK.

I tried to convert the video to AVI/MPEG-4 ASP using ffmpeg CLI SVN-r19159. The final video had doubled frames. Each frame is interlaced a followed by it's duplicate.

The latest version of FFMS2 has the same output as I mentioned earlier. It has doubled frames, but all of them are unique. I can see combing artifacts on the frames, which is strange. Also the frames are not exactly doubled, frame 400 of source video is not the same as frame 800 from FFMS2. I can elaborate this further if it helps anything.

DGAVCDec reports the correct count of frames, but there is a lot of blocking artifacts and I have a feeling the frame order is sometimes incorrect too.

Myrsloik> Could you please have a look at my AVCHD sample if there is anything you can do to support it? Since it works correctly in DirectShow, Haali's splitter and libavcodec should be able to decode the video.

neuron2> Could you please try to update libavcodec.dll? The version in latest DGAVCDec is quite old. Since other FFmpeg based tools don't have the blocking artifacts, I hope an updated libavcodec might fix it.

Guest
9th September 2009, 14:10
neuron2> Could you please try to update libavcodec.dll? The version in latest DGAVCDec is quite old. Since other FFmpeg based tools don't have the blocking artifacts, I hope an updated libavcodec might fix it. No. It's been discussed many times. Use search.

You can use DGAVCDecNV. It decodes these streams with no problems. That has also been discussed. :)

vlada
9th September 2009, 14:32
No. It's been discussed many times. Use search.

It's not possible because I check that it is the DLL that I supply. I cannot use the newer versions because they are broken for accurate frame random access.

Is this the reason? Is it still broken in libavcodec (FFmpeg)? Is there any chance of fixing it or should I simply forget about DGAVCDec for my purpose.

You can use DGAVCDecNV. It decodes these streams with no problems. That has also been discussed. :)

Yes I know, but I don't own a nVidia graphics, furthermore I search for a solution that would work for all people.

Guest
9th September 2009, 14:45
Is this the reason? Is it still broken in libavcodec (FFmpeg)? Is there any chance of fixing it or should I simply forget about DGAVCDec for my purpose. Yes, it is the reason. Yes, it is still broken. The only chance for fixing it is if the libavcodec developers decide that the bug is worth fixing. Since there is no indication that they care about it I consider DGAVCDec to be dead-ended at this time.

Yes I know, but I don't own a nVidia graphics, furthermore I search for a solution that would work for all people. Keep searching then. :)

You can get a usable Nvidia card for less than $50.

poisondeathray
9th September 2009, 15:56
I search for a solution that would work for all people.

DirectShowSource() or DSS2() + Haali + FFDShow works fine when fed to vdub to encode xvid for example

Boolsheet
9th September 2009, 16:18
I experienced a similar behaviour of ffmpeg with my AVCHD sources. Forcing the framerate should fix the problem:

ffmpeg.exe -i AVCHD.ts -r 25 -vcodec rawvideo -an AVCHD.avi

Tested the difference with this avisynth script:

a = AVISource("AVCHD.avi")
b = DirectShowSource("AVCHD.ts", audio=false)
compare(a,b)

The output is the same as the DivX DirectShow decoder, well not exactly... The last 3 Frames are different, somehow DivX couldn't decode those and dropped them.

nm
9th September 2009, 16:26
MEncoder also seems to work with -mc 0 -noskip. For example:
mencoder input.ts -ovc lavc -lavcopts vqscale=3 -oac copy -mc 0 -noskip -vf yadif=0,scale=640:-2 -o output.avi

Kdenlive handles vlada's sample properly too, but it only works on Linux and *BSD.

vlada
19th September 2009, 00:30
poisondeathray> Yes, that's the solution I currently use. But it requires people to have a working DirectShow setup. I'm working on a AviSynth based audio/video transcoding application. I want to support at the input as many formats as possible while keeping the application portable. I'm getting close to the first release, but I wanted to support AVCHD. Unfortunately both portable solution - DGAVCDec and FFmpegSource fail to open it. The application will automatically switch to DirectShowSource if the preferred input filters fail. Unfortunately in this case, the filters seem to work but the output will be corrupted.

neuron2> I just purchased an nVidia card yesterday. ;-)