Generating Sample Files from Media

Why Sample Files?

In cases where problems occur playing a particular video file, it is often very useful to be able to analyze and test the file in question. Working with multi-gigabyte files isn't desired, though, so it's best to try and generate a small sample file that still exhibits the problem behavior so that the sample can be used for testing.

You may be asked to provide such a sample file as part of troubleshooting on the forum.

Tip!: In most cases, your Plex Media Server will actually skip over files with sample in the filename. If you're adding the file to a library, be sure not to include that word in the filename.

What to do with a Sample File

Once you've created a sample file, please check the following:

  • The sample file still reproduces the behavior in question
  • The sample file is of a reasonable size (ideally, they should be kept smaller than ~50MB; if that can't be done, please make an effort to produce the smallest sample you can)

Once you have a small sample file, the best way to share it is to upload the file to an online storage site such as Dropbox, Google Drive, or similar. Then share the link to the file in the forum thread.

How to Create a Sample File

Often, the easiest way to create a small sample file is to split a file into separate, smaller chunks. If you can do so and if the small chunk still exhibits the behavior in question, then you have a sample file.

There are many ways to create a sample file and different methods may be needed for different types of files. Below are simply some suggestions.

Use the dd command

The dd command can be used on files that does not have indexed data at the end. For example MKV, TS, and streaming-optimized MP4 files can use this powerful method. Command arguments:

  • if: input file, including the full path
  • of: output file, including the full path
  • bs: use a value of "1m" or "1M", depending on your OS (see below)
  • count: the output filesize in megabytes (50 is a good starting value)

OS X Example

You can run the command from the Terminal in OS X. Use the "1m" value for bs.

dd if=/path/to/inputFile.ts of=/path/to/output.ts bs=1m count=50

Edit the count value to get the size of the sample file you want.

Linux Example (non BSD)

Linux systems will require you to use the "1M" value for bs.

dd if=/path/to/inputFile.ts of=/path/to/outputFile.ts bs=1M count=50

Edit the count value to get the size of the sample file you want.

MKV

The MKVToolNix program lets you create MKV files from various media streams. It also lets you create chunks from an existing MKV file. Downloading MKVToolNix:

To split an MKV file:

  • Launch the program and add the MKV file by clicking add under the input tab
  • Switch to the Global tab
  • Under Splitting, choose "split after size" or "split after duration"
  • Enter an appropriate size (e.g. "50M") or duration (e.g. "60s")
  • Set an output path and file name
  • Click the Start muxing button
  • You can cancel the process after a number of files have been created

After you've created some chunks, pick one and verify that it still exhibits the behavior in question.

Use the Plex Transcoder

If you're not scared of using the command line, you can use the Plex Transcoder itself to generate a sample file. This can be used to generate files for multiple container types such as MP4, AVI, MKV, etc. The general command would be something like:

/path/to/PlexTranscoder -i /path/to/your/input/file.mp4 -t 120 -map 0 -c copy output.mp4

Arguments:

  • Default path to the transcoder:
    • Windows: C:\Program Files (x86)\Plex\Plex Media Server\PlexTranscoder.exe
    • OS X: /Applications/Plex Media Server.app/Contents/Resources/Plex Transcoder
    • Linux: /usr/lib/plexmediaserver/Resources/Plex Transcoder
  • "-t 120": the duration in seconds; in this case, the sample would be 2 minutes long

Tip!: The actual path to the transcoder may be different on your system. You'll also want to escape or quote paths as needed for your operating system.

Windows Example

Running from a command prompt (starting in "C:\users\youruser"):

"C:\Program Files (x86)\Plex\Plex Media Server\PlexTranscoder.exe" -i "C:\downloads\file.mp4" -t 120 -map 0 -c copy "output.mp4" 

This would create a "output.mp4" file in your "C:\downloads" directory with a 2 minute duration.

OS X Example

Running from the Terminal (starting in "~"):

/Applications/Plex\ Media\ Server.app/Contents/Resources/Plex\ Transcoder -i ~/Downloads/file.mkv -t 60 -map 0 -c copy output.mkv

This would create a "output.mkv" file in your "/users/youruser/Downloads/" directory (since that's what "~" indicates) with a 1 minute duration.