Skip to content

Instantly share code, notes, and snippets.

@mfd
Last active February 23, 2025 20:28
Show Gist options
  • Save mfd/c990a01d626847a6d7e823dceca598e1 to your computer and use it in GitHub Desktop.
Save mfd/c990a01d626847a6d7e823dceca598e1 to your computer and use it in GitHub Desktop.
Download any video from Microsoft Teams, SharePoint and OneDrive
2teams() {
NOW=$(date +"%Y-%m-%d_%H%M")
if [ ! -z $2 ] ; then
echo $NOW"_"$2.mp4
ffmpeg -i $1 -codec copy $NOW"_"$2.mp4
else
echo $NOW"_teamsvid".mp4
ffmpeg -i $1 -codec copy $NOW"_teamsvideo".mp4
fi
}

Download any video from Microsoft Teams, SharePoint and OneDrive

Videos like

- https://{ORGID}.sharepoint.com/personal/{USERID}/_layouts/15/stream.aspx?id={VIDEOID}%2Emp4&ga=1
- https://{ORGID}.sharepoint.com/:v:/p/{USERID}/{VIDEOID}
  1. Run video from SharePoint corporate account or OneDrive,
  2. In Chrome open Web inspector and in Network filter by videomanifest
  3. Copy this url
  4. Run ffmpeg -i "%URL%" -codec copy outputvideo.mp4

chrome

@alfoirazabal
Copy link

THX 🙏🙏🙏

@mircsicz
Copy link

I currently have a link to a video where this good ol Trick won't do any good :-(

Not saying it's bad, has served already a bunch of times! Just saying there are times when it doesnt...

@anishbishnoi127
Copy link

please explain carefully i didn't understand.

@vitkolar
Copy link

vitkolar commented Sep 4, 2024

