Pages: [1]   Go Down

Author Topic: AVCHD transcoding within Linux environment  (Read 8876 times)

diyav

  • Newbie
  • *
  • Offline Offline
  • Posts: 6
AVCHD transcoding within Linux environment
« on: September 06, 2011, 06:44:22 pm »

I'm hoping that I may be able to find someone here that is familiar with AVCHD video and Linux.

I have and use a GH2 (and a TZ7 - my wife's), so I have AVCHD and AVCHD Lite clips to edit.

I also have a Dual Core 3.2 GHz PC with 2GB memory running a Linux OS. This system can play the files (just about) but editing is, as you can imagine, a bit of a struggle.

Having bought the LL Guide to Cinematography for Photographers I understand that I would probably be best to transcode the AVCHD files to make the editing easier. The guide recommends transcoding to ProRes. However, this is a proprietary format 'native' to Macs and possibly available for Windows. A very good all round utility is ffmpeg, which I believe currently includes some support for decoding ProRes, but unlikely to offer any support for encoding any time soon.

ffmpeg offers several lossless alternatives such as Huffyuv which I would like to use, unless anyone can suggest otherwise.

I have tried using ffmpeg and Huffyuv, but the result is not as 'clean' as I believe should be possible, such as signs of 'combing'. This is probably due to incorrect or missing options, of which there are many.

I have also found reference elsewhere (although now several years old) to using two other utilities (mencoder and mplayer I think), but the process would appear to split (demux?) the video and audio streams, process then re-combine them, which seems unnecessary to me. Some other references also appear to use mpeg or H.264 codecs which I understand are either lower quality or equal compression so would not seem to meet the ideal requirement.

With regard to the 'Lite' format, the problem is exacerbated by the cludge of recording P video encased in I format.

So, can anyone please help with regard to ffmpeg settings and or an alternative method, for both AVCHD and AVCHD Lite video files?
Logged

Daniel Browning

  • Full Member
  • ***
  • Offline Offline
  • Posts: 142
Re: AVCHD transcoding within Linux environment
« Reply #1 on: September 06, 2011, 06:56:15 pm »

I am interested. I'm also on Linux, and I've done transcoding with ffmpeg before, but not from AVCHD -> Huffyuv. Interlace combing issues could be coming from several areas. For example, it's possible (but highly unlikely IMHO) that the transcode is happening perfectly, but the program you're using for playback is not doing the job correctly, whereas another program would. I'll try playing around with it a little bit and if I can find out anything useful (unlikely), I'll report back. Otherwise, hopefully someone else can chime in with a more useful post for you. :)
Logged
--Daniel

diyav

  • Newbie
  • *
  • Offline Offline
  • Posts: 6
Re: AVCHD transcoding within Linux environment
« Reply #2 on: September 06, 2011, 07:16:23 pm »

I agree that the combing issues could come from a number of places, but I don't think it is a playback issue as the same hardware can play the original AVCHD (and Lite) files.

I forgot to mention that I'm in the UK so use Pal, so 50/25 fps. Something I read somewhere suggested that this might not be 'true' 50 fps, but 49.9xx. If this is true, then this might also be a problem.

Unfortunately, I think I have just enough knowledge to know some of the terminology, but not enough to keep me out of trouble!
Logged

Daniel Browning

  • Full Member
  • ***
  • Offline Offline
  • Posts: 142
Re: AVCHD transcoding within Linux environment
« Reply #3 on: September 06, 2011, 08:32:33 pm »

I was able to reproduce your problem, but I did not find a solution. I downloaded a GH2 24p video file and converted it to HuffyUV with ffmpeg and it played back great. When I tried the same thing with a GH2 50i video file, I got the combing artifacts.

After a little investigation, I discovered that HuffyUV did not even support interlace flags until the most recent version (2.2.0), which doesn't even seem to be available on the author's web site. So that leads me to a few possible theories:

 * HuffyUV itself has some bugs in the brand new interlacing feature
 * HuffyUV itself is fine, but ffmpeg is not using the brand-new interlace feature that HuffyUV supports.
 * ffmpeg is fine, but the playback program is using the old (2.1-era) HuffyUV that doesn't detect and use the interlace flags.

Good luck.
Logged
--Daniel

diyav

  • Newbie
  • *
  • Offline Offline
  • Posts: 6
Re: AVCHD transcoding within Linux environment
« Reply #4 on: September 07, 2011, 06:05:16 am »

Thank you for your time checking this out, which at least gives me some options to investigate further myself.

On the camera side, I need to better understand the different video options and when/how they come into effect. In particular, FPS and I/P, so I know what I'm trying to deal with in transcoding.

In terms of transcoding, their are other options for codecs. In particular there is ffvhuf, an alternative/variant of Huffyuv, which may or may not suffer the same problems.

The problem is that with so many options and if I'm honest, not fully understanding what I'm doing, I could spend forever working through different permutations and never get the results that I want or are possible.

I just hope that someone with more knowledge achieves this and that I can find the report and details of their success.

If I find anything useful I will report back.

Thanks again for your input.
Logged

diyav

  • Newbie
  • *
  • Offline Offline
  • Posts: 6
