[FFmpeg-devel] movenc.c extradata handling for "aivx" video streams

Vincent Olivier vincent at up4.com
Thu Mar 13 20:09:31 CET 2014


Hi,

Please see a partial patch below (not ready for submission yet).

This will make a MOV file with extradata that can be read back and shows up as being identical to the FCPX-remuxed version via "ffprobe -show_data -show_streams”. Please see FFPROBE OUTPUT below for the FFMPEG-remuxed file.

However, there is a difference between the two files that I cannot pinpoint even after extensive probing and tracing of the mov.c parsing code. I get a “no frame!” error plus “Could not find codec parameters…” in (both in the FFPROBE OUTPUT).

I’m pretty sure it has to do with the fact that in the FCPX-remuxed file, the extradata is not parsed out of the “avcC” atom. But I don’t know the tag of the actual atom. My question is this: how to I find out the atom tag from with the extradata is parsed for the aivx format? Like I said I put multiple traces in mov.c wherever I could see that extradata was effected, but I was unsuccessful to isolate extradata parsing code for the aivx format. Please find a FCPX-remuxed aivx sample here: http://j.mp/aivx-sample1

Thanks!

Vincent


FFPROBE OUTPUT:
Vincents-MacBook-Air:remuxing vincent$ ffprobe -show_streams -show_data -i /Users/vincent/Desktop/A013C006_140306IO.MOV 
ffprobe version 2.1.git-ffb7d71 Copyright (c) 2007-2014 the FFmpeg developers
  built on Mar  4 2014 08:48:40 with Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
  configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-avresample --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libspeex --enable-libass --enable-libbluray --enable-gnutls --enable-fontconfig --enable-libfreetype --disable-indev=jack --disable-outdev=xv --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/clang --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid --enable-nonfree --enable-libfdk-aac --enable-libfaac
  libavutil      52. 66.100 / 52. 66.100
  libavcodec     55. 52.102 / 55. 52.102
  libavformat    55. 33.100 / 55. 33.100
  libavdevice    55. 10.100 / 55. 10.100
  libavfilter     4.  2.100 /  4.  2.100
  libavresample   1.  2.  0 /  1.  2.  0
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
[h264 @ 0x7ffd89004c00] no frame!
    Last message repeated 10 times
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7ffd8a042a00] decoding for stream 0 failed
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7ffd8a042a00] Could not find codec parameters for stream 0 (Video: h264 (aivx / 0x78766961), 2048x1080, 90734 kb/s): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/vincent/Desktop/A013C006_140306IO.MOV':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf55.34.101
  Duration: 00:00:55.17, start: 0.000000, bitrate: 90734 kb/s
    Stream #0:0(eng): Video: h264 (aivx / 0x78766961), 2048x1080, 90734 kb/s, 24 fps, 24 tbr, 24k tbn, 48k tbc (default)
    Metadata:
      handler_name    : DataHandler
      timecode        : 00:01:55:21
    Stream #0:1(eng): Data: none (tmcd / 0x64636D74)
    Metadata:
      handler_name    : DataHandler
      timecode        : 00:01:55:21
Unsupported codec with id 0 for input stream 1
[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=unknown
codec_type=video
codec_time_base=1/48000
codec_tag_string=aivx
codec_tag=0x78766961
width=2048
height=1080
has_b_frames=0
sample_aspect_ratio=0:1
display_aspect_ratio=0:1
pix_fmt=unknown
level=-99
timecode=N/A
id=N/A
r_frame_rate=24/1
avg_frame_rate=24/1
time_base=1/24000
start_pts=0
start_time=0.000000
duration_ts=1324000
duration=55.166667
bit_rate=90734592
nb_frames=1324
nb_read_frames=N/A
nb_read_packets=N/A
extradata=
00000000: 0000 0001 0910 0000 0001 277a 102a b6cf  ..........'z.*..
00000010: 0080 0227 e270 1100 0013 8800 03a9 8084  ...'.p..........
00000020: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000030: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000040: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000050: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000060: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000070: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000080: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000090: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000000a0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000000b0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000000c0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000000d0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000000e0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000000f0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000100: 0000 0001 28ce 3133 8811 36b8 8c25 1905  ....(.13..6..%..
00000110: 0128 ccdc 1f60 da0e a0a0 2519 9b83 ec1b  .(...`....%.....
00000120: 41d0 8824 9ae4 f5ff e23f 88fc 67c6 78ce  A..$.....?..g.x.
00000130: 331d 1813                                3...

DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
TAG:language=eng
TAG:handler_name=DataHandler
TAG:timecode=00:01:55:21
[/STREAM]
[STREAM]
index=1
codec_name=unknown
codec_long_name=unknown
profile=unknown
codec_type=data
codec_time_base=1/24
codec_tag_string=tmcd
codec_tag=0x64636d74
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/24000
start_pts=0
start_time=0.000000
duration_ts=1324000
duration=55.166667
bit_rate=N/A
nb_frames=1
nb_read_frames=N/A
nb_read_packets=N/A
extradata=
00000000: 0000 0000 0000 0000 0000 5dc0 0000 03e8  ..........].....
00000010: 1800 0000                                ....

DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
TAG:language=eng
TAG:handler_name=DataHandler
TAG:timecode=00:01:55:21
[/STREAM]




PARTIAL PATCH:

---
 libavformat/movenc.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 954b208..967bed7 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -772,6 +772,15 @@ static int mov_write_avcc_tag(AVIOContext *pb, MOVTrack *track)
     ff_isom_write_avcc(pb, track->vos_data, track->vos_len);
     return update_size(pb, pos);
 }
+static int mov_write_aivx_tag(AVIOContext *pb, MOVTrack *track)
+{
+    int64_t pos = avio_tell(pb);
+    
+    avio_wb32(pb, 0);
+    ffio_wfourcc(pb, "avcC");
+    avio_write(pb, track->vos_data, track->vos_len);
+    return update_size(pb, pos);
+}
 
 static int mov_write_hvcc_tag(AVIOContext *pb, MOVTrack *track)
 {
@@ -1244,7 +1253,13 @@ static int mov_write_video_tag(AVIOContext *pb, MOVTrack *track)
     else if (track->enc->codec_id == AV_CODEC_ID_HEVC)
         mov_write_hvcc_tag(pb, track);
     else if (track->enc->codec_id == AV_CODEC_ID_H264) {
-        mov_write_avcc_tag(pb, track);
+        
+        // Check H264/MOV "flavor", default to avcc
+        if(track->enc->codec_tag == MKTAG('a','i','v','x'))
+           mov_write_aivx_tag(pb, track);
+        else
+           mov_write_avcc_tag(pb, track);
+ 
         if (track->mode == MODE_IPOD)
             mov_write_uuid_tag_ipod(pb);
     } else if (track->enc->codec_id == AV_CODEC_ID_VC1 && track->vos_len > 0)
-- 
1.8.3.4 (Apple Git-47)


More information about the ffmpeg-devel mailing list