Log in

View Full Version : [MeGUI] Convert AVCHD (m2ts) to mp4/mkv


eXistenZ_69
26th May 2010, 21:28
Hello,

I'm trying to convert AVCHD video's recorded with my Panasonic TZ10 to more common formats like mp4 and mkv with MeGUI but get an error. The video's have the following details:

General
ID : 0
Complete name : C:\temp\20100523(132318).m2ts
Format : BDAV
Format/Info : Blu-ray Video
File size : 10.4 MiB
Duration : 6s 224ms
Overall bit rate : 14.0 Mbps
Maximum Overall bit rate : 18.0 Mbps

Video
ID : 4113 (0x1011)
Menu ID : 1 (0x1)
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4.0
Format settings, CABAC : No
Format settings, ReFrames : 1 frame
Format_Settings_FrameMode : Frame doubling
Duration : 6s 200ms
Bit rate : 13.2 Mbps
Width : 1 280 pixels
Height : 720 pixels
Display aspect ratio : 16:9
Frame rate : 25.000 fps
Original frame rate : 50.000 fps
Standard : NTSC
Resolution : 8 bits
Colorimetry : 4:2:0
Scan type : Progressive
Bits/(Pixel*Frame) : 0.574
Stream size : 9.77 MiB (94%)

Audio
ID : 4352 (0x1100)
Menu ID : 1 (0x1)
Format : AC-3
Format/Info : Audio Coding 3
Duration : 6s 240ms
Bit rate mode : Constant
Bit rate : 192 Kbps
Channel(s) : 2 channels
Channel positions : L R
Sampling rate : 48.0 KHz
Stream size : 146 KiB (1%)

Text
ID : 4608 (0x1200)
Menu ID : 1 (0x1)
Format : PGS
Duration : 5s 692ms

Here's the error:

[Warning] Log
-[Information] Versions
--[NoImage] MeGUI Version : 0.3.4.0
--[NoImage] OS : Windows XP Professional x86 SP3 (5.1.196608.2600)
--[NoImage] Latest .Net Framework installed : 3.5 (3.5.30729.01)
--[NoImage] Avisynth Version : 2.5.7.0
-[Warning] Log for job1 (ext, 20100523(132318).m2ts -> xxx)
--[Information] [26/05/2010 22:11:24] Started handling job
--[Information] [26/05/2010 22:11:25] Preprocessing
--[NoImage] Job commandline: "C:\Video\MeGUI\tools\eac3to\eac3to.exe"
"C:\Documents and Settings\abc\Desktop\20100523(132318).m2ts"
1:"C:\Documents and Settings\abc\Desktop\T1_Video - .mkv"
-progressnumbers
--[Information] [26/05/2010 22:11:25] Extracting started
--[Warning] A warning occurred: v01 The video bitstream framerate
field doesn't seem to match the timestamps.
--[Warning] A warning occurred: The h264 muxer doesn't support this
stream type yet.Please send a 20MB sample to dear@madshi.netGetting
"Haali Matroska Muxer" i
--[NoImage] Standard output stream
---[NoImage] M2TS, 1 video track, 1 audio track, 1 subtitle track,
0:00:06, 25p
---[NoImage] 1: h264/AVC, 720p50 (16:9)
---[NoImage] 2: AC3, 2.0 channels, 192kbps, 48khz
---[NoImage] 3: Subtitle (PGS)
---[NoImage] v01 Extracting video track number 1...
---[NoImage] v01
---[NoImage] v01
---[NoImage] v01 Muxing video to Matroska...
---[NoImage] v01
---[NoImage]
--[NoImage] Standard error stream
--[Information] [26/05/2010 22:11:27] Job completed

The vids are 50fps but the sensor of the camera only outputs 25fps. I guess that's the cause of the error. How should I handle this kind of input?

Greetz,

eXistenZ_69

Inspector.Gadget
26th May 2010, 23:50
Rather than extracting the video, try indexing directly from the transport stream with DGAVCIndex or FFMSIndex.

