[vlc-commits] demux: mp4: add option for M4A audio only

Francois Cartegnie git at videolan.org
Wed Dec 14 20:37:30 CET 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Dec 14 20:15:44 2016 +0100| [004366d949e7fa727ed151306211d5ffcc1ee2ee] | committer: Francois Cartegnie

demux: mp4: add option for M4A audio only

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=004366d949e7fa727ed151306211d5ffcc1ee2ee
---

 modules/demux/mp4/libmp4.h |  1 +
 modules/demux/mp4/mp4.c    | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index 42e3e02..726a790 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -40,6 +40,7 @@ typedef int64_t stime_t;
 #define MAJOR_dash VLC_FOURCC( 'd', 'a', 's', 'h' )
 #define MAJOR_mp41 VLC_FOURCC( 'm', 'p', '4', '1' )
 #define MAJOR_avc1 VLC_FOURCC( 'a', 'v', 'c', '1' )
+#define MAJOR_M4A  VLC_FOURCC( 'M', '4', 'A', ' ' )
 
 #define ATOM_root VLC_FOURCC( 'r', 'o', 'o', 't' )
 #define ATOM_uuid VLC_FOURCC( 'u', 'u', 'i', 'd' )
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index 3514e4f..28b032f 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -43,6 +43,11 @@
 static int  Open ( vlc_object_t * );
 static void Close( vlc_object_t * );
 
+#define CFG_PREFIX "mp4-"
+
+#define MP4_M4A_TEXT     "M4A audio only"
+#define MP4_M4A_LONGTEXT "Ignore non audio tracks from iTunes audio files"
+
 vlc_module_begin ()
     set_category( CAT_INPUT )
     set_subcategory( SUBCAT_INPUT_DEMUX )
@@ -50,6 +55,9 @@ vlc_module_begin ()
     set_shortname( N_("MP4") )
     set_capability( "demux", 240 )
     set_callbacks( Open, Close )
+
+    add_category_hint("Hacks", NULL, true)
+    add_bool( CFG_PREFIX"m4a-audioonly", false, MP4_M4A_TEXT, MP4_M4A_LONGTEXT, true )
 vlc_module_end ()
 
 /*****************************************************************************
@@ -103,6 +111,11 @@ struct demux_sys_t
     asf_packet_sys_t asfpacketsys;
     uint64_t i_preroll;         /* foobar */
     int64_t  i_preroll_start;
+
+    struct
+    {
+        int es_cat_filters;
+    } hacks;
 };
 
 #define DEMUX_INCREMENT (CLOCK_FREQ / 8) /* How far the pcr will go, each round */
@@ -632,6 +645,11 @@ static int Open( vlc_object_t * p_this )
             case MAJOR_dash:
                 msg_Dbg( p_demux, "DASH Stream" );
                 break;
+            case MAJOR_M4A:
+                msg_Dbg( p_demux, "iTunes audio" );
+                if( var_InheritBool( p_demux, CFG_PREFIX"m4a-audioonly" ) )
+                    p_sys->hacks.es_cat_filters = AUDIO_ES;
+                break;
             default:
                 msg_Dbg( p_demux,
                          "unrecognized major media specification (%4.4s).",
@@ -3213,6 +3231,11 @@ static void MP4_TrackCreate( demux_t *p_demux, mp4_track_t *p_track,
         }
     }
 
+    if( p_sys->hacks.es_cat_filters && (p_sys->hacks.es_cat_filters & p_track->fmt.i_cat) == 0 )
+    {
+        p_track->fmt.i_priority = ES_PRIORITY_NOT_DEFAULTABLE;
+    }
+
     if( TrackCreateES( p_demux,
                        p_track, p_track->i_chunk,
                       (p_track->b_chapters_source || !b_create_es) ? NULL : &p_track->p_es ) )



More information about the vlc-commits mailing list