Mts in mp4 linux

1. What I tried

I have some .MTS (AVCHD format) files recoreded with my AVCHD camera. Its specification is as shown below:

$ ffprobe 140612_Canon-00000.MTS ffprobe version 2.2.1 Copyright (c) 2007-2014 the FFmpeg developers (snip) Input #0, mpegts, from '140612_Canon-00000.MTS': Duration: 00:48:58.40, start: 0.800300, bitrate: 5563 kb/s Program 1 Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p, 1440x1080 [SAR 4:3 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 256 kb/s 

Pay attention to the part of framerate/timebase: 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc Now I’d like to convert this file to .mp4 file, without re-encoding H264 video stream, on the other hand, with transcoding its audio stream to AAC. So I tried the following command: ffmpeg -i 140612_Canon-00000.MTS -t 60 -y -vcodec copy -acodec libfaac -ab 128k 140612_Canon-00001.MTS.mp4

2. Result

$ ffprobe 140612_Canon-00000.MTS.mp4 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '140612_Canon-00000.MTS.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf55.33.100 Duration: 00:01:00.04, start: 0.021333, bitrate: 4590 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1440x1080 [SAR 4:3 DAR 16:9], 4448 kb/s, 59.94 fps, 59.94 tbr, 90k tbn, 59.94 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default) Metadata: handler_name : SoundHandler 

Look at the part of framerate/timebase: 59.94 fps, 59.94 tbr, 90k tbn, 59.94 tbc. Although ffmpeg just copied the video stream, framerate and timebase has been changed to twice value. So, when I open and playback the output file with QuickTime Player or VLC Player, the audio has no problem, however, the video stream is not played correctly. The video is played back with having its frame forward and backward quiveringly repeatedly.

3. Question

  1. How can I convert .MTS file (AVCHD) to .mp4 by ffmpeg without re-encoding H264 video stream correctly?
  2. How can I keep the original framerate/timebase values (fps/tbr/tbn/tbc) when I convert the container with ffmpeg and its -vcodec copy switch.
  3. How can I set framerate/timebase values (fps/tbr/tbn/tbc) by ffmpeg’s command line options without re-encoding a video stream.

4. Adding -r 29.97 option

Professor Sparkles gave me an advice to add -r 29.97 . I tried that:

ffmpeg -i 140612_Canon-00001.MTS -t 60 -r 29.97 -y -vcodec copy -acodec libfaac -ab 128k 140612_Canon-00001.MTS.mp4 

However, the output file has still wrong framerate/timebase:

Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1440x1080 [SAR 4:3 DAR 16:9], 4448 kb/s, 59.94 fps, 59.94 tbr, 11988 tbn, 59.94 tbc (default) 

5. Remux using MP4Box

I tried demux and remux using MP4Box, according to Professor Sparkles’s advice.

brew install mp4box ffmpeg -i 140612_Canon-00000.MTS -t 60 -y \ -vcodec copy -an 140612_Canon-00000.MTS.h264 ffmpeg -i 140612_Canon-00000.MTS -t 60 -y \ -vn -acodec libfaac -ab 128k 140612_Canon-00000.MTS.aac mp4box -add 140612_Canon-00000.MTS.h264:fps=29.97 \ -add 140612_Canon-00000.MTS.aac \ -new 140612_Canon-00000.MTS.mp4 
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '140612_Canon-00000.MTS.mp4': (snip) Duration: 00:02:00.22, start: 0.000000, bitrate: 2293 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1440x1080 [SAR 4:3 DAR 16:9], 2228 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default) Metadata: creation_time : 2014-07-14 00:38:23 handler_name : 140612_Canon-00000.MTS.h264:fps=29.97 - Imported with GPAC 0.5.0-rev4065 Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 125 kb/s (default) 

It looks a bit step forward. Look at the part of framerate/timebase: 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc. Those are match to the original stream, except for tbn (timebase value from container).

Читайте также:  Линукс войти под рутом в

However, when I play back the output file with Quicktime Player or VLC, the video is play back at the half speed.

