[FFmpeg-devel] Make FLV decoder expose meta-data
Art Clarke
aclarke
Mon Jul 6 21:59:08 CEST 2009
>
> please split the patch in
> 1. remove parts of the old code (cosmetic as its disabled)
> 2. reenable the remaining (Bit-rate and duration) parsing
> 3. add your metadata code
>
> (this would make debuging any bugs they might cause easier, and no
> ive no reason to belive they would but theres always a change that does
> and thats one of the reasons why nicely split patches and commits are
> better)
>
>
Understood -- just hoped the simplicity of these changes could avoid the
unneccessary cosmetic changes. Does this work:
1) cosmetic-only; removed old code (but left in the bit-rate parsing since I
didn't change those lines and that seems better for debugging later).
2) add new code for adding exposing av_metadata but it's still not enabled.
3) and then re-enable the AMF parsing
Attached patches must be applied in order (they build on each other).
- Art
--
http://www.xuggle.com/
xu?ggle (z?' gl) v. To freely encode, decode, and experience audio and
video.
Use Xuggle to get the power of FFmpeg in Java.
-------------- next part --------------
Index: libavformat/flvdec.c
===================================================================
--- libavformat/flvdec.c (revision 19361)
+++ libavformat/flvdec.c (working copy)
@@ -217,36 +217,10 @@
acodec = astream ? astream->codec : NULL;
vcodec = vstream ? vstream->codec : NULL;
- if(amf_type == AMF_DATA_TYPE_BOOL) {
- if(!strcmp(key, "stereo") && acodec) acodec->channels = num_val > 0 ? 2 : 1;
- } else if(amf_type == AMF_DATA_TYPE_NUMBER) {
+ if(amf_type == AMF_DATA_TYPE_NUMBER) {
if(!strcmp(key, "duration")) s->duration = num_val * AV_TIME_BASE;
-// else if(!strcmp(key, "width") && vcodec && num_val > 0) vcodec->width = num_val;
-// else if(!strcmp(key, "height") && vcodec && num_val > 0) vcodec->height = num_val;
else if(!strcmp(key, "videodatarate") && vcodec && 0 <= (int)(num_val * 1024.0))
vcodec->bit_rate = num_val * 1024.0;
- else if(!strcmp(key, "audiocodecid") && acodec && 0 <= (int)num_val)
- flv_set_audio_codec(s, astream, (int)num_val << FLV_AUDIO_CODECID_OFFSET);
- else if(!strcmp(key, "videocodecid") && vcodec && 0 <= (int)num_val)
- flv_set_video_codec(s, vstream, (int)num_val);
- else if(!strcmp(key, "audiosamplesize") && acodec && 0 < (int)num_val) {
- acodec->bits_per_coded_sample = num_val;
- //we may have to rewrite a previously read codecid because FLV only marks PCM endianness.
- if(num_val == 8 && (acodec->codec_id == CODEC_ID_PCM_S16BE || acodec->codec_id == CODEC_ID_PCM_S16LE))
- acodec->codec_id = CODEC_ID_PCM_S8;
- }
- else if(!strcmp(key, "audiosamplerate") && acodec && num_val >= 0) {
- //some tools, like FLVTool2, write consistently approximate metadata sample rates
- if (!acodec->sample_rate) {
- switch((int)num_val) {
- case 44000: acodec->sample_rate = 44100 ; break;
- case 22000: acodec->sample_rate = 22050 ; break;
- case 11000: acodec->sample_rate = 11025 ; break;
- case 5000 : acodec->sample_rate = 5512 ; break;
- default : acodec->sample_rate = num_val;
- }
- }
- }
}
}
-------------- next part --------------
Index: libavformat/flvdec.c
===================================================================
--- libavformat/flvdec.c (revision 19361)
+++ libavformat/flvdec.c (working copy)
220c220,225
< if(amf_type == AMF_DATA_TYPE_NUMBER) {
---
> if(amf_type == AMF_DATA_TYPE_BOOL) {
> av_strlcpy(str_val, num_val > 0 ? "true" : "false", sizeof(str_val));
> av_metadata_set(&s->metadata, key, str_val);
> } else if(amf_type == AMF_DATA_TYPE_NUMBER) {
> snprintf(str_val, sizeof(str_val), "%.f", num_val);
> av_metadata_set(&s->metadata, key, str_val);
224c229,230
< }
---
> } else if (amf_type == AMF_DATA_TYPE_STRING)
> av_metadata_set(&s->metadata, key, str_val);
-------------- next part --------------
Index: libavformat/flvdec.c
===================================================================
--- libavformat/flvdec.c (revision 19361)
+++ libavformat/flvdec.c (working copy)
358c358
< if (type == FLV_TAG_TYPE_META && size > 13+1+4 && 0)
---
> if (type == FLV_TAG_TYPE_META && size > 13+1+4)
More information about the ffmpeg-devel
mailing list