AVCHD .m2ts conversion for Linux - Page 6 - AVS Forum
Forum Jump: 
 
Thread Tools
Old 03-05-2009, 02:38 PM
Member
 
h-munster's Avatar
 
Join Date: Jan 2009
Location: Hollywood, CA
Posts: 40
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Quote:
Originally Posted by oldcpu View Post

Under openSUSE-11.1 Linux, I tried playing your files with ffplay on 3 different PCs, and also tried edit/rendering them with kdenlive.

Thank you for your help.

I am glad to know about the ffplay capability. On my machine, ffplay stutters (both video and audio) with the Canon AVCHD footage. I have ffplay/ffmpeg version SVN-r1639, and I have an Athlon dual 4000 (but it seems to be running at 1Ghz!). Mplayer doesn't play the AVCHD video at all, but gives smooth audio.

Can you play the Canon AVCHD footage with Mplayer?

Unfortunately, I think it would be futile to try to convince my Final Cut Pro editors to switch to kdenlive. In addition to needing a usable format for those FCP users, I am trying to do the remove the Canon FP24 pull-down, and I don't see that capability anywhere in kdenlive (my version is 0.7.2.1).

I am also grateful that your post made me check the stats in my /proc/cpuinfo. I need to find out why I am running at only 1Ghz.

Thanks,
-Dale
h-munster is offline  
Sponsored Links
Advertisement
 
Old 03-05-2009, 03:39 PM
Member
 
oldcpu's Avatar
 
Join Date: Feb 2009
Location: Europe
Posts: 65
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Quote:
Originally Posted by h-munster View Post

Can you play the Canon AVCHD footage with Mplayer?

No, ... audio only with mplayer on all 3 of my PCs (including my Intel core2 duo P8400). But I use a version of mplayer packaged by the Packman rpm/application 3rd party packagers for openSUSE, and I know one user (who packages the scripts xvidenc , h264enc , and divxenc ) who claims he has yet to find an AVCHD format his custom compiled mplayer can not handle. (I do not compile mplayer myself). I replied to one of his posts with a link to a recent AVCHD and asked if he could confirm that still the case ... he has not got back to me yet.
oldcpu is offline  
Old 03-09-2009, 01:58 AM
Member
 
h-munster's Avatar
 
Join Date: Jan 2009
Location: Hollywood, CA
Posts: 40
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
@oldcpu
Thanks for reminding me of the h264enc/xvidenc/divxenc scripts. It appears that these scripts handle batch encodings, and that they also can use the detc pulldown removal plugin. I might try one of these.

Thanks,
-Dale
h-munster is offline  
Old 03-09-2009, 12:51 PM
Member
 
oldcpu's Avatar
 
Join Date: Feb 2009
Location: Europe
Posts: 65
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Quote:
Originally Posted by h-munster View Post

.... the h264enc/xvidenc/divxenc scripts. It appears that these scripts handle batch encodings, and that they also can use the detc pulldown removal plugin. I might try one of these.

They are handy scripts. I use xvidenc a fair amount.

I confess most of their features, I know nothing about. There is an explanation here:
http://h264enc.sourceforge.net/faq.html

... and reference pull down, after reading your post, I now note this :
Quote:


- Video filters