Although the original file has 90k tbn (90000 ticks per second) and the new output file from MP4Box has 30k tbn which is just one-third value of original one, the output file is play back at the half speed.

I don’t know the reason why. But I think the rest issue is how I can adjust the tbn value.

5-b. MediaInfo’s report on the output file

I also tried MediaInfo tool on the output file generated by 5. Remux using MP4Box. The output is here: https://gist.github.com/kaorukobo/c5ab9eaa413dff6cd26a

6. Trying avconv

Volodya reported avconv worked well. Also I prepared a short sample movie file (Canon-00006.MTS) recorded with the same camera. Okay, let’s try:

brew install avconv avconv -i Canon-00006.MTS -c:a copy -c:v copy -y Canon-00006.MTS.mp4 ffprobe Canon-00006.MTS.mp4 

The output file’s ffprobe information is here: https://gist.github.com/kaorukobo/5b53244ade2632ff1211 and its framerate/timebase information is as the following: 59.94 fps, 59.94 tbr, 90k tbn, 59.94 tbc

The output file was played back well with VLC Player as Volodya reported. However, opening it with Quicktime Player X, the video was play back at the normal speed but with having its frame backward quiveringly repeatedly.

7. Why «Free AVCHD to MOV» app work?

As I mentioned in my previous comment, Free AVCHD to MOV app’s «rewrap to MOV» feature worked well, even though it makes not MP4 but MOV.

The software calls its own ffmpeg (or avconv) program internally, and I saw what options are passed to it. It’s as shown below:

/Applications/Free AVCHD to Mov.app/Contents/Resources/bin/com.geranium-soft.convert \ -i /path/to/140710_Canon-00003.MTS \ -map 0:0 -map 0:1 -c:a libfaac -vol 256 -b:a 128k -c:v copy \ -sn -movflags faststart -threads 0 -pix_fmt yuv420p -y \ /path/to/140710_Canon-00003.mov 

I tried passing same options (Extractly same. I set the output container type to MOV and removed even -t 60 switch.) to ffmpeg program and converting. But the result was same as reported so far.

Anyway that great app resolved my issue on «How can I convert .MTS file (AVCHD) to .mp4 without re-encoding H264 video stream?», except at «to .mp4» and «by ffmpeg». But I’m still interested in why that app do well but ffmpeg don’t.

What do you mean by «correctly»? Maybe remove that from the title. I would like to help but I have never used ffmpeg. I just use the adobe tools media encoder.

4 Answers 4

Seeing that in the text of your question you have started discussing other utilities, i will assume that you are not interested in sticking with ffmpeg, but rather in getting the job done.

Читайте также:  Astra linux пакет ca certificates

In my experience with libav and MTS i have had no problems with the framerate, the files get remuxed perfectly.

I have just attempted the following with one of my files:

avconv -i 00174.MTS -c:a copy -c:v copy 00174.mp4 

The resulting MP4 file played correctly with VLC.

My file is progressive MTS, i don’t have any interlaced laying around, but if need be i can do more checking with that.

Report about the file test

The topic starter was able to provide a file, that was remuxed from MTS to MP4 and did not play on that person’s machine with QuickTime Player (version unknown). It did, however, play with that individual’s VLC player.

I do not have a Mac OS computer, but i have tried it with Ubuntu. I have played it on Ubuntu on VLC (2.0.8) and GNOME Videos (used to be called Totem) (3.8.2); both play perfectly.

I then asked a friend of mine, who is on a Mac to play it. He is on Mavericks (10.9.4), and it played fine with QuickTime Player 10.3 (727.4).

At this time it appears to be a problem with the particular player or a problem with configuration settings on the computer. And it is probably best to attempt to update to the newest version of QTP, possibly with first removing the current version and completely wiping the old configuration.

Another possibility