eXistenZ_69
27th May 2010, 08:45
Hello,

thanks for your reply. Could you elaborate on how to do that exactly, please?

If you mean directly opening the file in the Avisynth Script Creator, that gives me the error "Unable to render the file. You probably don't have the correct filters installed." :confused:

Cheers,

eXistenZ_69

tebasuna51
27th May 2010, 09:38
MEGUI -> Tools -> File Indexer -> Input file: your.m2ts

7ekno
27th May 2010, 10:24
What AVS script are you using?!?

By entering the MTS (obviously you renamed it to M2TS) into the MeGUI "Input" line you force the use of "DirectShowSource" filter as Avisynth input (not entirely appropriate for this source) ...

Your camera generates "50fps" by "faking" the stream, all it does is set "flags" in the MTS file to display each frame twice (has a benefit of looking like "more smooth" motion on LCD/LED screens via halving the image "hold" time) ...

First, you need to decide if you want to keep the duplicated 50 fps (has some minor advantages on LED/LCD HDTVs) or reduce the stream to 25 fps (saving a small amount of space on the encode ~ 10%) ...

The "indexing" feature listed above (in MeGUI) will use DGAVCIndex to index and reference the stream, this will result in a 25 fps encode ...

Your other option is to download the FFMS2 source filter (http://code.google.com/p/ffmpegsource/) for Avisynth (and extract the appropriate files to your Avisynth plugin directory), and write an AVS script for "input" to MeGUI, something like:

FFMpegSource2("blahblah.m2ts")

The above will generate an encode at 50fps with duplicates (as is the original) ...

Tek

eXistenZ_69
27th May 2010, 11:47
Hello,

first of all, thanks to both for your valuable input! :)

What AVS script are you using?!?
I'm not using any AVS script for the moment. I tried creating one with the Avisynth Script Creator of MeGUI, but that fails (see above post).

By entering the MTS (obviously you renamed it to M2TS) into the MeGUI "Input" line you force the use of "DirectShowSource" filter as Avisynth input (not entirely appropriate for this source) ...
The input files are untouched by me. The file extension is like that coming from the camera. I didn't try opening the file in the MeGUI input field directly.

Your camera generates "50fps" by "faking" the stream, all it does is set "flags" in the MTS file to display each frame twice (has a benefit of looking like "more smooth" motion on LCD/LED screens via halving the image "hold" time) ...
Interesting and good to know. Thanks for the info!

First, you need to decide if you want to keep the duplicated 50 fps (has some minor advantages on LED/LCD HDTVs) or reduce the stream to 25 fps (saving a small amount of space on the encode ~ 10%) ...
I prefer going the 25 fps route.

The "indexing" feature listed above (in MeGUI) will use DGAVCIndex to index and reference the stream, this will result in a 25 fps encode ...
Ok, I will try this...