Re: AVCHD transcoding within Linux environment
« Reply #5 on: September 07, 2011, 11:17:01 am »

Well, as I mentioned before, I know enough to get into trouble but not necessarily to get or keep out of it!

I hadn't even thought about the interlace aspect. Thought the clip I was testing was P and didn't check.

Out of interest, I'm not sure that ffmpeg makes it clear, so on a separate but related issue does anyone know how I might be able to check any given clip for its format?

Anyhow, following the previous reply post by by Daniel, I though that I would try the huffyuv codec but adding the deinterlace switch. I added it before the input file flag as one of the other articles I read in looking for a solution mentioned that 'the switch' needed to be before the file to operate on it.

Guess what? It appears to work and playback without the combing artefacts.

I'm using FFmpeg version SVN-r0.5.1-4:0.5.1-1ubuntu1.1 and the code I used was:
ffmpeg -deinterlace -i input-file.MTS -acodec copy -vcodec huffyuv output-file.avi

From what I've seen so far this appears to deliver just what I want. I can scrub the timeline (OpenShot) and the video is clean and the system can keep up for editing.
Logged

Daniel Browning

  • Full Member
  • ***
  • Offline Offline
  • Posts: 142
Re: AVCHD transcoding within Linux environment
« Reply #6 on: September 07, 2011, 12:16:36 pm »

Out of interest, I'm not sure that ffmpeg makes it clear, so on a separate but related issue does anyone know how I might be able to check any given clip for its format?

I'm not sure how to check if it's interlaced or not, but you can at least find the frame rate by opening it in VLC and going to Tools->Codec information, which should say 50 for 50i. Since the GH2 is only capable of 50i (not 50p), you know it's 50i. If VLC says 24, 25, etc., then it's probably 24p or 25p.

Guess what? It appears to work and playback without the combing artefacts.

Excellent. This may have one or two downsides (which may or may not matter to you). If you deinterlace to 50p, the file size usually doubles, but the quality is great (especially with a good deinterlace algorithm like yadiff2). If you deinterlace to 25p, then you lose the feel of motion of 50i (like going from "soap opera" feel to "movie" feel) and you get more artifacts than just shooting 25p to start with.

From what I've seen so far this appears to deliver just what I want. I can scrub the timeline (OpenShot) and the video is clean and the system can keep up for editing.

Excellent!
Logged
--Daniel

diyav

  • Newbie
  • *
  • Offline Offline
  • Posts: 6
Re: AVCHD transcoding within Linux environment
« Reply #7 on: September 07, 2011, 01:02:26 pm »

Quote
Excellent. This may have one or two downsides (which may or may not matter to you). If you deinterlace to 50p, the file size usually doubles, but the quality is great (especially with a good deinterlace algorithm like yadiff2).
I'm not bothered about file size yet. If I have to use large files for the editing/production process and it makes it a more manageable process then I can accept it.

Quote
If you deinterlace to 25p, then you lose the feel of motion of 50i (like going from "soap opera" feel to "movie" feel) and you get more artifacts than just shooting 25p to start with.
I'm not sure what I'm deinterlacing to but believe and hope it is 50p.

The output from ffmpeg on the original file is:
Input #0, mpegts, from 'g-test1.MTS':
  Duration: 00:00:12.55, start: 0.701467, bitrate: 16450 kb/s
  Program 1
    Stream #0.0[0x1011]: Video: h264, yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 50 tbr, 90k tbn, 50 tbc
    Stream #0.1[0x1100]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s

The output from the transcoded avi file is:
Input #0, avi, from 'g-test1.avi':
  Duration: 00:00:12.57, start: 0.000000, bitrate: 409239 kb/s
    Stream #0.0: Video: huffyuv, yuv422p, 1920x1080, PAR 1:1 DAR 16:9, 50 tbr, 50 tbn, 50 tbc
    Stream #0.1: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s

I haven't yet looked into the different figures but the only obvious other than bitrate is the tbn figure. Given that the original clip was created with the 'red' video button, I understand that that produces 50i. As I created the avi file with a deinterlace switch I hope that the new file is therefore 50p, but there isn't anything that confirms this.

I'll have to investigate a method of checking this.
Logged

diyav

  • Newbie
  • *
  • Offline Offline
  • Posts: 6
Re: AVCHD transcoding within Linux environment
« Reply #8 on: September 07, 2011, 02:16:39 pm »

Identifying interlaced video?

Probably a little obvious for those that know. You don't actually need to have a piece of software to identify I/P and indeed, there is some suggestion that they may not even work all the time.

What you do need is a player that doesn't deinterlace or has an option not to. Then on playback of any given file, you will see any interlacing/combing.

I have been using VLC which was deinterlacing the video previously. However, I found and disabled this option and there was the combing shown in the playback.

At least it was for the original 50i file. The transcoded file does not show the same effect, so it would seem that the process in the above post does indeed create 50p video.

Thanks to a little help from Daniel, in solving the original transcoding problem, I have also learnt a little more about the whole process and using VLC, so this has been a significant step forwards in my learning and knowledge. Thanks Daniel, I hope you've also gained something from your original interest mentioned in your first post:)

Logged
Pages: [1]   Go Up