Encoding additional data (non-AV) in stream?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Encoding additional data (non-AV) in stream?

Florian Echtler-3
Hello everybody,

I have an libavcodec/format based application to write video data to an
output file. This is working nicely; however, I'd also like to be able
to put additional data packets (containing e.g., 3D position data) into
the output stream using CODEC_TYPE_DATA. I suppose normal players would
ignore these packets, while a specially adapted decoder could get the
data back out. I've done some experiments with AVI files, and the AVI
file does indeed get a 'dats' chunk in the header.. but my data doesn't
show up anywhere in the file.

I suppose the problem is that I don't have the correct codec. I tried
CODEC_ID_RAWVIDEO (probably a dumb idea), but I couldn't find anything
else that would fit. Can somebody please give me a hint on how to embed
non-AV data in the final stream?

Many thanks,
Yours, Florian
--
0666 - Filemode of the Beast

_______________________________________________
libav-user mailing list
[hidden email]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|

PATCH: Re: Encoding additional data (non-AV) in stream?

Florian Echtler-3
> I suppose the problem is that I don't have the correct codec. I tried
> CODEC_ID_RAWVIDEO (probably a dumb idea), but I couldn't find anything
> else that would fit. Can somebody please give me a hint on how to embed
> non-AV data in the final stream?
Replying to myself again.. as it seems, CODEC_ID_RAWVIDEO wasn't such a
dumb idea after all. I've managed to embed my data frames in the AVI
file successfully, however, now I have problems with decoding them
again. I noted that while avienc.c is able to correctly generate a
'dats' header, avidec.c is not able to read them again and fails.

I think it's a bit odd that one part of ffmpeg can write files that the
other part can't read anymore, so here's a tiny patch which at least
allows the stream to be read:

--- avidec.old 2008-06-09 09:06:01.000000000 +0200
+++ avidec.c 2008-06-09 09:06:34.000000000 +0200
@@ -411,6 +411,9 @@
                 //FIXME
                 codec_type = CODEC_TYPE_DATA; //CODEC_TYPE_SUB ?  FIXME
                 break;
+            case MKTAG('d', 'a', 't', 's'):
+                codec_type = CODEC_TYPE_DATA;
+                break;
             default:
                 av_log(s, AV_LOG_ERROR, "unknown stream type %X\n",
tag1);
                 goto fail;

In case the whitespace gets messed up, I have also attached the patch as
a file. Please tell me what you think - is this the right way to go?

On a different topic: I still have some problems understanding how to
handle the pts values.. do I have to generate them? How? Can somebody
point me to a more detailed description?

Thanks again, Yours, Florian
--
0666 - Filemode of the Beast

_______________________________________________
libav-user mailing list
[hidden email]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

avidec.patch (496 bytes) Download Attachment