1

I used VLC to play what's supposed to be a video file, and it plays just a still image with sound; Before trashing it, I decided to open it in the Windows Media Player, and to my surprise I can see video and sound normally.

Next I used ffprobe and discovered the video file contains 3 streams, and VLC picks up the 1st (video) stream, which is just a mjpeg image! Whereas WMP picks up the 2nd (video) stream.

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'mySupaDupaFile.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.33.100
  Duration: 01:46:15.80, start: 0.000000, bitrate: 3191 kb/s
  Stream #0:0[0x1](und): Video: mjpeg (Baseline) (mp4v / 0x7634706D), yuvj444p(pc, bt470bg/unknown/unknown), 749x972, 99348 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
  Stream #0:1[0x2](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 3101 kb/s, 25 fps, 25 tbr, 90k tbn
  Stream #0:2[0x3](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 82 kb/s (default)

Looking at the ffprobe output, stream#0 is marked as (default). Does ffmpeg have a command that can unset (default) on stream-0, and set (default) on stream-1 ?

For now, I have just re-encoded into another file the h264 + aac streams, and discarded the mjpeg stream, but would like to know if it's possible just to change the default video stream ! (and more generally how to mark a stream as DEFAULT when there are multiple streams).

2 Answers 2

1

Final answer: Use -map to copy all 3 streams. First disposition UNSETS the existing default; Second disposition SETS the NEW default;

If you don't unset, all 3 streams are marked as default, and thus when opening in VLC the mjpeg will still play !

ffmpeg -i "myInputFile.mp4" -y ^
    -c copy -map 0:0 -map 0:1 -map 0:2 ^
    -disposition:v:0 0 ^
    -disposition:v:1 default ^
    myOutputFile.mp4
0

Based on https://ffmpeg.org/ffmpeg.html, there is an example of making the second audio stream the default stream:

ffmpeg -i in.mkv -c copy -disposition:a:1 default out.mkv

such that making the second video stream the default stream would be

ffmpeg -i in.mkv -c copy -disposition:v:1 default out.mkv
3
  • No need for multiple commands.
    – Gyan
    Commented Apr 1, 2023 at 4:06
  • @Gyan what multiple commands?
    – joedotnot
    Commented Apr 1, 2023 at 17:05
  • @xer-rex Using your example, I end up with the mjpeg stream as the default, and the sound stream as the default; i.e. 2 streams only, the actual video stream h264 is dropped ! But thanks for pointing me to the DISPOSITION flag, see my revised answer below.
    – joedotnot
    Commented Apr 1, 2023 at 17:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.