View Full Version : VFR h.264 (in MKV) to AVI
edzieba
8th November 2006, 22:13
I recently purchased an Archos 504 (supports xvid, divx, MPEG2, h.264, in avi or mp4 containers). Unfortunately, it cannot play softsubs of any kind (and can't even recognise mkv files as videos).
I've been using this ugly hack method of preparing my softsubbed files for playback:
1) extract raw h.264 stream, audio, and subs with MKVextractgui
2) use avc2avi to put the raw h.264 into an avi container
3) open this with virtualdubmod, and add the audio, subs and resize to 720x480 or equivalent aspect (most of the files are HD).
I've been using xvid to encode because virtualdub doesn't seem to like encoding to h.264, and I don't have enough disc space to output raw and encode elsewhere.
This works fine (though is a long and involved process), except with VFR h.264 files. Avc2avi requires you enter a framerate, and assumes the entire video is that framerate (I've found that all the VFR files I've tested have used 25fps for OP/ED sequences, and 23.98 for the main body of the show).
The only solution I can think of at the moment is to perform the first two steps, then use virtualdub to cut out the OP and ED, correct the framerate somehow, then join the pre-start sequence, OP, body, ED and post-end sequence back together (assuming I can cut accurately at the points where the framerate changes) and hope the audio and subtitles still sync up.
This is such a convoluted and roundabout way of doing things, that there MUST be a better method (for either converting the raw h.264, or for the entire process). Does anyone know of such a method?
bond
8th November 2006, 22:28
first of all did you try whether that player supports mpeg-4 ttxt streams in mp4 (as createable by mp4box)?
SeeMoreDigital
8th November 2006, 22:28
Welcome to the forum...
I wonder if you could satisfy my curiosity?
You say the Archos 504 supports MPEG-4 within MP4.... Does this mean it includes MPEG-4 with AAC audio in MP4? And if so, at what max resolution?
nm
8th November 2006, 22:46
Something like this should work:
1. Use mkvextract to get the raw H.264 stream and timecodes out of the container.
2. Re-encode the H.264 stream with CLI tools (MEncoder, x264+AviSynth, ...) or some GUI frontend. You may need to learn some new things, but once you've done that, doing this kind of stuff is a lot easier in the future.
3. Insert the new video track with a converted timecode file (http://forum.doom9.org/showthread.php?t=112199) and audio track into a suitable container (MP4 preferably).
4. Hope that the player's MP4 support is good enough ;)
edzieba
8th November 2006, 23:04
Yes, it supports MPEG-4 with AAC audio in MP4 (according to the specs anyway). Max resolution is 720x480.
---
Tried using mp4box (with YAMB as GUI) to mux to mp4. Here's the log:
******** MP4Box Command Line used *********
MP4Box.exe -add "D:\My Videos\Coyote Ragtime Show\Track1.h264" -add "D:\My Videos\Coyote Ragtime Show\Track2.ogg#audio" -chap "D:\My Videos\Coyote Ragtime Show\Chapters.txt" -add "D:\My Videos\Coyote Ragtime Show\track3.srt:lang=und" -chap "D:\My Videos\Coyote Ragtime Show\Chapters.txt" "D:\My Videos\Coyote Ragtime Show\Track1.mp4"
******** YAMB Output **********************
[21:51:57] : YAMB 1.6.0 started !
[21:51:57] : OS type detection...
[21:51:57] : Windows XP Professional (version 5.1, Build 2600 : Service Pack 2)
[21:51:57] : Checking MP4Box location...MP4Box found.
[21:51:57] : Checking MediaInfo.dll...0.7.1.2 found.
[21:52:22] : Muxing started...
[21:52:53] : Muxing finished completely.
******** MP4Box stdout ********************
AVC-H264 import - frame size 704 x 400 at 25.0000 FPS
Adjusting AVC SizeLength to 16 bits
Stream uses B-slice references - max frame delay 2
OGG Vorbis import - sample rate 48000 - 2 channels
Timed Text (SRT) import - text track 704 x 400, font Serif (size 18)
WARNING: corrupted SRT frame 4 - starts (at 15710 ms) before end of previous one (0 ms) - adjusting time stamps
WARNING: corrupted SRT frame 5 - starts (at 17040 ms) before end of previous one (0 ms) - adjusting time stamps
WARNING: corrupted SRT frame 32 - starts (at 171940 ms) before end of previous one (0 ms) - adjusting time stamps
WARNING: corrupted SRT frame 33 - starts (at 177370 ms) before end of previous one (0 ms) - adjusting time stamps
WARNING: corrupted SRT frame 35 - starts (at 180020 ms) before end of previous one (0 ms) - adjusting time stamps
WARNING: corrupted SRT frame 49 - starts (at 226320 ms) before end of previous one (0 ms) - adjusting time stamps
WARNING: corrupted SRT frame 80 - starts (at 320810 ms) before end of previous one (0 ms) - adjusting time stamps
WARNING: corrupted SRT frame 113 - starts (at 434550 ms) before end of previous one (0 ms) - adjusting time stamps
WARNING: corrupted SRT frame 116 - starts (at 438070 ms) before end of previous one (0 ms) - adjusting time stamps
WARNING: corrupted SRT frame 203 - starts (at 708920 ms) before end of previous one (0 ms) - adjusting time stamps
WARNING: corrupted SRT frame 318 - starts (at 1172040 ms) before end of previous one (0 ms) - adjusting time stamps
WARNING: corrupted SRT frame 331 - starts (at 1263750 ms) before end of previous one (0 ms) - adjusting time stamps
WARNING: corrupted SRT frame 341 - starts (at 1303800 ms) before end of previous one (0 ms) - adjusting time stamps
WARNING: corrupted SRT frame 345 - starts (at 1319660 ms) before end of previous one (0 ms) - adjusting time stamps
Saving to D:\My Videos\Coyote Ragtime Show\Track1.mp4: 0.500 secs Interleaving
As you can see, it encoded the whole thing at 25fps (not 23.97 for body and 25 for credits).
I tried the file anyway, and it didn't play at all (scrubber picked up the length, file info read audio and video codecs correctly). It just didn't play when I pressed play, with no errors or crashing. File played fine in MPC ('cept for the framerate problem)
bond
8th November 2006, 23:14
the player will obviously not handle ogg vorbis audio. use aac
as nm pointed out you need to remux as described here (http://forum.doom9.org/showthread.php?t=112199)to get a vfr mp4 file
than the srt file seems to be borked as described in the log
edzieba
8th November 2006, 23:39
The SRT errors are due to the conversion from .ass subs (the originals extracted from the MKV) with overlapping subtitles.
Never encoded to MP4 before, so I didn't know .ogg was invalid.
Tried it on the player. Still no video, and the scrubber doesn't move, but the audio plays.
I'll give that timecode program a go once I figure out how to use it (I need to put the h.264 into an mp4 first, then use it, right?).
::EDIT:: Video now syncs perfectly with audio and subs. Still no video on the player though. Interestingly, on closer inspection it reports the video bitrate as the same as the audio bitrate. It's looking more and more like the mp4 support is dodgy, let along subtitle support.
edzieba
9th November 2006, 08:24
Well, as mp4 seems to be a dead end, any suggestions for VFR h.264 > AVI?
foxyshadis
9th November 2006, 09:03
DirectShowSource("...",fps=...,convertfps=true) in avisynth is the easiest way, converting to CFR, since avi sucks that way. Another option is avi_tc (http://bengal.missouri.edu/~kes25c/avi_tc_package.zip), see its readme for how to use it to create a 120fps avi out of your encoded avi + your timecode (same one you used for the mp4).
nm
9th November 2006, 11:44
Tried it on the player. Still no video, and the scrubber doesn't move, but the audio plays.
I'd guess the player's H.264 decoder doesn't support the level or options used in the stream you're trying to play. You'll need to re-encode/transcode the video track.
edzieba
9th November 2006, 14:37
Quick update: using avi_tc and the extracted timecode, the converted and hardsubbed AVI plays back correctly on the player. I'll try recoding the h.264 and see if the player will then accepet it in an mp4.
giandrea
9th November 2006, 20:14
Quick update: using avi_tc and the extracted timecode, the converted and hardsubbed AVI plays back correctly on the player. I'll try recoding the h.264 and see if the player will then accepet it in an mp4.
How can I tell if the video in a MKV is VFR? I tried converting my h264 in MKV video to another format with ffmpeg, but it gives errors. The only solution I've found is demuxing the audio and video streams and encoding them separately. But then when I mux them in MP4 they don't sync. Any solution?
P.S. I am on a Mac, so no Avisynth unfortunately... :(
bond
11th November 2006, 11:36
::EDIT:: Video now syncs perfectly with audio and subs. Still no video on the player though. Interestingly, on closer inspection it reports the video bitrate as the same as the audio bitrate. It's looking more and more like the mp4 support is dodgy, let along subtitle support.before you waste your time, are you sure that your player is able to decode the video stream? which features are used in the stream? your player might not handle some of the features used and therefore doesnt display the video (imho more likely than the container being the cause)
edit: nm already pointed that out
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.