使用GStreamer生成的MP4无法在Windows Media Player播放的解决咨询
Let's break down the possible issues and fixes for your GStreamer-generated MP4 not playing in WMP, even though it works in MPlayer and VLC. From your command and playback logs, here are actionable steps to try:
1. Enforce MPEG-4 Simple Profile (WMP's preferred profile)
WMP's built-in MPEG-4 decoder has strict support limits—it often only handles Simple Profile (SP) instead of the Advanced Simple Profile (ASP) that avenc_mpeg4 might use by default. Your MPlayer output confirms the video is MPEG-4, but doesn't specify the profile, which could be the mismatch.
Modify your GStreamer command to explicitly set the profile and level to WMP-compatible values:
gst-launch-1.0 videotestsrc num-buffers=10 ! "video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30/1" ! videoconvert ! avenc_mpeg4 profile=1 level=5 ! avmux_mp4 ! filesink location=/tmp/test_sp.mp4
profile=1corresponds to Simple Profilelevel=5matches your 720p resolution/30fps combination
2. Add a Dummy Audio Stream
WMP frequently struggles with video-only MP4 files, even if they're technically compliant. Your MPlayer output clearly shows "Audio: no sound", which is likely a key compatibility issue here.
Add a silent AAC audio stream (WMP's preferred audio codec) to your command:
gst-launch-1.0 videotestsrc num-buffers=10 ! "video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30/1" ! videoconvert ! avenc_mpeg4 profile=1 level=5 ! queue ! avmux_mp4 name=mux audiotestsrc num-buffers=30 ! "audio/x-raw, rate=44100, channels=2" ! audioconvert ! avenc_aac ! queue ! mux. mux. ! filesink location=/tmp/test_with_audio.mp4
- The
audiotestsrcgenerates 30 frames of silence to match your 10 video frames at 30fps - AAC is natively supported by WMP, so this should resolve the "no audio" compatibility gap
3. Move the MOOV Atom to the Front of the File
WMP sometimes fails to handle MP4 files where the moov metadata atom is stored at the end of the file (the default behavior for many muxers). Use GStreamer's mp4mux with the faststart flag to place the moov atom upfront, making it easier for WMP to parse:
gst-launch-1.0 videotestsrc num-buffers=10 ! "video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30/1" ! videoconvert ! avenc_mpeg4 profile=1 level=5 ! mp4mux faststart=true ! filesink location=/tmp/test_faststart.mp4
faststart=truerearranges the file structure so WMP can read metadata immediately, without waiting to scan the entire file
4. Verify with FFmpeg (Cross-Check)
If none of the above work, use FFmpeg to reprocess your existing MP4 into a WMP-friendly version. If this converted file plays, it confirms the issue is with encoding/muxing parameters in GStreamer:
ffmpeg -i /tmp/test.mp4 -c:v mpeg4 -profile:v simple -level 5 -c:a aac -f mp4 /tmp/test_ffmpeg.mp4
Test this FFmpeg-generated file in WMP—if it works, replicate the exact parameters in your GStreamer command to fix the original issue.
内容的提问来源于stack exchange,提问作者hyunsooPark

