Can't Open x264 encoded files

MrVideo

Active member
Ultimately I'll have 5 x264 encoded files, in order to edit them in order to fix a problem.

Two of the files are 720p H.264 sourced and three of the files are 1080i MPEG-2 sourced, which is why I can't edit the original file.

So, they were all encoded to 720p23.976 H.264, wrapped into MKV.

VRD won't open the MKV files, That's OK, I just used tsMuxeR to remux into TS files.

One file gets an error that it can't find the clock and the other crashes VRD.

I'm going to upload the two TS and two MKV files and the log.
 
Last edited:

Dan203

Senior Developer
Staff member
VideoReDo requires that H.264 files have SPS/PPS headers. In MKV these are typically stored in a single CodecPrivate section of the file in the same format used by MP4. In TS they need to be attached to every I/IDR frame. If they are missing then VRD will not be able to open the file. Some other players/muxers will make assumptions about the SPS/PPS data if it's missing, allowing it to play. However VRD can't do that. We need the SPS/PPS to be in the file.

In tsMuxer there is an option that says something like "continually insert SPS/PPS" try turning that on and remuxing your files again.

Dan
 

MrVideo

Active member
In tsMuxer there is an option that says something like "continually insert SPS/PPS" try turning that on and remuxing your files again.
That option is checked by default. So, that isn't it.

Please look at the samples that I uploaded to the ftp server. Email ticket # is PKW-91995-213
 

Dan203

Senior Developer
Staff member
I just checked the folder. The only thing in it was a log file, no samples.

Edit: Server might be full. Hold off for a few minutes while we check.

Edit: OK we cleared out the server. Sorry about that, but you'll need to re-upload the samples

Dan
 
Last edited:

MrVideo

Active member
OK, two of the four files are there. The TS and MKV of one of them. This is the one that gave the error about not finding the clock, but didn't crash VRD.
 

MrVideo

Active member
I tried something different

Since having the x264 encoder output a mp4 file and wrapping that with MKV didn't work (an issue that should be fixed in the next release) and remuxing with tsMuxeR from MKV to TS also failed to load, I had the x264 encoder output a raw .264 elementary stream and then had tsMuxeR remux that video with the audio.

VRD loaded that just fine.
 

Dan203

Senior Developer
Staff member
Did you ever try simply opening the MP4 file in VRD? That probably would have worked.

I'm guessing the problem here is tsMuxeR's MP4 reader. MP4 files store the SPS/PPS for the H.264 stream in a global buffer to reduce the amount of redundant data stored in the file. However TS files require that the SPS/PPS be attached to every I/IDR frame as part of an Annex B header. So in order for a program to properly convert from MP4 to TS they have to properly read the SPS/PPS from the MP4 file and then reattach it to every I/IDR frame.

Now I'm not sure what tsMuxeR uses to read MP4 files, but if they use FFmpeg then that could be the issue. FFmpeg includes a filter which can convert the MP4 SPS/PPS data to an Annex B header. However it's designed so that it only attaches them to IDR frames, and not I frames. So if your file does not have any IDR frames, or they are really far apart, then it would not insert enough SPS/PPS headers for VRD to open the file.

I ran into this when I added FFmpeg support to VRD for MP4 and MKV (MKV stores the SPS/PPS the same way as MP4) so I had to rewrite the FFmpeg filter so that it would insert the SPS/PPS header into both IDR and I frames. I tried to submit the change to the FFmpeg project, but I couldn't figure out how. So right now this ability is exclusive to VRD. (if anyone knows how to submit changes to FFmpeg let me know)

Anyway my point is that if the H.264 stream in your file only had I frames, or just a few IDR frames very far apart, then tsMuxeR may not have attached enough SPS/PPS headers to the TS file to allow VRD to open it. Which would explain what I was seeing in the sample files you sent.

Dan
 

MrVideo

Active member
Did you ever try simply opening the MP4 file in VRD? That probably would have worked.
While it may have, it was video only. The MP4 video and the audio was then MKV wrapped. I'm going to try putting out ES H.264 and wrapping that with MKV and see what happens.

Anyway my point is that if the H.264 stream in your file only had I frames, or just a few IDR frames very far apart, then tsMuxeR may not have attached enough SPS/PPS headers to the TS file to allow VRD to open it. Which would explain what I was seeing in the sample files you sent.
You should have seen IDR frames every second. That is how the x264 encoder is configured. More in the BBC problem thread.
 

MrVideo

Active member
I take back the part about the samples having IDR frames. I just opened an encoding where the B-frames are now back and there are no IDR frames. It seems that the x264 encoder only uses I-frames if there B-frames.
 

Dan203

Senior Developer
Staff member
I'm betting they have the same issue I did with FFmpeg where they only attached the SPS/PPS to IDR frames and not I frames. That explains why the TS didn't open, and I already explained why the MKV didn't open, so this thread is done right?

Dan
 

MrVideo

Active member
I'm betting they have the same issue I did with FFmpeg where they only attached the SPS/PPS to IDR frames and not I frames.
I'm confused by this statement. They? Both of the newer x264 encodes )not the samples I sent you) opened with VRD, just that the one with IDR/P frames could be edited without glitching and the other, with I/P/B frames would always glitch.

That explains why the TS didn't open, and I already explained why the MKV didn't open, so this thread is done right?
In any event, this thread is really done.
 

Dan203

Senior Developer
Staff member
I'm confused by this statement. They? Both of the newer x264 encodes )not the samples I sent you) opened with VRD, just that the one with IDR/P frames could be edited without glitching and the other, with I/P/B frames would always glitch.
I was referring to the developers of tsMuxeR as "they". They seem to have an issue properly inserting the SPS/PPS into files which only have I frames and no IDR frames. I explained this before, but basically MP4 and MKV both store the SPS/PPS in a single global header rather then in each I/IDR frame. When converting to TS the program, in this case tsMuxeR, has to reapply the SPS/PPS to every I/IDR frame. When I was writing the FFmpeg reader for VideoReDo I discovered that the code in FFmpeg which is designed to do this (i.e. take the global SPS/PPS and apply it to I/IDR frames) would actually only apply it to IDR frames, so when I attempted to open files which only had I frames it would fail. I had to make a modification to FFmpeg to make it apply the SPS/PPS to both IDR and I frames before it would work. I think tsMuxeR has a similar problem. They might even be using FFmpeg to read MP4/MKV files too, so it could be the exact same problem.

Dan
 

MrVideo

Active member
Sorry, I got all that. I wasn't having an issue opening the new x264 encoded files, just editing them. They weren't conversions, but H.264 ES video output from x264, which was then muxed with tsMuxeR. No MP4 or MKV involvement in this last case.

All of this is now in the BBC problem thread, so this thread is done.
 
Top Bottom