* 11 software scaling filters (fast bilinear, bilinear, bicubic, experimental, nearest neighbor/point, area averaging, luma bicubic/chroma bilinear, gaussian, sinc, lanczos, natural bicubic spline)
* 5 deblock/dering postprocessing filters (spp, uspp, fspp, pp7, ha/va/dr)
* 5 denoise filters (denoise3d, hqdn3d, ow, tn, x264's internal denoiser)
* 1 (un)sharp mask/gaussian blur filter (unsharp)
* 10 different deinterlacers (lb, li, ci, md, fd, l5, yadif, tfields, mcdeint, kerndeint)
* 5 inverse telecine/3:2 pulldown filters (pullup, filmdint, ivtc, detc, telecine)
* Automatic brightness/contrast control filters
* 1 software equalizer filter (eq2)
* 1 interlacing filter (tinterlace combined with the phase filter)
* 2 frame rate conversion filters (filmdint, framestep)

which I am certain you noted before I (as most of this is typically beyond my knowledge).
oldcpu is offline  
Old 03-25-2009, 02:53 PM
Member
 
h-munster's Avatar
 
Join Date: Jan 2009
Location: Hollywood, CA
Posts: 40
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
I found a way to remove the 24P pulldown on all the AVCHD files generated by my Canon HF11.

[Note: the method described in this post is being superceded by the easier/faster "pu-avchd" script explained in message #158 below]

Unfortunately, one has to play each file for about 10-15 seconds to determine on which frame it starts in the 3:2 pulldown cadence. Then one moves the file into a corresponding directory, before it can be batch encoded. Eventually, these two manual steps will probably be eliminated/automated.

The below procedure works for Linux, Unix and probably OSX, as long as the versions of mencoder and ffmpeg are recent. The process is simpler than it looks.

Enjoy!

-Dale


=============


PULLDOWN REMOVAL FOR CANON 24P AVCHD FOOTAGE, USING MENCODER AND FFMPEG IN LINUX/UNIX/OSX


WHEN SHOOTING:
- Upon pressing the camera's start button, swipe your hand side-to-side in front of the lens for one second, or pan back-and-forth for one second. This movement will make it much easier to determine which frame of the 3:2 pulldown cadence starts the file (especially when the subject is standing still).

PREPARE YOUR ENCODING DIRECTORIES:
- Put all of the AVCHD files into the desired directory for your project, and, in that directory, create five sub-directories labeled "0", "1", "2", "3" and "4".

DETERMINE EACH FILE'S STARTING FRAME AND MOVE THE FILES TO THEIR CORRESPONDING DIRECTORY:
- Open a terminal, and "CD" to the directory that contains the AVCHD files.
- To play an AVCHD file one-frame-at-a-time, use the command, "mplayer -demuxer lavf -vc ffh264 your_avchd_file.mts". Press the spacebar immediately after pressing "enter" on this mplayer command, which will pause the video on the first or second frame (you can see on which frame it stops). To advance one-frame-at-a-time, press the period (".") key. This method allows you to count through the cadence and determine on which frame the video starts. Once you get the hang of this procedure, it should take about 10-15 seconds to determine the starting frame.
- Here are the five different pulldown cadence patterns ("P"=progressive frame and "I"=interlaced frame):
PPPII -- starts on frame #0
PPIIP -- starts on frame #1
PIIPP -- starts on frame #2
IIPPP -- starts on frame #3
IPPPI -- starts on frame #4
- When you determine on which frame the file's 3:2 cadence starts, move that file to the corresponding sub-directory.
- Repeat this "starting-frame-discovery" procedure on each file, until all the files are moved to their corresponding directories.
- By the way, you could put all files starting on frames #0, #1 and #2 into one directory, because they use the same pulldown removal filter. However, it is probably good to keep each type of file in a separate directory, so that you can recover easily just in case you uniformly miscount/mis-designate every file in a directory (e.g. all the files you designated to be #1 are actually #3 files).

ENCODE THE FILES:
- Get the three mffpeger scripts: mffpeger012; mffpeger3; and mffpeger4. I have put them here: http://marks.org/avchd/mffpeger/
- In your terminal, "CD" to each subdirectory and use the corresponding mffpeger script (mffpeger012 for sub-directories "0", "1" and "2"; mffpeger3 for sub-directory "3"; and mffpeger4 for sub-directory "4").
- Because the mffpeger script is not interactive (it does not use switches/flags to change settings on the command line), it is probably best to put a copy of the script into each subdirectory and use that script, rather than running the script globally (for instance, from within /usr/local/bin). This way, changes to the settings can be made within the script, and they won't affect the script's use elsewhere. Of course, to use a script in the current directory, one merely types "./name_of_script" at the terminal prompt, and then presses "enter".
- If you continually get skipped/dropped frame errors during the mencoder stage, try using one of the other two scripts on the file. By the way, after the pulldown has been removed, there should be no duplicate frames -- you can see duplicate frames by advancing through the footage one-frame-at-a-time in mplayer.
- The mffpeger default file format is Quicktime files (.mov), to use in Final Cut Pro. If you have a Mac computer and these files don't play in Quicktime or FCP, try installing the free Perian utility: http://perian.org/ and then try to play the footage.

TO DO:
1. Find a way to adjust the settings on one of mencoder's fancy, pulldown removal filters, so that a single script can remove the pulldown on all of the files, regardless of the starting frame.
2. Make the script interactive, so that settings (such as frame rate, pulldown removal, file paths, deinterlacing, frame rates, etc.) can be specified on the command line.
3. Explore streaming raw video during encoding. It might be faster/better to pipe a raw video stream out of mencoder and into ffmpeg, but I am not sure how to do that. I have seen scripts that pipe a raw video stream from mplayer into ffmpeg, but this method seems to necessitate that the audio be encoded/copied on a separate pass.
4. Convert the mffpeger script to work in Windows.

I could definitely use some help with these tasks. I am a novice, so it will probably take a lot of time/effort for me to find these command/script settings on my own, merely poking-around by trial-and-error.
h-munster is offline  
Old 04-03-2009, 09:52 PM
Member
 
mooninite's Avatar
 
Join Date: Oct 2006
Posts: 171
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
h-munster, that's a good set of instructions. Let me help you out a little.

You should use libx264 instead of mpeg4 and mkv instead of mov. Knock the bitrate down from 35k... to 25k...

Also, for 30FP pulldown removal, use the following:

Code:
mencoder $i -fps 60000/1001 -oac pcm -demuxer lavf -vf pullup,softskip -ofps 30000/1001 -ovc lavc -lavcopts vcodec=ffvhuff:format=YV12:vstrict=-1:aspect=16/9 -o $INTERMED
You can use fifos by using mplayer -> ffmpeg.

mplayer -vo yuv4mpeg:file=videoout.fifo

ffmpeg -f yuv4mpegpipe -i videoout.fifo
mooninite is offline  
Old 04-04-2009, 02:26 AM
Member
 
h-munster's Avatar
 
Join Date: Jan 2009
Location: Hollywood, CA
Posts: 40
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
mooninite, thank you very much for the help.

I was aware of the named pipes (fifos) for mplayer/ffmpeg, but I was wondering how to pipe from mencoder into ffmpeg. Mplayer stutters on my machine when playing AVCHD files, even with the "-demuxer lavf -vc ffh264" flags.

Just curious, why is libx264 is better than mpeg4? Isn't AVCHD already H264? And isn't the severe H264 compression the reason why AVCHD is so CPU intensive?

So, for my files to play on most machines and for my files to be editable on most non-linear editors, shouldn't I be trying to get away from H264 compression?

Also, Final Cut Pro has to be able to play my files. So, isn't the Quicktime (.mov) container better than mkv? Every time I mention mkv to an FCP editor, I get a blank stare!

In regards to bitrate, I would love to yield MPEG2 video at 35Mb/s. Mpeg4 (or mencoder/ffmpeg) doesn't seem to allow a constant bitrate of more than about 30 Mb/s. Same with H264 encoded by mencoder/ffmpeg.


Pu-avchd seems to be much better than mffpeger

Since I posted the mffpeger script, I have found a single-pass mencoder command that, so far, seems to successfully remove the pulldown from all Canon ".mts" files -- which means there is no need to play each file to find its starting frame!

Furthermore, it encodes a lot faster than mffpeger (at a varying rate of between 10fps to 20fps), in about 1/6th of the time taken by mffpeger!

I cannot discern any difference in the resulting video quality between the two methods.

Here is the command:
Code:
mencoder input_file.mts -o output_file.mov -noskip -mc 0 -oac lavc -demuxer lavf -vf pullup,softskip -ovc lavc -lavcopts acodec=libfaac:abitrate=256:vcodec=mpeg4:vqscale=2:aspect=16/9 -of lavf -lavfopts format=mov -fps 60000/1001 -ofps 24000/1001
Incidentally, the "pullup" filter can be replaced with the "detc" filter, and the command still seems to work on all AVCHD *mts files generated by my Canon HF11. I switched from specifying a constant bitrate to specifying the maximum quality -- "vqscale=2" (vqscale=1 is not necessarily better quality, and there are warnings that vqscale=1 can cause wierd side effects).

I was unable to make the audio/video properly sync when specifying the pcm codec (-oac pcm), as in mffpeger. The audio from the above command seems to have less "bite" than pcm, but it seems to sync better. If anyone knows how to maintain the audio quality, while keeping the sync intact, I would wellcome any suggestions.

I put this command in a "script" to convert a batch of "*mts" files in the current directory into ".mov" files. I call the script, "pu-avchd":
Code:
#!/bin/bash

## pu-avchd -- remove the pulldown from a batch of Canon FP24, AVCHD files (.mts),
## and then convert them to Quicktime (mov).
##
## Please send any modified versions of this script to me at h_munster@gmx.com.
## Thanks,  -Dale

for i in *mts;
do

  ORIGINAL=`basename $i .mts`
  FINAL=${ORIGINAL}.mov

## Mencoder command.
mencoder $i -o $FINAL -noskip -mc 0 -oac lavc -demuxer lavf -vf pullup,softskip -ovc lavc -lavcopts acodec=libfaac:abitrate=256:vcodec=mpeg4:vqscale=2:aspect=16/9 -of lavf -lavfopts format=mov -fps 60000/1001 -ofps 24000/1001

done
The "vqscale=2" flag seems to encode with a variable bitrate, and it yields smaller files with slightly lower average bitrates than the constant bitrate flag in the mffpeger script.

The big question now is whether or not the .mov files resulting from pu-avchd are playable in Quicktime/FCP. I have to get a Mac friend to try to play them. It is possible that the Perian utility might have to be installed on the Mac machine, for these files to play.

I am still experimenting with different options/flags. With most of the files, the audio track runs about 0.13 seconds shorter than the video track, so I am considering delaying the audio track in mencoder to compensate for this slight difference.

Any comments or tips are appreciated.

Thanks,
-Dale
h-munster is offline  
Old 04-04-2009, 08:32 PM
Member
 
mooninite's Avatar
 
Join Date: Oct 2006
Posts: 171
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Quote:
Originally Posted by h-munster View Post

mooninite, thank you very much for the help.

I was aware of the named pipes (fifos) for mplayer/ffmpeg, but I was wondering how to pipe from mencoder into ffmpeg. Mplayer stutters on my machine when playing AVCHD files, even with the "-demuxer lavf -vc ffh264" flags.

mencoder is an *encoder* and you cannot output to a fifo. mplayer is a *player* and can output to a fifo. When you are using mplayer to output to a fifo, it does not playback at real-time because it's waiting on the program on the other end of the fifo to accept data. Your "stuttering" computer won't cause any problems with a fifo pipe when using mplayer.

Quote:
Just curious, why is libx264 is better than mpeg4? Isn't AVCHD already H264? And isn't the severe H264 compression the reason why AVCHD is so CPU intensive?

So, for my files to play on most machines and for my files to be editable on most non-linear editors, shouldn't I be trying to get away from H264 compression?

Yes, AVCHD is h.264, which is MPEG-4 layer 10, but what you are doing is taking h.264 video and transcoding to MPEG-4 layer 2... which is worse than you started with. That's why I recommended that you stick with H.264. If your computer can't handle h.264, then it is time to upgrade. Sticking with h.264 will retain PQ while changing codecs will make your video worse.

Quote:
Also, Final Cut Pro has to be able to play my files. So, isn't the Quicktime (.mov) container better than mkv? Every time I mention mkv to an FCP editor, I get a blank stare!

Time to find new software. kdenlive will negate all of what you are doing as when ffmpeg gets AVCHD support you can edit straight from the .MTS files from your cam.

Quote:
In regards to bitrate, I would love to yield MPEG2 video at 35Mb/s. Mpeg4 (or mencoder/ffmpeg) doesn't seem to allow a constant bitrate of more than about 30 Mb/s. Same with H264 encoded by mencoder/ffmpeg.

You do not seem to understand the differences in the codecs you are using. I would recommend that you spend some time reading up the differences between MPEG-2, MPEG-4, and H.264 (MPEG-4 layer 10). Using 35Mb does nothing for your video except take up more disc space unnecessarily.
mooninite is offline  
Old 04-06-2009, 02:09 PM
Member
 
h-munster's Avatar
 
Join Date: Jan 2009
Location: Hollywood, CA
Posts: 40
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
mooninite,

Thank you for the tips. I figured that the mplayer stuttering wouldn't matter, but there seemed to be other pipe options available with encoders, so I tried them first.

I am a little confused after your explanation about not being able to pipe the output from encoders. I thought that one could do so and also could use named pipes on the output of ffmpeg (which is an encoder).

I found some sites that mentioned these possibilities. Here is the FAQ section from ffmpeg.org showing the use of named pipes on the ffmpeg output: http://www.ffmpeg.org/faq.html#SEC30 Here is a procedure that pipes the output of mencoder: http://wiidiaplayer.wordpress.com/category/mencoder/

In message #136 of this very thread, alecmuffett posted a link to his hdffxvrt script, which seems to pipe output from the ffmpeg encoder.

I just wanted to pipe the output from mencoder into ffmpeg, with or without named pipes.

However, that piping procedure is probably unnecessary, because the single-pass mencoder command in pu-avchd seems to work better. I just have to make sure that my clients (mostly Mac/FCP users) can use the resulting files.

In regards to sticking with H264 on the output, I tried this comand:
Code:
mencoder input_file.mts -o output_file.mov -noskip -mc 0 -oac lavc -demuxer lavf -vf pullup,softskip -ovc lavc -lavcopts acodec=libfaac:abitrate=256:vcodec=libx264:vbitrate=24000000:aspect=16/9 -of lavf -lavfopts format=mov -fps 60000/1001 -ofps 24000/1001
It looked good, but it stuttered in mplayer.

I used the "vbitrate=24000000" flag instead of "vqscale=2", because the "vqscale=2" results looked crappy.

I also tried other formats (mpeg4 in avi, mpeg2 in avi, etc.) at higher bitrates, and I cannot perceive any difference between those videos and the H264 video. I even compared identical, captured, still frames.

I can discern only a very slight difference between the pu-avchd mpeg4 results and the higher bitrate H264 and avi files. However, the difference is almost imperceptible -- the pu-avchd files have slightly less grain/sharpness in certain fleeting areas and moments. I have not spotted any artifacts in any of the videos.

Regarding the tip to get new software, unfortunately, Final Cut Pro (and Avid) software is what my clients usually own. They would probably hire someone else if I relayed your suggestion to them.

The Kdenlive potential is encouraging. However, I think ffmpeg can already decode/read AVCHD -- it just cannot remove the Canon 24P pulldown.

You are correct. I don't understand all of the differences between the many codecs and containers. No matter how much I read about all of the little features and nuances in codecs/containers, I seem to get more confused and forgetful about the subject. I only have so many brain cells!

The reason why I desired MPEG2 video at 35Mb/s is because those "settings" are what the FCP editors report they are using on their timeline from certain Sony cameras. I would like to match those settings as closely as possible.

My compressed AVCHD files supposedly have a bitrate of 25 Mb/s, while ffmpeg reports that the raw video from those files is around 300,000 Mb/s! So, I just want a bitrate that is "in between," and I want files that FCP can use.

Thanks,
-Dale
h-munster is offline  
Old 06-21-2009, 02:34 PM
Newbie
 
yeahyeahyeah's Avatar
 
Join Date: Jun 2009
Posts: 5
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
how do i post a forum of my own??? i only know how to reply. please reply i need help!!!
yeahyeahyeah is offline  
Old 06-22-2009, 01:08 PM
Member
 
h-munster's Avatar
 
Join Date: Jan 2009
Location: Hollywood, CA
Posts: 40
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Quote:
Originally Posted by yeahyeahyeah View Post

how do i post a forum of my own??? i only know how to reply. please reply i need help!!!

I assume that you mean that you want to start a new forum thread.

To do so, find the page that shows the list of threads in the forum in which you wish to post, and then click on the "New Thread" button.

If you do not see a "New Thread" button, it could be that your thread-starting capabilities are restricted until you make a certain number of posts, or check to see if javascript is enabled in your browser.
h-munster is offline  
Old 10-24-2009, 04:06 PM
Member
 
h-munster's Avatar
 
Join Date: Jan 2009
Location: Hollywood, CA
Posts: 40
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
I have made some progress in transcoding Canon 24FP AVCHD files.

I have updated the mffpeger script, so that it does the 24FP pulldown removal automatically on any file with any cadence (no need to inch through each file frame-by-frame to determine cadence), and so that it outputs a DNxHD file withing a Quicktime container.

DNxHD is Avid's high quality intermediate codec. It is a free/open codec, so it can be used by FCP, Avid and probably other NLEs. This format is almost "lossless." FCP users merely need to download the free codec from Avid.

By the way, Apple does not support AVCHD on their PowerPC machines, so this is one of the free/easy ways to get AVCHD to work with FCP on a G4/G5. One can also import AVCHD onto PowerPC machines by using Toast, Voltaic and Cineform.

Mencoder's "pullup" filter is used to remove the 24FP pulldown, combined with other mencoder settings taken from the pu-avchd script. Mencoder outputs an almost raw AVI file, then ffmpeg converts this AVI file into the DNxHD/Quicktime file.

Here's the code for mffpeger10-1-09:
Code:
#!/bin/bash

## mffpeger10-1-09 -- remove the Canon AVCHD 24FP->60I pulldown in mencoder, then convert it to DNxHD/Quicktime in ffmpeg.
##
## mencoder's "pullup" filter is used to remove the pulldown on Canon 24FP AVCHD files
##
## Please send any modified versions of this script to me at h_munster@gmx.com.
## Thanks,  -Dale


for i in *mts;
do

  ORIGINAL=`basename $i .mts`
  INTERMED=${ORIGINAL}.avi
  FINAL=${ORIGINAL}.mov

## Use mencoder to remove the pulldown and convert the AVCHD file into an "almost raw" ffvhuff/AVI intermediate file.
mencoder $i -fps 60000/1001 -noskip -mc 0 -oac pcm -demuxer lavf -vf  pullup,softskip -ofps 24000/1001 -ovc lavc -lavcopts vcodec=ffvhuff:format=YV12:vstrict=-1:aspect=16/9 -o $INTERMED

## Use ffmpeg to convert intermediate file into a DNxHD/Quicktime file.
ffmpeg -i $INTERMED -vcodec dnxhd -b 36Mb -f mov -acodec copy $FINAL

## Remove the huge intermediate file (keeps the current partition from filling up).
rm -v $INTERMED

done
This script works well, however, like the original mffpeger script, it slows down to a crawl during the ffmpeg stage. It seems to be very CPU intensive to compress the "raw" AVI files into the DNxHD/Quicktime files.

I wish that I could do it all in mencoder, like the speedy pu-avchd script. It is supposed to be possible, but I haven't found a way.

Another possible method would be to pipe raw video from mplayer/mencoder into ffmpeg (as discussed earlier in this thread), but I haven't been able to make that work either.

If anyone knows how to accomplish this entirely in Mencoder (or by piping mplayer into ffmpeg) , please chime in.

By the way, I am using mplayer SVN-r29694 and ffmpeg version SVN-r19923, on Sidux64.
h-munster is offline  
Old 10-24-2009, 06:56 PM
Member
 
0ctane's Avatar
 
Join Date: Aug 2004
Location: Zionsville, IN
Posts: 130
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Quote:


By the way, Apple does not support AVCHD on their PowerPC machines, so this is one of the free/easy ways to get AVCHD to work with FCP on a G4/G5. One can also import AVCHD onto PowerPC machines by using Toast, Voltaic and Cineform.

Well, this is why Axel and I originally created this thread and the scripts. I am glad to see that people are still finding it useful (and making improvements). Still, it is sad that Apple did not choose to natively support AVCHD in Tiger or Leopard (or now even Snow Leopard) so that all Mac users could have some AVCHD love, but I imagine this might have something to do with licensing the AVCHD trademark from Sony and Panasonic. Clearly, it is not a technical hurdle.

0ctane is offline  
Old 10-25-2009, 02:34 PM
Member
 
h-munster's Avatar
 
Join Date: Jan 2009
Location: Hollywood, CA
Posts: 40
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
@0ctane
If you or Axel could suggest how to convert the mffpeger10-1-09 script into a single mencoder command, it would be highly appreciated.

Here's what I tried so far (and it failed):
Code:
mencoder input_file.mts -o output_file.mov -noskip -mc 0 -oac lavc -demuxer lavf -vf pullup,softskip -ovc lavc -lavcopts acodec=libfaac:abitrate=256:vcodec=dnxhd:aspect=16/9 -of lavf -lavfopts format=mov -fps 60000/1001 -ofps 24000/1001
I think that we're on the verge of a really fast and simple solution.

Thanks,
-Dale
h-munster is offline  
Old 10-26-2009, 05:24 AM
Member
 
0ctane's Avatar
 
Join Date: Aug 2004
Location: Zionsville, IN
Posts: 130
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Quote:
Originally Posted by h-munster View Post

@0ctane
If you or Axel could suggest how to convert the mffpeger10-1-09 script into a single mencoder command, it would be highly appreciated.

Sorry, Dale, but I don't use mencoder. Maybe Axel does.

0ctane is offline  
Old 10-26-2009, 02:33 PM
Member
 
oldcpu's Avatar
 
Join Date: Feb 2009
Location: Europe
Posts: 65
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
While I note Sony Vegas (under MS-Windows) and kdenlive (under Linux) can process some raw .mts files, I also notice handling such large files can slow down those editors. If one knows in advance their output format is to be much smaller (in terms of bit rate and resolution) then one can obtain an improved video editing experience by reducing the video format before editing.

Under openSUSE-11.1 Linux, I use the following ffmpeg commands to reduce the videos with a .mts extension (I run these against a complete directory, converting all files in the one directory in one go):

avi to 1280x720 @ 8MB bit rate
Code:
for i in *.mts; do ffmpeg -y -i "$i" -f avi -vcodec mpeg4 -b 8000000 -acodec ac3 -ab 128000 -s 1280x720 year_month_day_${i/%mts/avi}; done
dvd format mpeg in PAL
Code:
 for i in *.mts; do ffmpeg -y -i "$i" -target pal-dvd year_month_day_dvd_${i/%mts/mpg}; done
pal-svcd format mpeg in PAL
Code:
for i in *.mts; do ffmpeg -y -i "$i" -target pal-svcd year_month_day_svcd_${i/%mts/mpg}; done
pal-vcd format mpeg in PAL
Code:
for i in *.mts; do ffmpeg -y -i "$i" -target pal-vcd year_month_day_vcd_${i/%mts/mpg}; done
The above are just examples that I use. One can tune these as they feel appropriate to obtain the exact output that they wish.

Dependant on one's PC, these can be very quick, or very slow. For example on my Intel Core i7 920 PC (w/6GB RAM and a SATA hard drive), an entire directory of video files is converted very quickly. However on my older 32-bit athlon-1100 PC (w/1GB RAM and an older IDE drive) it takes MUCH longer to convert.
oldcpu is offline  
Old 10-28-2009, 11:37 PM
AVS Special Member
 
Shadow_7's Avatar
 
Join Date: Dec 2008
Posts: 1,311
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 11
Quote:
Originally Posted by h-munster View Post

Just curious, why is libx264 is better than mpeg4? Isn't AVCHD already H264? And isn't the severe H264 compression the reason why AVCHD is so CPU intensive?

A lot of video cards now contain h.264 decoders. Which makes playback, even on somewhat slow systems possible. h.264 also saves a lot of file space, and is better suited for distribution over a network / internet. Not that I know if Linux drivers have access to said h.264 hardware (yet). But there's other performance gains to be had with a decent video card besides a hardware decoder.

I went with a non-AVCHD camcorder. At the time of my choice, xport.exe and friends were the only linux option. Which took 15x's + the length of the footage and required about 700GB of temp files per HOUR of footage. i.e. Not worth the hassle. My AVC1/H.264 MP4 format FH1 camcorder processes in only about 4x's the record time. The only temp files are for audio since ffmpeg still kind of sucks for AAC.

On the flip side, I've been starting to use high quality mpeg4 files, and my 720p30 mpeg4 files are about the same size as my 1080p60 source files. The only gain is that I can actually play the 720p30 files on my computer(s) in real time.
Shadow_7 is offline  
Old 11-06-2009, 07:03 PM - Thread Starter
Senior Member
 
Axel Olmos's Avatar
 
Join Date: Sep 2001
Location: Oakland, CA USA
Posts: 295
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
My apologies to everyone for being a bad shepherd of this project. My spare time recently has been very minimal.

Since I started this thread two years ago, some significant improvements have been made to ffmpeg, mplayer, and the Nvidia drivers under Linux.

In particular, mplayer now plays .m2ts files directly,
and the Nvidia vdpau HD decoding acceleration in mplayer means slow CPUs should be able to playback the files.

Has anyone been able to playback the sample .m2ts file in my kit using mplayer without converting it first? When I try to play it directly with mplayer, the speed and lip sync are all wrong.

I updated the http://www.olmosconsulting.com/m2ts.tar.gz file to work with the newer versions of ffmpeg, etc. I ran ./install on CentOS today and it played the test video, and the lip sync looked good, although I'm not sure if it was perfect. It's definitely the best it's looked.

It seems to me that we should be able to play the .m2ts files directly with mplayer if the options are right, and converted using mencoder, thus eliminating all the other steps. If that's the case, my kit is now obsolete.

Anyone have any success?
Axel Olmos is offline  
Old 11-10-2009, 11:44 PM
Member
 
h-munster's Avatar
 
Join Date: Jan 2009
Location: Hollywood, CA
Posts: 40
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Axel,

Canon .mts files seem to play more smoothly when adding the "-demuxer lavf -vc ffh264" flags to the mplayer command line.

Ffplay seems to play .mts files with some stuttering.

I am more interested in being able to transcode and remove the Canon 24FP pulldown, with a single, speedy command. I have been able to do just that with the mencoder command in the pu-avchd script (shown above in post #157), but I can't seem to make the "intermediate quality" codecs (such as DNxHD) work in mencoder.

Currently, I am using the mffpeger10-1-09 script shown above, but the ffmpeg stage of the process is excruciatingly slow.

Do you have any suggestions?

Thanks,
-Dale
h-munster is offline  
Old 11-11-2009, 08:15 PM
Member
 
0ctane's Avatar
 
Join Date: Aug 2004
Location: Zionsville, IN
Posts: 130
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Looks like original spam post I was making fun of has ben removed....

0ctane is offline  
Old 01-07-2010, 03:58 AM
Newbie
 
VorplForsField's Avatar
 
Join Date: Jan 2010
Posts: 2
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
I am new to the video editing world. My camera shoots in Canon's AVCHD format.
I have keyboard scars on my forehead from days of trying to find a conversion that will retain the quality of the footage, and nothing I had found can touch what you have provided here. I need the files to be edited across several applications ncluding Cinelerra, which has proven to be the most finicky. Thanks to the information, and the script found in this thread, this is now possible. I have edited the script to use the H.264 codec on the final .mov output, though I'm sure mpeg4 would have worked just fine. Also, for convenience of batch processing I place 2 folders in the same directory as the script. One directory for the files to be converted, and another directory for the converted files to be output into. Here is a copy of the edited script. Please make note of the file names contained within for those intent on using this script.

Thanks for the wonderful information



Code:
#!/bin/bash

## mffpeger10-1-09 -- remove the Canon AVCHD 24FP->60I pulldown in mencoder, then convert it to DNxHD/Quicktime in ffmpeg.
##
## mencoder's "pullup" filter is used to remove the pulldown on Canon 24FP AVCHD files
##
## Please send any modified versions of this script to me at h_munster@gmx.com.
## Thanks, -Dale

## If you have a multi-core CPU, and would like to speed up the conversion
## process, change this to the number of cores you would like to dedicate
## to both the mencoder and ffmpeg encoding processes
CPUCORES='1'

## Put files to be converted in this directory
INPUTDIR='./Convert-INPUT/'

## The converted files will be placed in this directory
OUTPUTDIR='./Convert-OUTPUT/'

for i in ${INPUTDIR}*mts;
do

ORIGINAL=`basename $i .mts`
INTERMED=${INPUTDIR}${ORIGINAL}.avi
FINAL=${OUTPUTDIR}${ORIGINAL}.mov

## Use mencoder to remove the pulldown and convert the AVCHD file into an "almost raw" ffvhuff/AVI intermediate file.
mencoder $i -fps 60000/1001 -noskip -mc 0 -oac pcm -demuxer lavf -vf pullup,softskip -ofps 24000/1001 -ovc lavc -lavcopts threads=${CPUCORES} vcodec=ffvhuff:format=YV12:vstrict=-1:aspect=16/9 -o $INTERMED

## Uncomment to Use ffmpeg to convert intermediate file into a DNxHD/Quicktime file.
## ffmpeg -i $INTERMED -vcodec dnxhd -b 36Mb -f mov -acodec copy $FINAL

## Uncomment to Use ffmpeg to convert intermediate file into a H.264/Quicktime file.
ffmpeg -i $INTERMED -threads ${CPUCORES} -vcodec libx264 -b 36Mb -f mov -acodec copy $FINAL

## Remove the huge intermediate file (keeps the current partition from filling up).
rm -v $INTERMED

done
VorplForsField is offline  
Old 01-09-2010, 09:26 AM
 
flipconverter's Avatar
 
Join Date: Jan 2010
Posts: 1
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Thanks
flipconverter is offline  
Old 01-10-2010, 03:12 PM
Newbie
 
VorplForsField's Avatar
 
Join Date: Jan 2010
Posts: 2
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
I edited the code in my previous post #171 to allow you to set how many cores you would like to use for encoding. Will greatly speed up the converter for those with multi-core CPU's.
VorplForsField is offline  
Old 06-02-2010, 08:57 PM
 
timili's Avatar
 
Join Date: Mar 2010
Posts: 12
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Is there a good way to convert AVC-HD camcorder video mts file to AVI?
timili is offline  
Old 06-03-2010, 08:59 AM
Member
 
0ctane's Avatar
 
Join Date: Aug 2004
Location: Zionsville, IN
Posts: 130
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Quote:
Originally Posted by timili View Post

Is there a good way to convert AVC-HD camcorder video mts file to AVI?

On how many separate threads are you going to promote this? Please go away.

0ctane is offline  
Old 12-22-2010, 10:28 AM
Newbie
 
nlamarra's Avatar
 
Join Date: Dec 2010
Posts: 1
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
mplayer properly decodes video from .TS file, but defaults to 2-ch audio over HDMI, whereas my ALSA device=hw:0,7 allows 5.1-ch audio (e.g., "speaker-test -D hw:0,7 -c6").

I've tried: "mplayer -ao alsa:device=hw=0.7 file.TS", but this doesn't help.

Does anyone know how can I get mplayer to recognize 5.1-ch audio and output it to HDMI?

I'm running Ubuntu 10.10 on i7-950 with nVidia GT240 over HDMI to Sony.

Thanks
nlamarra is offline  
 
Thread Tools


Forum Jump: 

Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off