Your other option is to download the FFMS2 source filter (http://code.google.com/p/ffmpegsource/) for Avisynth (and extract the appropriate files to your Avisynth plugin directory), and write an AVS script for "input" to MeGUI, something like:

FFMpegSource2("C:\Documents and Settings\abc\Desktop\20100523(132318).m2ts")

The above will generate an encode at 50fps with duplicates (as is the original) ...

Tek
This would result in real duplicate frames in the output, not references? Correct?

eXistenZ_69
27th May 2010, 22:22
Ok, I tried what you guys suggested. Opening the m2ts file with Tools > DG Creator and then using the resulting dga file in the Avisynth Script Creator gave me the following AVS script:

LoadPlugin("C:\Video\MeGUI\tools\dgavcindex\DGAVCDecode.dll")
AVCSource("C:\Documents and Settings\abc\Desktop\20100523(132318).dga")
#deinterlace
#crop
#resize
#denoise


Then when I use that script to encode with x264 to MP4, I get a video that plays too fast. It's 50 fps, instead of the intended 25 fps. How do I change that?

Greetz,

eXistenZ_69

Inspector.Gadget
27th May 2010, 22:47
Try SelectOdd() as the last line in your Avisynth script. This will serve to x264 only the non-duplicate frames (1,3,5,7, etc.), assuming that DGAVCIndex honors the frame doubling.

eXistenZ_69
27th May 2010, 23:07
I tried adding SelectOdd(). Now the video info indicates 25 fps instead of 50 fps, but it still plays too fast. The file plays exactly the same as the 50 fps file. Also strange is that the last frame is reached in both cases half way of the total play time. Any suggestions? Is the dga file incorrectly generated?

Some other thing, where does the Audio: PCM (AC3) 48000Hz 6ch 192kbps [Output] come from that MPC HC indicates and plays in the resulting MP4? I selected the demux audio streams option in DG Creator, but didn't do any muxing afterwards...

Btw. the audio plays for the full length of the video.

Inspector.Gadget
27th May 2010, 23:30
MPC HC will auto-load audio tracks in the same folder as the video, given similar naming schemes, explaining the audio playback.

Can you upload the M2TS or a similar short one to Mediafire and link it here? I want to try to replicate your workflow and see where the issue lies and I don't have any frame-doubled streams kicking around.

Pringles
27th May 2010, 23:35
I just ran into the same troubles as you are with a Panasonic TZ7 camera as I wanted to upload on facebook my newly recorded videos from Roland Garros :D

Here is what I did:

Open MeGui

Tools: DG Creator / Select your MTS file and demux the audio (not sure if this is necessary but that's how I did) / Enqueue and start job.

Then configure the x264 encoder: Automated 2pass, Turbo, bitrate 5000 (or whatever), Presets=Slower, click OK to exit, Fileformat=MKV, Enqueue, start job.

Tools: Muxer / MKV Muxer.
In the video input, select your newly created mkv file and choose the framerate you want (ie 25fps), select you audio file, enqueue and start muxing.

Your video should playback fine. At least mine are ;) Hope this helps.

eXistenZ_69
27th May 2010, 23:52
@Inspector.Gadget
Good call on the auto-loading of audio tracks. I didn't know of this feature of MPC HC. I turned it off now to avoid confusion. As a result the total playing time of the clip is now half and stops on the last frame. I will upload a short sample later today...

@Pringles
Except for the muxing part in the end, that's what I already did. I just tried the muxing at the end with specifying 25 fps, but the muxed MP4 (tried MKV as well) still runs twice as fast as it should... :(

Pringles
27th May 2010, 23:56
Maybe you should start over, delete all your temp or job files and try exactly what I wrote, because I don't see why a video recorded with a TZ10 would behave differently from one recorded by a TZ7.

Inspector.Gadget
27th May 2010, 23:57
For general compatibility, it's likely better to have the correct FPS on the bitstream itself. Anyway, now I'm interested in a solution from the beginning and it'll be a good thing to add to the knowledgebase :)

Pringles
28th May 2010, 00:25
eXistenZ_69, I uploaded an MTS file directly copied from my Panasonic TZ7 camera.

http://www.megaupload.com/?d=7LLTAF18 (28MB)

Can you convert it into MKV and make it play at a normal speed at 25fps? I just did it with the method I described in my post above.

eXistenZ_69
28th May 2010, 00:34
Here's my sample (32,19MB):

http://www.mediafire.com/?fjzzjmymtmx

eXistenZ_69
28th May 2010, 00:49
@Pringles
I tried encoding your sample and the resulting file also plays too fast. Very strange. Don't know what I'm doing wrong then. It's not player related, cause I tried MPC HC and VLC.

Btw. how come your file is an MTS? What's the difference with M2TS? I noticed that Panasonic PHOTOfunSTUDIO displays my video as MTS file located on the SDHC card during import, but after import it's an M2TS with some other files added in the same folder (.cont, .pmpd, .tmb). Do you get your video directly from the SDHC card?

Guest
28th May 2010, 01:09
Your stream has frame repeat flags. If you are not honoring them just put AssumeFPS(25) at the end of your script. It is that simple.

Ramir Gonzales
28th May 2010, 01:54
Hello,

I'm trying to convert AVCHD video's recorded with my Panasonic TZ10 to more common formats like mp4 and mkv with MeGUI but get an error. The video's have the following details:

Greetz,

eXistenZ_69

Where did you get that Panasonic TZ10 ? :mad:

poisondeathray
28th May 2010, 02:04
Another option is to use ffmpegsource2, which handles the frame repeat flags avchd lite properly

e.g. if you want to pass the audio as well:

FFMpegSource2("video.mts", atrack=-1)

Guest
28th May 2010, 02:07
DGAVCDec and DGDecNV can both deal correctly with the repeated frames but the user must understand what he is doing. Here we have an instance where that is apparently not the case.

eXistenZ_69
28th May 2010, 07:39
Where did you get that Panasonic TZ10 ? :mad:

Why do you ask? :confused:

eXistenZ_69
28th May 2010, 07:44
Your stream has frame repeat flags. If you are not honoring them just put AssumeFPS(25) at the end of your script. It is that simple.

Thanks! That worked great :). But how come user Pringles doesn't have to do this in his work flow?