When i have had an old machine i have had some high bitrate files play incorrectly in some players, and it was container specific. For example, VLC would refuse to play MTS file, it would show a frame, and then show the next one only in a second and a half. GNOME Videos played it fine. But when remuxing it to MKV, both players played it reasonably well. This maybe a question of something similar. A player maybe reading a particular container (MP4 in this case) in a way that requires just enough CPU time, that it begins to choke itself. The jerkiness effect can be then attributed to whatever subprocess takes up CPU finishing, and player dumping all of the frames that were lagging behind very rapidly, after that the bad subprocess again kicks in, and the cycle keeps on going.

In this possibility, the best option is still to try to upgrade the software. With the current multicore processors it would be difficult to test the need to upgrade the hardware without actually getting it, but maybe it is possible to look at the CPU load during the QuickTime Player useage and compare it to VLC. If you see 100% for any one core with QTP, that maybe indicative of this.

Источник

Как преобразовать файл MTS в формат MP4 в Linux

Моя трехлетняя видеокамера — Canon Vixia HF100. Благодаря оптически стабилизированному зум-объективу с 12-кратным увеличением он обеспечивает отличное качество видео. Однако есть одно предостережение относительно видеокамеры: видеофайлы сохраняются в формате AVCHD, который представляет собой видеоформат HD, разработанный Sony и Panasonic. Видео AVCHD обычно имеют расширения файлов .mts или .m2ts .

Поскольку формат AVCHD не является распространенным видеоформатом, используемым для обмена видео в Интернете, файлы MTS не поддерживаются YouTube. То есть, если вы загрузите видео МТС на YouTube, YouTube откажется его обрабатывать. Если вы хотите загрузить видео MTS на YouTube, вам необходимо сначала перекодировать видео в более популярные видеоформаты, такие как AVI, MP4 или WMV.

Читайте также:  Vmware workstation remove linux

Есть несколько хороших бесплатных транскодеров с открытым исходным кодом, которые могут конвертировать файлы MTS в другие форматы. Среди них Handbrake, пожалуй, лучший с точки зрения удобства использования и скорости. Handbrake свободно доступен для Mac OS, Windows, Ubuntu и Fedora. С помощью Handbrake вы можете легко конвертировать видео MTS в формат MP4.

Сначала загрузите Handbrake и установите его на свою ОС. В Linux вы можете использовать эти инструкции для установки HandBrake. После запуска HandBrake укажите исходный видеофайл и папку назначения. В разделе « Настройки вывода » выберите контейнер « Файл MP4 ». При желании вы также можете настроить видеокодек (h.264/mpeg4/mpeg2), частоту кадров, аудиокодек, а также применить различные фильтры, такие как фильтр деинтерлейсинга.

После того, как вы преобразовали MTS в MP4 с помощью Handbrake, теперь вы можете загрузить преобразованное видео MP4 на YouTube и поделиться им в Интернете.

Источник

How to convert MTS file to MP4 format on Linux

My 3-year old camcorder is Canon Vixia HF100. It delivers excellent quality videos via optically stabilized 12X zoom lens. One caveat of the camcorder, however, is that video files are saved in AVCHD format, which is a HD video format developed by Sony and Panasonic. AVCHD videos typically have .mts or .m2ts file extensions.

Since the AVCHD format is not a common video format used to share videos online, MTS files are not supported by YouTube. That is, if you upload an MTS video to YouTube, YouTube will refuse to process it. If you would like to upload MTS videos to YouTube, you need to transcode the videos into more popular video formats such as AVI, MP4 or WMV first.

There are a few good free and open-source transcoders that can convert MTS files to other formats. Among them, Handbrake is arguably the best in terms of usability and speed. Handbrake is freely available for Mac OS, Windows, Ubuntu and Fedora. With Handbrake, you can convert MTS videos to MP4 format quite easily.

First, download Handbrake, and install it on your OS. On Linux, you can use these instructions to install HandBrake. Once you launch HandBrake, specify a source video file and destination folder. In » Output Settings «, choose » MP4 File » container. If you want, you can also customize video codec (h.264/mpeg4/mpeg2), framerate, audio codec, as well as apply various filters such deinteracing filter.

Once you have converted MTS to MP4 with Handbrake, you can now upload the converted MP4 video to YouTube and share it online.

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Источник

Оцените статью
Adblock
detector