From: Steven S. <sch...@gm...> - 2014-10-23 13:32:12
|
It's been a little while since I needed to create a 4:2:2 uncompressed Quicktime file but now when I run the program that did this task in the past the file shows up as having 0 frames which makes many applications unhappy. I've finally narrowed the problem down to the 'stts' atom having a 'sample_count' value of 0. Included is a simple test case that produces a 10 frame Quicktime file named testing.mov. Compilation was done with cc -I/usr/local/include/lqt testqt.c -lquicktime but if you've libquicktime installed elsewhere change the -I and / or add -L. Running the program as ./a.out results in the file [larry:~] sms% ls -l testing.mov -rw-r--r-- 1 sms staff 6759228 Oct 17 16:56 testing.mov qtinfo says the file has 0 frames qtinfo testing.mov Type: Quicktime 0 audio tracks. 1 video tracks. 704x480, depth 24 rate 23.976025 [24000:0] constant length 0 frames compressor 2vuy. Native colormodel: Undefined Interlace mode: None (Progressive) Pixel aspect ratio: 10:11 No timecodes available supported. 0 text tracks. and the frame rate doesn't look right either, I'd expect [24000:1001]. I thought too that the Native colormodel should be 422. Looking at the file using an Apple utility I se the 'stts' atom has a 0 for the 'sampCnt' (sample_count) field. If I change that to 10 the qtinfo output is correct. The test program is based on the y4mtoqt program from mjpegtools. Y4mtoqt was working for years and hasn't changed, so something in libquicktime's been broken in the last few months or so. I've tried attaching what I thought were small enough screenshots showing the atoms of the broken file but a 64KB limit on mail times is causing the mail to be held pending moderator approval. here's the test program that produces a file with 10 junk frames. #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <quicktime.h> #include <lqt.h> #include <colormodels.h> int main(int argc, char **argv) { char *outfilename = "testing.mov"; uint8_t *yuv[3]; int y_len, u_len, v_len, nfields = 1, dominance = 0; int imodel = 0; int err, i, c, y4mchroma; char *qtchroma = NULL; quicktime_t *qtf; quicktime_pasp_t pasp; qtchroma = QUICKTIME_2VUY; imodel = BC_YUV422P; /* Input is planar */ y_len = 704 * 480; u_len = 352 * 480 ; v_len = 352 * 480 ; yuv[0] = malloc(y_len); yuv[1] = malloc(u_len); yuv[2] = malloc(v_len); qtf = quicktime_open(outfilename, 0, 1); if (!qtf) fprintf(stderr,"quicktime_open(%s,0,1) failed", outfilename); quicktime_set_video(qtf, 1, 704, 480, (double) 24000 / 1001, qtchroma); lqt_set_cmodel(qtf, 0, imodel); dominance = 0; nfields = 1; lqt_set_fiel(qtf, 0, nfields, dominance); pasp.hSpacing = 10; pasp.vSpacing = 11; lqt_set_pasp(qtf, 0, &pasp); for (i = 0; i < 10; i++) { err = quicktime_encode_video(qtf, yuv, 0); if (err != 0) fprintf(stderr, "quicktime_encode_video failed."); } quicktime_close(qtf); exit(0); } |