eXistenZ_69
28th May 2010, 07:50
DGAVCDec and DGDecNV can both deal correctly with the repeated frames but the user must understand what he is doing. Here we have an instance where that is apparently not the case.

Could you explain why the converted video runs too fast? When you say handle correctly, I would think that without AssumeFPS(25) the video should be 50 fps, but running at normal speed... just like playing the original M2TS file :confused:

7ekno
28th May 2010, 08:44
Could you explain why the converted video runs too fast? When you say handle correctly, I would think that without AssumeFPS(25) the video should be 50 fps, but running at normal speed... just like playing the original M2TS file :confused:

Because your input stream is flagged as "50 fps", but the decoder only finds 25 real frames in any given second (remember the "fake" frames set via a flag - the way you are doing it is ignoring the "duplicate" flag), so your encoded stream is flagged as "50 fps" (same as the source), but only ever has 25 real frames in a given second ...

Your playback device see the encode flagged as "50 fps" and tries to play 25 actual frames at 50 fps (hence "double speed") ...

The AssumeFPS(25) just ensures the right "fps" is written to the encoded file :P

To get playback working at 50fps, honor the "duplicate" flags while indexing or use "FFMpegSource2" (which also honors the fake flags and returns 50 frames in any given second) ..

7ek

eXistenZ_69
28th May 2010, 09:13
@7ekno

Thanks for the detailed explanation. Just for future reference and out of curiosity, how would I go about "honoring the duplicate flags while indexing" (without using FFMpegSource2)?

Pringles
28th May 2010, 11:14
@Pringles
I tried encoding your sample and the resulting file also plays too fast. Very strange. Don't know what I'm doing wrong then. It's not player related, cause I tried MPC HC and VLC.

Btw. how come your file is an MTS? What's the difference with M2TS? I noticed that Panasonic PHOTOfunSTUDIO displays my video as MTS file located on the SDHC card during import, but after import it's an M2TS with some other files added in the same folder (.cont, .pmpd, .tmb). Do you get your video directly from the SDHC card?

Yes, I copied my file directly from the SD card.
I just tried my method with your video and it could reencode it with a normal playback.

Guest
28th May 2010, 11:49
Thanks! That worked great :). But how come user Pringles doesn't have to do this in his work flow? I suppose his player is following the container's frame rate rather than the stream's frame rate.

how would I go about "honoring the duplicate flags while indexing" With DGDecodeNV, you would set fieldop=0 (Honor Pulldown Flags).

eXistenZ_69
28th May 2010, 11:51
Yes, I copied my file directly from the SD card.
I just tried my method with your video and it could reencode it with a normal playback.
So you don't use AssumeFPS(25) in your AVS script or anything equivalent? Do you use FFMpegSource2 and keep your encode at 50 fps?

