PDA

View Full Version : command line for ffmpeg to convert mkv to mpeg2 and keep ac3 to play on ps3


jamos
8th January 2008, 22:29
many of you know how hard it is to use all the multitudes of programs out there to convert mkv files to play on the ps3 and still keep quality as well as ac3 audio. With the great addition of mkv2vob I have found it is a great program and takes hardly anytime remuxing mkv's to vobs so they can play on the ps3. This works well and is very user friendly and fast. unfortunatley the resulting vob cannot be played on your pc by most media players, and when it is played on the ps3 the ff/rw is disabled making it a pain to watch a longer video. (it seems when you change the lvl down to 4.1 it messes with playback).

my alternative is quite simple. Just use ffmpeg and use a command line similar to mine.

ffmpeg.exe -i "F:/video.mkv" -vcodec mpeg2video -sameq -acodec copy -f vob -copyts -y "f:/video.mpg"

where video.mkv is your mkv file.
and video.mpg is your output.
-sameq uses the same bitrate/quality as the source video.
-copyts seems to fix some audio sync issues with problem mkv files.
-y overwrites target file.

Downside is the file is larger than the original by about 50% and you are transcoding it which means you may lose a little quality, but other than that it plays and looks fine on your pc or your ps3, and on the ps3 ff/rw work:)

enjoy all..

edit: updated to use the same bitrate as source instead of fixing it to 20k.

jamos
9th January 2008, 02:01
skipping was due to using a wireless media server. apparently the overloaded mpeg2 stream uses more bandwith than it can handle. when i copy it down to my ps3 it plays fine without skips.:cool:

fonkee1
9th January 2008, 02:42
Does this work on 720p and 1080p files? Thanks

buzzqw
9th January 2008, 08:18
Does this work on 720p and 1080p files? Thanks

works with whatever resolution is the input file

the output file will have same resolution, same audio codec (attention to dts/aac audio) and framerate of 23.976
(if your source is pal just change "-r 23.976" to "-r 25.000" )

BHH

tot31
9th January 2008, 12:14
thanks jamos, it works great for me, although it takes a few hours but having ff/rw really worth the time.

jamos
9th January 2008, 16:55
also the -copyts option seems to fix a bug with audio sync issues due to dts.

tot31
9th January 2008, 17:40
I've just done with a 5.49GB mkv (h264/ac3) file (the first attempt was with 171MB) and the final mpg file size is 9.82GB, that's definitely more than 50% increment. Anyway I'm really happy as it plays fine on my PS3 i.e FF/RW works, stop and continue play work. Now, should I delete the original mkv?

jamos
9th January 2008, 18:13
I've just done with a 5.49GB mkv (h264/ac3) file (the first attempt was with 171MB) and the final mpg file size is 9.82GB, that's definitely more than 50% increment. Anyway I'm really happy as it plays fine on my PS3 i.e FF/RW works, stop and continue play work. Now, should I delete the original mkv?


may just as well as it saves you space and you can play the new file on your pc also. and the 50% increase was just a guess based on what I have tried. depending on the source video/audio it can be more.

fonkee1
9th January 2008, 18:21
In the immortal words of the the great reporter from Khazikstan, Mr. Borat Sagdyiev, "GREAT SUCCESS!". Thanks for the tip Jamos! The command line worked on my 1080p mkv file to mpeg2 whereas mkv2vob (no knock on it ;-) would produce an out-of-sync audio file.

jamos
9th January 2008, 18:24
In the immortal words of the the great reporter from Khazikstan, Mr. Borat Sagdyiev, "GREAT SUCCESS!". Thanks for the tip Jamos! The command line worked on my 1080p mkv file to mpeg2 whereas mkv2vob (no knock on it ;-) would produce an out-of-sync audio file.

I think its the -copyts that fixes issues with that.

Glorioso
9th January 2008, 19:59
How can i use it to hardcode subtitles?

jamos
9th January 2008, 20:04
How can i use it to hardcode subtitles?

-scodec copy

copies subtitles from source.

tot31
10th January 2008, 00:43
Just did another mkv 7.89GB and the final mpeg2 result is 14.6GB. If I were to convert all my 253GB mkvs to mpeg2 then I need a new 500GB HDD... :D -scodec copy doesn't work though.

jamos
10th January 2008, 02:17
Just did another mkv 7.89GB and the final mpeg2 result is 14.6GB. If I were to convert all my 253GB mkvs to mpeg2 then I need a new 500GB HDD... :D -scodec copy doesn't work though.

I never tried -scodec copy just saw it was a option..may also have to use other options.

Quatre
10th January 2008, 05:05
many of you know how hard it is to use all the multitudes of programs out there to convert mkv files to play on the ps3 and still keep quality as well as ac3 audio. With the great addition of mkv2vob I have found it is a great program and takes hardly anytime remuxing mkv's to vobs so they can play on the ps3. This works well and is very user friendly and fast. unfortunatley the resulting vob cannot be played on your pc by most media players, and when it is played on the ps3 the ff/rw is disabled making it a pain to watch a longer video. (it seems when you change the lvl down to 4.1 it messes with playback).

