diff mbox

[FFmpeg-devel,1/5,v3] movenc: use correct tag list for AVOutputFormat.codec_tag

Message ID 1498747925-48428-1-git-send-email-derek.buitenhuis@gmail.com
State New
Headers show

Commit Message

Derek Buitenhuis June 29, 2017, 2:52 p.m. UTC
From: John Stebbins <stebbins@jetheaddev.com>

ff_mp4_obj_type contains the wrong type of tags for
AVOutputFormat.codec_tag. AVOutputFormat.codec_tag is used to
validate AVCodecParameters.codec_tag so needs to be the same
type of tag.

Creates new tag lists for mp4 and ismv.  New tag lists support
same list of codecs found in ff_mp4_obj_type. psp uses the same
tag list as mp4 since these both use mp4_get_codec_tag to look up tags.

(cherry picked from commit 713efb2c0d013a42be4051adb7cd90a7c2cbbb4f)
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
---
With fixed EVRC.
---
 libavformat/movenc.c | 42 +++++++++++++++++++++++++++++++++++++++---
 1 file changed, 39 insertions(+), 3 deletions(-)

Comments

Michael Niedermayer June 29, 2017, 8:51 p.m. UTC | #1
On Thu, Jun 29, 2017 at 03:52:05PM +0100, Derek Buitenhuis wrote:
> From: John Stebbins <stebbins@jetheaddev.com>
> 
> ff_mp4_obj_type contains the wrong type of tags for
> AVOutputFormat.codec_tag. AVOutputFormat.codec_tag is used to
> validate AVCodecParameters.codec_tag so needs to be the same
> type of tag.
> 
> Creates new tag lists for mp4 and ismv.  New tag lists support
> same list of codecs found in ff_mp4_obj_type. psp uses the same
> tag list as mp4 since these both use mp4_get_codec_tag to look up tags.
> 
> (cherry picked from commit 713efb2c0d013a42be4051adb7cd90a7c2cbbb4f)
> Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
> ---
> With fixed EVRC.
> ---
>  libavformat/movenc.c | 42 +++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 39 insertions(+), 3 deletions(-)

this seems to break:
./ffmpeg -i matrixbench_mpeg2.mpg -f dash file-fdash.dash

[mp4 @ 0x42b6040] Tag [33][0][0][0] incompatible with output codec id '28' (avc1)
Could not write header for output file #0 (incorrect codec parameters ?): Invalid data found when processing input
Error initializing output stream 0:0 --

[...]
James Almer June 29, 2017, 9:17 p.m. UTC | #2
On 6/29/2017 5:51 PM, Michael Niedermayer wrote:
> On Thu, Jun 29, 2017 at 03:52:05PM +0100, Derek Buitenhuis wrote:
>> From: John Stebbins <stebbins@jetheaddev.com>
>>
>> ff_mp4_obj_type contains the wrong type of tags for
>> AVOutputFormat.codec_tag. AVOutputFormat.codec_tag is used to
>> validate AVCodecParameters.codec_tag so needs to be the same
>> type of tag.
>>
>> Creates new tag lists for mp4 and ismv.  New tag lists support
>> same list of codecs found in ff_mp4_obj_type. psp uses the same
>> tag list as mp4 since these both use mp4_get_codec_tag to look up tags.
>>
>> (cherry picked from commit 713efb2c0d013a42be4051adb7cd90a7c2cbbb4f)
>> Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
>> ---
>> With fixed EVRC.
>> ---
>>  libavformat/movenc.c | 42 +++++++++++++++++++++++++++++++++++++++---
>>  1 file changed, 39 insertions(+), 3 deletions(-)
> 
> this seems to break:
> ./ffmpeg -i matrixbench_mpeg2.mpg -f dash file-fdash.dash
> 
> [mp4 @ 0x42b6040] Tag [33][0][0][0] incompatible with output codec id '28' (avc1)
> Could not write header for output file #0 (incorrect codec parameters ?): Invalid data found when processing input
> Error initializing output stream 0:0 --

dashenc is also using ff_mp4_obj_type. Guess it should be a matter of
changing that as well. It would require making the new codec_mp4_tags[]
shared in isom.c
James Almer June 29, 2017, 9:31 p.m. UTC | #3
On 6/29/2017 6:17 PM, James Almer wrote:
> On 6/29/2017 5:51 PM, Michael Niedermayer wrote:
>> On Thu, Jun 29, 2017 at 03:52:05PM +0100, Derek Buitenhuis wrote:
>>> From: John Stebbins <stebbins@jetheaddev.com>
>>>
>>> ff_mp4_obj_type contains the wrong type of tags for
>>> AVOutputFormat.codec_tag. AVOutputFormat.codec_tag is used to
>>> validate AVCodecParameters.codec_tag so needs to be the same
>>> type of tag.
>>>
>>> Creates new tag lists for mp4 and ismv.  New tag lists support
>>> same list of codecs found in ff_mp4_obj_type. psp uses the same
>>> tag list as mp4 since these both use mp4_get_codec_tag to look up tags.
>>>
>>> (cherry picked from commit 713efb2c0d013a42be4051adb7cd90a7c2cbbb4f)
>>> Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
>>> ---
>>> With fixed EVRC.
>>> ---
>>>  libavformat/movenc.c | 42 +++++++++++++++++++++++++++++++++++++++---
>>>  1 file changed, 39 insertions(+), 3 deletions(-)
>>
>> this seems to break:
>> ./ffmpeg -i matrixbench_mpeg2.mpg -f dash file-fdash.dash
>>
>> [mp4 @ 0x42b6040] Tag [33][0][0][0] incompatible with output codec id '28' (avc1)
>> Could not write header for output file #0 (incorrect codec parameters ?): Invalid data found when processing input
>> Error initializing output stream 0:0 --
> 
> dashenc is also using ff_mp4_obj_type. Guess it should be a matter of
> changing that as well. It would require making the new codec_mp4_tags[]
> shared in isom.c

