Skip to content
The Chat Archive
claude-opus-4-20250514-thinking-16k· Anthropic LMArena Human Preference 140K

When I run mpv 'some YouTube video' on command line, for some reason, for some of the…

  1. User

    When I run mpv 'some YouTube video' on command line, for some reason, for some of the videos mpv is running and blocking input; for some other videos mpv is running in background and instantly returned a command prompt. Analyze and let me know why.

  2. Assistant

    This behavior is most likely caused by the ampersand (&) character in YouTube URLs, which has special meaning in shell environments.

    When you run:

    mpv https://youtube.com/watch?v=VIDEO_ID&list=PLAYLIST_ID
    

    The shell interprets the & as a command to run the process in the background. Everything after the & is treated as a separate command. So mpv only receives the URL up to the & character, and the terminal immediately returns to the prompt.

    Solution: Quote the YouTube URL to prevent shell interpretation:

    # Use single quotes
    mpv 'https://youtube.com/watch?v=VIDEO_ID&list=PLAYLIST_ID'
    
    # Or double quotes
    mpv "https://youtube.com/watch?v=VIDEO_ID&list=PLAYLIST_ID"
    
    # Or escape the ampersand
    mpv https://youtube.com/watch?v=VIDEO_ID\&list=PLAYLIST_ID
    

    YouTube URLs commonly contain these parameters with & separators:

    • &list= (playlist ID)
    • &t= (timestamp)
    • &feature= (sharing feature)

    If this isn't the issue, other possible causes include:

    • Some videos failing to load (check mpv's output/errors)
    • Different behavior for audio-only content
    • Terminal settings or mpv configuration differences

    But in most cases, unquoted & characters in URLs are the culprit for this exact behavior.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.