my alternative is quite simple. Just use ffmpeg and use a command line similar to mine.



where video.mkv is your mkv file.
and video.mpg is your output.
-r 23.976 is the NTSC framerate format (use 25 for pal formatted sources).
-sameq uses the same bitrate/quality as the source video.
-copyts seems to fix some audio sync issues with problem mkv files.
-y overwrites target file.

Downside is the file is larger than the original by about 50% and you are transcoding it which means you may lose a little quality, but other than that it plays and looks fine on your pc or your ps3, and on the ps3 ff/rw work:)

enjoy all..

edit: updated to use the same bitrate as source instead of fixing it to 20k.

just rename the .vob that mkv2vob produces to .m2ts or .mpg and they play on the pc. I do this to test and make sure the file is working before transferring to the ps3. sometimes I leave it as .mpg or .m2ts which also still work with that extension on ps3. There might even be other extensions that work on both pc and/or ps3 but I know renaming the vob to either of those 2 works on both. I guess it depends what codecs and stuff you have on your pc also but renaming the .vob to .mpg should work on most any pc. Just dont get confused that it is actually a mpeg-2 when its not.

anyway I really need ff/rw and dont mind it taking a few hours or the larger file size. mkv2vob worked fine for me for transcoding to mpeg-2 with no audio sync issues and it in fact has an option now to force transcode to mpeg-2 even if it is an mkv that can be muxed to vob but, if mkv2vob really gives some audio sync issues on some mpeg-2 sometimes then maybe I will try this.

thanks.

jamos
10th January 2008, 06:40
just rename the .vob that mkv2vob produces to .m2ts or .mpg and they play on the pc. I do this to test and make sure the file is working before transferring to the ps3. sometimes I leave it as .mpg or .m2ts which also still work with that extension on ps3. There might even be other extensions that work on both pc and/or ps3 but I know renaming the vob to either of those 2 works on both. I guess it depends what codecs and stuff you have on your pc also but renaming the .vob to .mpg should work on most any pc. Just dont get confused that it is actually a mpeg-2 when its not.

anyway I really need ff/rw and dont mind it taking a few hours or the larger file size. mkv2vob worked fine for me for transcoding to mpeg-2 with no audio sync issues and it in fact has an option now to force transcode to mpeg-2 even if it is an mkv that can be muxed to vob but, if mkv2vob really gives some audio sync issues on some mpeg-2 sometimes then maybe I will try this.

thanks.


Yes, now mkv2vob does everything I have here and more. I would suggest everyone to use that now.:cool:

Quatre
10th January 2008, 08:49
yeah but i still have a whole season of tv eps in mkv that cant be transcoded to mpeg-2 and its the only hd version available. I'm trying to find out the quicker way to convert mkv into mp4 cus using Super it takes almost as long as wmv.

3r1c
10th January 2008, 21:24
-r 23.976 is the NTSC framerate format (use 25 for pal formatted sources).


or just remove the -r option completely to use same as source.
ffmpeg can detect the frame rate of mkv just fine.
its only needed if the input is a raw h264.

jamos
12th January 2008, 04:08
or just remove the -r option completely to use same as source.
ffmpeg can detect the frame rate of mkv just fine.
its only needed if the input is a raw h264.

true the -r is redundent for mkv files, I accidently left it on the command line when i posted it above.

simontink
16th January 2008, 14:22
Hopefully this will fix the audio sync issues. Hope that the 1080 resolution is retained.

jamos
17th January 2008, 01:19
Hopefully this will fix the audio sync issues. Hope that the 1080 resolution is retained.

it should be, run mkvinfo on your original mkv file and see what the resolution says that will tell you what the original is.

simontink
17th January 2008, 16:48
With this comand line I'm getting
error non monotone timestamps 7650 >= 7650
av_interleaved_Write_frame<>: error opening file
The original MKV plays fine and in sync on VLC

jamos
18th January 2008, 01:58
With this comand line I'm getting
error non monotone timestamps 7650 >= 7650
av_interleaved_Write_frame<>: error opening file
The original MKV plays fine and in sync on VLC

usually that means it cannot open the mkv file maybe because your source is dts not sure.

simontink
18th January 2008, 16:36
Thanks Jamos.
Yes I've tried a couple of smaller sample 1080 mkv's with this command line and they run through fine and in sync but using mkv2vob its way out of sync and this command line doesn't seem to like the file at all.

jamos
18th January 2008, 19:31
Thanks Jamos.
Yes I've tried a couple of smaller sample 1080 mkv's with this command line and they run through fine and in sync but using mkv2vob its way out of sync and this command line doesn't seem to like the file at all.


you may want to use mkvextract and extract the elementary streams then use mkvmerge to merge them back into a mkv, it may fix whatever issues the original mkv has. if not then I would say your mkv has some issues with its elementary streams.