For the record, this also affects libav. dashenc is currently broken
there because of this patch.
Derek Buitenhuis June 30, 2017, 3:23 p.m. UTC | #4
On 6/29/2017 10:31 PM, James Almer wrote:
>> dashenc is also using ff_mp4_obj_type. Guess it should be a matter of
>> changing that as well. It would require making the new codec_mp4_tags[]
>> shared in isom.c
> For the record, this also affects libav. dashenc is currently broken
> there because of this patch.

Martin (the author) sent a fix.

I'll cherry-pick it.

- Derek
diff mbox

Patch

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index ca389e3..f0262e3 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -6488,6 +6488,41 @@  static int mov_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt)
     return ret;
 }
 
+const AVCodecTag codec_mp4_tags[] = {
+    { AV_CODEC_ID_MPEG4       , MKTAG('m', 'p', '4', 'v') },
+    { AV_CODEC_ID_H264        , MKTAG('a', 'v', 'c', '1') },
+    { AV_CODEC_ID_HEVC        , MKTAG('h', 'e', 'v', '1') },
+    { AV_CODEC_ID_MPEG2VIDEO  , MKTAG('m', 'p', '4', 'v') },
+    { AV_CODEC_ID_MPEG1VIDEO  , MKTAG('m', 'p', '4', 'v') },
+    { AV_CODEC_ID_MJPEG       , MKTAG('m', 'p', '4', 'v') },
+    { AV_CODEC_ID_PNG         , MKTAG('m', 'p', '4', 'v') },
+    { AV_CODEC_ID_JPEG2000    , MKTAG('m', 'p', '4', 'v') },
+    { AV_CODEC_ID_VC1         , MKTAG('v', 'c', '-', '1') },
+    { AV_CODEC_ID_DIRAC       , MKTAG('d', 'r', 'a', 'c') },
+    { AV_CODEC_ID_TSCC2       , MKTAG('m', 'p', '4', 'v') },
+    { AV_CODEC_ID_VP9         , MKTAG('v', 'p', '0', '9') },
+    { AV_CODEC_ID_AAC         , MKTAG('m', 'p', '4', 'a') },
+    { AV_CODEC_ID_MP4ALS      , MKTAG('m', 'p', '4', 'a') },
+    { AV_CODEC_ID_MP3         , MKTAG('m', 'p', '4', 'a') },
+    { AV_CODEC_ID_MP2         , MKTAG('m', 'p', '4', 'a') },
+    { AV_CODEC_ID_AC3         , MKTAG('a', 'c', '-', '3') },
+    { AV_CODEC_ID_EAC3        , MKTAG('a', 'c', '-', '3') },
+    { AV_CODEC_ID_DTS         , MKTAG('m', 'p', '4', 'a') },
+    { AV_CODEC_ID_FLAC        , MKTAG('f', 'L', 'a', 'C') },
+    { AV_CODEC_ID_OPUS        , MKTAG('O', 'p', 'u', 's') },
+    { AV_CODEC_ID_VORBIS      , MKTAG('m', 'p', '4', 'a') },
+    { AV_CODEC_ID_QCELP       , MKTAG('m', 'p', '4', 'a') },
+    { AV_CODEC_ID_EVRC        , MKTAG('m', 'p', '4', 'a') },
+    { AV_CODEC_ID_DVD_SUBTITLE, MKTAG('m', 'p', '4', 's') },
+    { AV_CODEC_ID_MOV_TEXT    , MKTAG('t', 'x', '3', 'g') },
+    { AV_CODEC_ID_NONE        ,    0 },
+};
+
+const AVCodecTag codec_ism_tags[] = {
+    { AV_CODEC_ID_WMAPRO      , MKTAG('w', 'm', 'a', ' ') },
+    { AV_CODEC_ID_NONE        ,    0 },
+};
+
 #if CONFIG_MOV_MUXER
 MOV_CLASS(mov)
 AVOutputFormat ff_mov_muxer = {
@@ -6548,7 +6583,7 @@  AVOutputFormat ff_mp4_muxer = {
     .write_trailer     = mov_write_trailer,
     .deinit            = mov_free,
     .flags             = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
-    .codec_tag         = (const AVCodecTag* const []){ ff_mp4_obj_type, 0 },
+    .codec_tag         = (const AVCodecTag* const []){ codec_mp4_tags, 0 },
     .check_bitstream   = mov_check_bitstream,
     .priv_class        = &mp4_muxer_class,
 };
@@ -6569,7 +6604,7 @@  AVOutputFormat ff_psp_muxer = {
     .write_trailer     = mov_write_trailer,
     .deinit            = mov_free,
     .flags             = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
-    .codec_tag         = (const AVCodecTag* const []){ ff_mp4_obj_type, 0 },
+    .codec_tag         = (const AVCodecTag* const []){ codec_mp4_tags, 0 },
     .check_bitstream   = mov_check_bitstream,
     .priv_class        = &psp_muxer_class,
 };
@@ -6631,7 +6666,8 @@  AVOutputFormat ff_ismv_muxer = {
     .write_trailer     = mov_write_trailer,
     .deinit            = mov_free,
     .flags             = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
-    .codec_tag         = (const AVCodecTag* const []){ ff_mp4_obj_type, 0 },
+    .codec_tag         = (const AVCodecTag* const []){
+        codec_mp4_tags, codec_ism_tags, 0 },
     .check_bitstream   = mov_check_bitstream,
     .priv_class        = &ismv_muxer_class,
 };