I want to download videos, but impossible with sites that i use as usual
link : https://www.tf1.fr/tf1/sept-a-huit/videos/sept-a-huit-life-du-dimanche-9-mai-2021-02981336.html
video downloader : https://www.videovor.com/fr/video-download-1
is there a dev who know how to fix this type of urls. i think content is blocked but maybe an experienced dev can help me to fix this because i really want to have methods to download this type of urls please,
many thanks
For general downloading of videos in Chrome (for Linux, Mac, Windows+cygwin):
Enable request logging to a json file from chrome://net-export/
Visit the site and play the video in Chrome
Stop logging
Extract .m3u8/.mp4 urls from the json file:
cat [json-file] | sed -n 's/.*"url":"\([^"]*\.m3u8\).*/- \1/p' | sort | uniq
cat [json-file] | sed -n 's/.*"url":"\([^"]*\.mp4\).*/- \1/p' | sort | uniq
Download url with ffmpeg (install if not on your system):
ffmpeg -i [url] -loglevel quiet -stats -c copy video.mp4
Note: This won't work if the site requires cookies to access the video url.
Related
I have a set of tests that downloads the latest Google Chrome from https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb and then parses the contents on https://chromedriver.chromium.org/downloads to figure out the right chrome driver version to download. The Chrome version eg: 102.0.5005.115, does not always match the chrome driver version, eg: 102.0.5005.61.
Currently, I parse the contents of https://chromedriver.chromium.org/downloads and try to figure out the right version. This is brittle as the HTML contents may change.
#!/bin/sh
GOOGLE_CHROME_VERSION="$(google-chrome --version | cut -f 3 -d ' ')"
# https://www.chromium.org/developers/version-numbers/
GOOGLE_CHROME_VERSION_MAJOR=$(echo "${GOOGLE_CHROME_VERSION}" | cut -f 1 -d'.')
echo "GOOGLE_CHROME_VERSION_MAJOR => [${GOOGLE_CHROME_VERSION_MAJOR}]"
# https://chromedriver.chromium.org/downloads
GOOGLE_CHROME_DRIVER_LINE=$(curl https://chromedriver.chromium.org/downloads | grep "If you are using Chrome version ${GOOGLE_CHROME_VERSION_MAJOR}," | head -1)
GOOGLE_CHROME_DRIVER_VERSION=$(echo "${GOOGLE_CHROME_DRIVER_LINE}" | rev | cut -f 1 -d' ' | rev)
echo "GOOGLE_CHROME_DRIVER_VERSION => [${GOOGLE_CHROME_DRIVER_VERSION}]"
wget https://chromedriver.storage.googleapis.com/${GOOGLE_CHROME_DRIVER_VERSION}/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
rm chromedriver_linux64.zip
chmod a+x chromedriver
mv chromedriver /usr/local/bin
Is there a simpler way to download a chrome driver for a specific version of google chrome?
https://chromedriver.chromium.org/downloads/version-selection
I hope this helps. Apparently, it supports some automated URL resolving:
First, find out which version of Chrome you are using. Let's say you have Chrome 72.0.3626.81.
Take the Chrome version number, remove the last part, and append the result to URL "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_". For example, with Chrome version 72.0.3626.81, you'd get a URL "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_72.0.3626".
Use the URL created in the last step to retrieve a small file containing the version of ChromeDriver to use. For example, the above URL will get your a file containing "72.0.3626.69". (The actual number may change in the future, of course.)
Use the version number retrieved from the previous step to construct the URL to download ChromeDriver. With version 72.0.3626.69, the URL would be "https://chromedriver.storage.googleapis.com/index.html?path=72.0.3626.69/".
After the initial download, it is recommended that you occasionally go through the above process again to see if there are any bug fix releases.
I try to stream my RTSP-IP-Camera on a website. I use the Nginx webserver. My source in the html-code is:
<source src=rtmp://ip-address:1935/live/ type="application/x-mpegURL" />
To convert the rtsp stream i use this ffmpeg code:
ffmpeg -rtsp_transport tcp -i rtsp://user:password#ip-camera:554/h264Preview_01_main -vcodec copy -acodec copy -f mp4 -y rtmp://ip-address:1935/live/
I get the error message "muxer does not support non seekable output
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument"
I also tried to convert the rtsp-camera into a mp4 file and then access the file as source in my html code, but i couldnt read the file while ffmpeg wrote in it.
If you need more information let me know.
Thank you and have a nice day.
First, you should use format flv, not mp4. More, you should specify a stream(StreamKey for obs) like livestream:
ffmpeg -rtsp_transport tcp -i rtsp://user:password#ip-camera:554/h264Preview_01_main -c copy \
-f flv -y rtmp://ip-address:1935/live/livestream
Then you covert RTSP to RTMP, and you can use server to covert the RTMP to HLS, like what you did.
The latency of HLS is large, about 5~10s, if you want to get lower latency, please use HTTP-FLV or WebRTC, see link here
I'm trying to run end-to-end testing in Chrome for a product that requires a webcam feed halfway through to operate. From what I understand this means providing a fake webcam video to Chrome using the --use-file-for-fake-video-capture="/path/to/video.y4m" command line argument. It will then use that as a webcam video.
However, no matter what y4m file I provide, I get the following error from Chrome running under these conditions:
DOMException: Could not start video source
{
code: 0,
message: "Could not start video source",
name: "NotReadableError"
}
Notably I can provide an audio file just fine using --use-file-for-fake-audio-capture and Chrome will work with it well. The video has been my sticking point.
This error comes out of the following straightforward mediaDevices request:
navigator.mediaDevices.getUserMedia({ video: true, audio: true })
.then(data => {
// do stuff
})
.catch(err => {
// oh no!
});
(This always hits the “oh no!” branch when a video file is provided.)
What I've tried so far
I've been running Chrome with the following command line arguments (newlines added for readability), and I'm using a Mac hence the open command:
open -a "Google Chrome" --args
--disable-gpu
--use-fake-device-for-media-stream
--use-file-for-fake-video-capture="~/Documents/mock/webcam.y4m"
--use-file-for-fake-audio-capture="~/Documents/mock/microphone.wav"
webcam.y4m and microphone.wav were generated from a video file I recorded.
I first recorded a twenty-second mp4 video using my browser's MediaRecorder, downloaded the result, and converted it using the following command line commands:
ffmpeg -y -i original.mp4 -f wav -vn microphone.wav
ffmpeg -y -i original.mp4 webcam.y4m
When this didn't work, I tried the same using a twenty-second movie file I recorded in Quicktime:
ffmpeg -y -i original.mov -f wav -vn microphone.wav
ffmpeg -y -i original.mov webcam.y4m
When that also failed, I went straight to the Chromium file that explains fake video capture, went to the example y4m file list it provided, and downloaded the grandma file and provided that as a command line argument to Chrome instead:
open -a "Google Chrome" --args
--disable-gpu
--use-fake-device-for-media-stream
--use-file-for-fake-video-capture="~/Documents/mock/grandma_qcif.y4m"
--use-file-for-fake-audio-capture="~/Documents/mock/microphone.wav"
Chrome provides me with the exact same error in all of these situations.
The only time Chrome doesn't error out with that mediaDevices request is when I omit the video completely:
open -a "Google Chrome" --args
--disable-gpu
--use-fake-device-for-media-stream
--use-file-for-fake-audio-capture="~/Documents/mock/microphone.wav"
Accounting for C420mpeg2
TestRTC suggests Chrome will “crash” if I give it a C420mpeg2 file, and recommends that simply replacing the metadata fixes the issue. Indeed the video file I generate from ffmpeg gives me the following header:
YUV4MPEG2 W1280 H720 F30:1 Ip A1:1 C420mpeg2 XYSCSS=420MPEG2
Chrome doesn't actually crash when run with this file, I just get the error above. If I edit the video file to the following header though per TestRTC's recommendations I get the same situation:
YUV4MPEG2 W1280 H720 F30:1 Ip A1:1 C420 XYSCSS=420MPEG2
The video file still gives me the above error in these conditions.
What can/should I do?
How should I be providing a video file to Chrome for this command line argument?
How should I be recording or creating the video file?
How should I convert it to y4m?
After reading the link you provided I noticed that we can also provide an mjpeg.
Depending on what your test requirements - this may be sufficient for you. As a terminal command with ffmpeg installed:
ffmpeg -i oldfile.mp4 newfile.mjpeg
then I tested by running Google Chrome from the terminal using:
google-chrome --use-fake-device-for-media-stream --use-file-for-fake-video-capture=newfile.mjpeg
After navigating to Tracking JS I could see the video being played back.
I hope that works for you!
If someone ever needs to mock a video dynamically, this is what I've used (forked from here)
await page.evaluate(() => {
const video = document.createElement("video");
video.setAttribute('id', 'video-mock');
video.setAttribute("src", 'https://woolyss.com/f/spring-vp9-vorbis.webm');
video.setAttribute("crossorigin", "anonymous");
video.setAttribute("controls", "");
video.oncanplay = () => {
const stream = video.captureStream();
navigator.mediaDevices.getUserMedia = () => Promise.resolve(stream);
};
document.querySelector("body").appendChild(video);
});
the key is to return Promise.resolve(stream)
oncanplay is better than onplay because it is triggered after the video is playable
This flags are still necessary:
'--use-fake-ui-for-media-stream',
'--use-fake-device-for-media-stream',
In the end, with this script different camera mocks are possible for every page - especially useful when using browserless!
Mocked/Fake Raw Video (2021)
Use y4m if you want raw frames without Chrome having to run a decoder:
ffmpeg -i original.avi -pix_fmt yuv420p video-for-chrome.y4m
Then, start Chrome:
chrome.exe --use-fake-device-for-media-stream --use-file-for-fake-video-capture=video-for-chrome.y4m
Note: There is no longer any reason to have to modify your y4m file's header. Chrome has since been fixed.
This method uses less CPU, but will take up a good deal of hard drive space for the raw video. Keep your video file short. Chrome will loop it.
How to mock webcam on Chrome for Windows
(Tested with Windows 10 Home Build 19043.1526 and Chrome Version 98.0.4758.102 (Official Build) (64-bit))
Install ffmpeg, then run the following command in your shell to convert your mp4 to mpjeg:
./ffmpeg.exe -i originalVideo.mp4 output.mjpeg
Alternatively, you could also create a y4m video from a png image (thanks #LGenzelis):
./ffmpeg.exe -loop 1 -i myStaticImage.png -pix_fmt yuv420p -t 0.05 output.y4m
Close all Chrome instances, then run the following command in your shell:
"C:\Program Files\Google\Chrome\Application\chrome.exe" --use-fake-device-for-media-stream --use-file-for-fake-video-capture="C:/absolute/path/to/output.mjpeg"
Then test it on a website like https://webcamtests.com/
Troubleshooting
Chrome still showing stream from real camera
Make sure there are no other Chrome instances running before launching it with those arguments.
Camera not found
Make sure you're providing the absolute path to your video in --use-file-for-fake-video-capture (e.g.: "C:/absolute/path/to/output.mjpeg" instead of just output.mjpeg)
So I've been trying to get wget to download a Google Drive file that I uploaded. Unfortunately, Google Drive incorrectly flags the file as a virus, so wget can't get the direct download link.
Things I've tried:
using the gdrive.pl fie that someone made, but I'm on Windows, and /tmp/cookies.txt does not exist.
doing wget --no-check-certificate https://docs.google.com/uc?export=download&id=FILEID -O FILENAME, but it says 400 Bad Request
using https://docs.google.com/uc?export=download&id=ID, but it fails because of the download infected file warning.
Does anyone have any suggestions to solve this?
Here is what I was able to do, based on a starting point I found at https://medium.com/#acpanjan/download-google-drive-files-using-wget-3c2c025a8b99 :
Edit I noticed you said Windows, so this command with sed won't work natively in Windows - I'll put steps without sed for Windows below
You of course start by sharing the file and getting the file ID from the share link on google drive. Then:
wget --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate "https://docs.google.com/uc?export=download&id=SHARE_LINK_ID" -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p' > /tmp/confirm && wget --load-cookies /tmp/cookies.txt --no-check-certificate "https://docs.google.com/uc?export=download&confirm="$(cat /tmp/confirm)"&id=SHARE_LINK_ID" -O YOUR_FILENAME && rm /tmp/cookies.txt /tmp/confirm
Replace SHARE_LINK_ID with your ID from your shared file link. Replace YOUR_FILENAME with your desired output file name.
This attempts to download the file and gets the html of the warning message about potential viruses in the file. It uses cookies as you need to use the same session ID for the subsequent download with the confirmation code.
It then gets the generated confirm code from that response and writes it to a temporary file.
I then does another wget adding the confirmation code to the query string to download the file, using the saved cookie to allow the confirmation code to work for the saved session.
Most likely this could be worked into a script, passing an argument of the share link ID to make it more useful.
For Windows (without sed)
wget --save-cookies %TMP%/cookies.txt --keep-session-cookies --no-check-certificate "https://docs.google.com/uc?export=download&id=SHARE_LINK_ID" -O %TMP%/confirm.txt
Downloads the confirmation html.
notepad %TMP%/confirm.txt
Opens %TMP%/confirm.txt in Notepad to get the confirm code string (CTRL+F to look for "confirm=" and get the code right after that). Replace it in the below command line (along with putting in the filename you want and the share link ID from google drive)
wget --load-cookies %TMP%/cookies.txt --no-check-certificate "https://docs.google.com/uc?export=download&confirm=CONFIRM_CODE&id=SHARE_LINK_ID" -O YOUR_FILENAME
Delete the temp files:
del %TMP%/cookies.txt %TMP%/confirm.txt
Try this. Don't forget to replace two FILEID and one FILENAME fields with your desired file's file id and the output file's name respectively.
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=FILEID' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=FILEID" -O FILENAME && rm -rf /tmp/cookies.txt
source: https://medium.com/geekculture/wget-large-files-from-google-drive-336ba2e1c991
A little bit of background: I am trying to create a Google Chrome that will play videos in your browser locally. Meaning it should be able to play without an Internet connection. Since I'm only using HTML/Javascript, I can only play webm, mp4, and ogg files. However, I am interested in playing other formats, such as AVI, MPG, and maybe a few others. I was thinking of creating a local server somehow where I can run ffmpeg to encode the videos to webm/mp4. So my main objective is to get ffmpeg to run. Is this possible?
Not just using html5 and javascript. If you have the option of running a local webserver than you can run any executable you want, including ffmpeg. You'll basically be calling a server side process (using php, java, or whatever) which happens to be running locally.
Download FFMPEG.EXE from here
Extract the FFMPEG.EXE from the archive.
Place the FFMPEG.EXE in the webdirectory.
As you all know how to upload a file (So i'm moving to the next step).
After the file uploaded just put the below line
exec("ffmpeg -i recipe_videos/$path -f flv recipe_videos/$test[0].flv");
//Format exec("ffmpeg -i pathofthevideouploaded -f towhichformat wherethefiletobesavedwithextension");
If you want delete the old file.
Now you can view the video in the desired format.
What you're trying to do is impossible. The browser prevents the server from accessing the user's computer (including running programs). You'll either need to transcode the videos on the server before serving them or have the user download FFmpeg and transcode the videos themselves.