jamos
19th January 2008, 05:09
here are two screenshots one from the original mkv the other from the mpeg2 vob conversion. Image quality is very very close. Can you tell which is which? point is that image quality is about the same.

http://img252.imageshack.us/img252/7112/vlcsnap7118587gx8.th.png (http://img252.imageshack.us/my.php?image=vlcsnap7118587gx8.png)

http://img256.imageshack.us/img256/8370/vlcsnap7116697rs9.th.png (http://img256.imageshack.us/my.php?image=vlcsnap7116697rs9.png)

simontink
21st January 2008, 18:17
My original MKV has DTS Audio. I think that could be the problem when using this command line. It would be a great help if the ffmpeg copyTS could be included in mkv2vob that could solve the audio sync problem with the 1080 files presumably it would be a fairly simple revision to make ?

jamos
21st January 2008, 20:36
My original MKV has DTS Audio. I think that could be the problem when using this command line. It would be a great help if the ffmpeg copyTS could be included in mkv2vob that could solve the audio sync problem with the 1080 files presumably it would be a fairly simple revision to make ?

I would think it would be but who knows he may already be doing it?

It would only work when transcoding into mpeg2 (not just remuxing which doesnt really work on 1080p videos anyways).

I am thinking of writing a guide on how to covert mkv to mpeg2 and include dts to ac3 steps.

jamos
21st January 2008, 20:38
With this comand line I'm getting
error non monotone timestamps 7650 >= 7650
av_interleaved_Write_frame<>: error opening file
The original MKV plays fine and in sync on VLC
thats probably cause your source is dts and your trying to copy it. you could convert it directly to ac3 with ffmpeg but when i have tried it the center channel seems to go to my left speaker.

hexperience
22nd January 2008, 03:59
Would using -b {bitrate} rather than -sameq allow me to adjust the file size? I'd like to try to keep a dvd9 sized file so that it would still fit on a dvd9.

I know there might be some loss, but to my uneducated eye ball, mpeg2 looks better than re-encoding to AVC again.

jamos
22nd January 2008, 19:24
Would using -b {bitrate} rather than -sameq allow me to adjust the file size? I'd like to try to keep a dvd9 sized file so that it would still fit on a dvd9.

I know there might be some loss, but to my uneducated eye ball, mpeg2 looks better than re-encoding to AVC again.


you could downgrade the bitrate but it would be trial and error to get the size you need, I would start out with -b 9000 and see what that gets you, and yes remove the -sameq part.

mmace
27th January 2008, 21:06
jamos, thanks a million for this, I've never used command lines for anything before and have really needed to pause/rewind/fastforward things (got a baby so can never watch without interruptions!). You're a lifesaver, thanks for this

hexperience
29th January 2008, 00:46
you could downgrade the bitrate but it would be trial and error to get the size you need, I would start out with -b 9000 and see what that gets you, and yes remove the -sameq part.

Yep, -b 6000 got me about the same file size as the orginal mkv.

Quick question, it worked perfectly on one I tried, but I then tried to make a "mini-blu-ray" using tsremux. The results played, but the video on my samsung player was only a couple of inches wide, and on the PS3 it was mostly green.

I know, it's a bit off the thread topic, just wondered if you or anyone has tried moving the result files to Disc in some way.

Cheers

jamos
29th January 2008, 00:54
Yep, -b 6000 got me about the same file size as the orginal mkv.

Quick question, it worked perfectly on one I tried, but I then tried to make a "mini-blu-ray" using tsremux. The results played, but the video on my samsung player was only a couple of inches wide, and on the PS3 it was mostly green.

I know, it's a bit off the thread topic, just wondered if you or anyone has tried moving the result files to Disc in some way.

Cheers

If your using a disc better to just remux the mkv into a m2ts file using tsmuxer then use tsremux to convert it into bluray format. there are plenty of threads on doing that I think and your file size will be about the same as your mkv.

morpheus0815
1st February 2008, 10:31
@mmace,

you may want to check out the mkv2vob thread again. Latest version also supports ff/rw ;-)

mmace
5th February 2008, 22:37
can you tell me what command line to use to convert the audio to AC3 5.1?

I have a WMV-VC1 file (1080p) with WMA 5.1 audio, I assume the command lines will be ok to convert the video but I wondered how to do the audio?

morpheus, cheers for that, I noticed later in the day that it had been updated, and now has forced MPEG encoding (good for me as I burn my own BD-R's

tyee
10th February 2008, 22:25
Anyone know if ffmpeg can transcode an evo or m2ts to h264/avc for us. I've read bits and pieces here and there and I saw a -h264 switch in a command line somewhere but just wondering if anyone has even tried it yet??

jamos
11th February 2008, 03:08
Anyone know if ffmpeg can transcode an evo or m2ts to h264/avc for us. I've read bits and pieces here and there and I saw a -h264 switch in a command line somewhere but just wondering if anyone has even tried it yet??

it should its a pretty powerful and quick transcoder. for m2ts i would just use tsmuxer to ts.