Btw. any particular reason why you get the files from the SD card directly and not via PHOTOfunSTUDIO?

eXistenZ_69
28th May 2010, 11:54
I suppose his player is following the container's frame rate rather than the stream's frame rate.


@Pringles
What player do you use to play the final encoded file? Could you upload a sample of that as well, please?

Pringles
28th May 2010, 13:34
So you don't use AssumeFPS(25) in your AVS script or anything equivalent? Do you use FFMpegSource2 and keep your encode at 50 fps?

Btw. any particular reason why you get the files from the SD card directly and not via PHOTOfunSTUDIO?

The 1st method I used to get a normal playback was to use a timecode file for MKVMerge.

# timecode format v1
assume 25

It worked fine, but I also tried the MeGui integrated MKV muxer which can set the FPS I want for the video stream and it also worked. I stuck with Megui as I don't have to juggle with another app and create the timecode file. So it's simpler.

I copy the files directly from the SD card because once again it's a simpler method and I don't like to install unecessary apps.

I'm using MPC-HC to play my video files.
http://img576.imageshack.us/img576/9493/image1ap.png

Here is the reencoded file with the Megui method:
http://www.megaupload.com/?d=9RF9X097

eXistenZ_69
28th May 2010, 13:45
@Pringles
What do you do exactly after using DG Creator? Do you use the AVS Script it creates as input for the video encoder (x264)? Or do you demux the video and us the raw h264 stream somehow? That's the only thing I can come up with that could be different between what you and I do...

Pringles
28th May 2010, 13:56
I just use the AVS script DG Creator creates. It's actually loaded automatically into Megui. I'm doing exactly what I wrote in my 1st post in this thread, no more no less!
Does my reencoded file plays fine on your computer?

eXistenZ_69
28th May 2010, 14:04
I'm not at home right now, I will check later today. I'm using the same player so I expect it to play at normal speed.

What build of MeGUI do you use? Do you use the patched build by Zathor? Maybe it's a difference in tool versions used by MeGUI... I just downloaded the stable 0.3.3 release from SourceForge and did an auto update. Can't tell till I'm home to what version it updated.

Guest
28th May 2010, 14:20
In MPC-HC the uploaded MKV plays at 25fps. If you demux the video and play that, it plays at 50fps. So that confirms my analysis stated above about the player following the container's frame rate.

eXistenZ_69
28th May 2010, 21:24
After some more experimenting I found the reason why I get a different result from Pringles. When doing the final muxing to MKV and explicitly specifying the frame rate as 25 fps, the player takes this frame rate instead of the one defined in the video stream (just as neuron2 explained). But for some reason this doesn't happen when muxing to MP4! The MP4 muxer ignores the explicitly set 25 fps in the settings. Is this a bug? I must have missed something when initially trying Pringles' workflow, sorry about that :)

What would be the recommended thing to do? Doing the AssumeFPS(25) in the AVS script or overriding the fps on container level? I think AssumeFPS(25) is more reliable, because not dependent on player behaviour.

Guest
28th May 2010, 22:07
What would be the recommended thing to do? Doing the AssumeFPS(25) in the AVS script or overriding the fps on container level? I think AssumeFPS(25) is more reliable, because not dependent on player behaviour. Yes, your reasoning is correct. Then the container and stream will agree, which is certainly a good thing.

smok3
5th June 2010, 15:27
so how exactly are this doubled frames handled in decoder/players? (iam doing downconversion to SD DV and i would like to know if it is of any use to go for 50i?)

eXistenZ_69
6th October 2010, 23:33
Your stream has frame repeat flags. If you are not honoring them just put AssumeFPS(25) at the end of your script. It is that simple.

Hi,

I'm again converting some videos and because it's been a while, I reread this thread. Now I've a new question regarding the position of the AssumeFPS(25) in the script. You mention to put it at the end, is that for a specific reason? I've seen script examples where it is put immediately after loading the source and before any further processing.

Cheers!