It used to work for me, unfortunately now I get:
[dash @ 000000000013c500] Error when loading first fragment of playlist
[in#0 @ 00000000000eb540] Error opening input: Invalid data found when processing input
Error opening input file video.txt.
Error opening input files: Invalid data found when processing input

@IronWill2024
Copy link

It used to work for me, unfortunately now I get: [dash @ 000000000013c500] Error when loading first fragment of playlist [in#0 @ 00000000000eb540] Error opening input: Invalid data found when processing input Error opening input file video.txt. Error opening input files: Invalid data found when processing input

same issues. that shell script use for what?

@guangxuanliu
Copy link

This method has failed, is there a new way?

@Adamus2396
Copy link

It doesn't work for me anymore, maybe there is a new solution?

@rbp9802
Copy link

rbp9802 commented Oct 29, 2024

@Adamus2396 @guangxuanliu @IronWill2024 @vitkolar
This solution works for me for sharepoint videos, it uses yt-dlp downloader

yt-dlp "URL until dash" -o "video.mp4"

@guangxuanliu
Copy link

Hi @rbp9802 , Thank you very much.
Do you know how to download the transcription?

@rbp9802
Copy link

rbp9802 commented Oct 29, 2024

I don't know, check the subtitle options

@IronWill2024
Copy link

@Adamus2396 @guangxuanliu @IronWill2024 @vitkolar This solution works for me for sharepoint videos, it uses yt-dlp downloader

yt-dlp "URL until dash" -o "video.mp4"

Thank u. it work!

@ShaunMaher
Copy link

The ffmpeg method also didn't work for me, using the full videomanifest URL. yt-dlp did work with the URL truncated after &format=dash. Thought I'd try the truncated URL with ffmpeg and it also worked.

So, yt-dlp and ffmpeg both worked for me, after truncating the URL.

@Adamus2396
Copy link

@rbp9802, @ShaunMaher thank you very much, both solutions work.

@rbp9802
Copy link

rbp9802 commented Oct 30, 2024

@ShaunMaher thank you for your feedback! In my case, yt-dlp was much faster.

@guangxuanliu could you share your code for downloading the transcription with ffmpeg or yt-dlp?

@guangxuanliu
Copy link

@rbp9802 I don't know how to download the transcription, but I found this, it may be need a little conversion.
If you know the downloading transcription method, please let us know.

@grpatter
Copy link

grpatter commented Nov 1, 2024

If you search for streamContent?format=json in network assets, you can find the URL for the transcript. It's in a fully formatted json notation though, so you'd have to convert it if you intend to do any analysis or manipulation.

Ex:
image

@shebenu
Copy link

shebenu commented Nov 23, 2024

@ShaunMaher @rbp9802 Can it work for Microsoft stream / teams view-only recordings? how to rephrase link?

@Nehal16237
Copy link

@shebenu Yes, It can work for ms stream , just do those steps

  1. Run video from SharePoint corporate account or OneDrive,
  2. In Chrome open Web inspector and in Network filter by videomanifest
  3. Copy this url
  4. Go to notepad and paste this url
  5. Delete the section starts with "&alt...." till the end of the url
  6. Copy the new url
  7. Go to windows powershell and run it as admin..
  8. Write this command
    ffmpef -i "new url" - videoname.mp4
    AND JUST WAIT!

@coffee0818
Copy link

@shebenu Yes, It can work for ms stream , just do those steps

  1. Run video from SharePoint corporate account or OneDrive,
  2. In Chrome open Web inspector and in Network filter by videomanifest
  3. Copy this url
  4. Go to notepad and paste this url
  5. Delete the section starts with "&alt...." till the end of the url
  6. Copy the new url
  7. Go to windows powershell and run it as admin..
  8. Write this command
    ffmpef -i "new url" - videoname.mp4
    AND JUST WAIT!

Thank you for your summary. That works for me.

@thyarles
Copy link

thyarles commented Jan 7, 2025

I just tried with ffmpeg and it worked like a charm. You must keep the URL until de dash part.

Example of URL (this will not work as I changed the IDs and the host, get yours like explained before):

ffmpeg -i "https://host-mediap.svc.ms/transform/videomanifest?provider=spo&inputFormat=mp4&cs=fFNQTw&correlationId=024475a1-903a-5000-3ead-&docid=https%3A%2F%my.sharepoint.com%2F%2F01ULWEOFMXKBGYPXHCANH3U2Q4R4ZQOBD7%3Ftempauth%3Dv1.eyJzaXRlaWQiOiJkMTk3N2Y4Zi01ZjZhLTRkMTMtYTFjYS0zYmI0N2U2YWFiNjkiLCJhdWQiOiIwMDAwMDAwMy0wMDAwLTCmZjEtY2UwMC0wMDAwMDAwMDAwMDAvdW5iYnItbXkuc2hhcmVwb2ludC5jb21AZWMzNTliYTEtNjMwYi00ZDJiLWI4MzMtYzhlNmQ0OGY5MDU5IiwiZXhwIjoiMTczNjI5Njk0OCJ9.CgoKBHNuaWQSAjI5EgsIpNq4n6LV1z0QBRoNMTc3LjIwMS7yOC41OCIUbWljcm9zb2Z0LnNoYXJlcG9pbnQqLFB2QjBLRG9BRGZ4VS9JQzQ5czFvSGIwSjcwaXJUL2ZoejhpMEJjNGlPMTg9MLYBOAFCEKF1RAI6kABQPq1t6hwHA0lKEGhhc2hlZHByb29mdG9rZW5iBHRydWVqJGFjNmNlNWJhLWYwZTMtNGFkYi1hYmE0LTFiNGQ3MzI3NGI3OXIpMGguZnxtZW1iZXJzaGlwfDEwBBByMDAzZGE4ZDZjMjFAbGl2ZS5jd216ATDCASYwIy5mfG1lbWJlcnNoaXB8MjQyMTAxMjYzQGFsdW5vLnVuYi5icsgBAQ.PlMSwnjqzU42dB9MUrbJPTnnv9y2X3OLwlFiRJBgxF0%26version%3DPublished&psi=06b8256c-5d88-123b-99ac-e0098993ff6e&enhanceAudio=true&cTag=%22c%3A%7B874D5097-123-4F03-123-1C8F3307047F%7D%2C2%22&action=Access&part=index&format=dash" -codec copy output.mp4

Thanks for the tips.

@tigaszzz
Copy link

@shebenu Yes, It can work for ms stream , just do those steps

  1. Run video from SharePoint corporate account or OneDrive,
  2. In Chrome open Web inspector and in Network filter by videomanifest
  3. Copy this url
  4. Go to notepad and paste this url
  5. Delete the section starts with "&alt...." till the end of the url
  6. Copy the new url
  7. Go to windows powershell and run it as admin..
  8. Write this command
    ffmpef -i "new url" - videoname.mp4
    AND JUST WAIT!

perfect! tks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment