Project Background
In today's information society, video learning has become an important way to acquire knowledge. However, many users are often less efficient than expected in watching videos. In order to improve the learning efficiency, we decided to develop a project to convert MP4 videos to TXT texts. In addition, many videos are played on WeChat web pages, which cannot be downloaded directly and are mainly streamed in M3U8 format. This prompted us to look for a solution.
Purpose of the project
- Enhance Learning Efficiency: By converting video to text, users can directly access the content of the text, improving learning efficiency.
- Realize resource download: For WeChat videos in M3U8 format, the download function is realized by specific scripts.
prescription
- For Question 1: MP4 to TXT Conversion Project
We created a new project on GitHub calledmp4-to-txt-using-ffmpeg-wenetThe aim of this project is to provide an efficient way to extract MP4 video content into TXT text. The project aims to provide an efficient way to extract MP4 video content into TXT text. The project includes detailed README documentation to help users use the tool smoothly. - In response to Question 2: Downloading the M3U8 video
In order to solve the problem that M3U8 video cannot be downloaded directly from WeChat web page, we have written a shell script. The script uses the FFmpeg tool to download the M3U8 video stream. Here is the code of the script:
/bin/bash /bin/bash
urls=(
"https://xxx" # Replace here with the actual URL of the video
"https://xxx" # You can add more links to the video
)
for ((i=0; i<${#urls[@]}; i++)); do
# Calculate the file names, numbering them from 0
file_num=$((i))
file_name="${file_num}.mp4"
# Use ffmpeg to download and convert (note: it is assumed here that ffmpeg can handle .m3u8 directly)
# If .m3u8 is an HLS playlist, you may need additional steps to merge the clips
ffmpeg -i "${urls[$i]}" -c copy "${file_name}"
# Output information that the file has been downloaded
echo "Downloaded: ${file_name}"
done
Instructions for use
Replace URL: In the urls array in the script, replace "https://xxx" with the actual M3U8 video link. If there are multiple videos, you can continue to append links in this format.
Find the M3U8 URL:
Copy the WeChat video page into Chrome.
Press F12 to open Developer Tools and switch to the Network tab.
Press F5 to refresh the page and type m3u8 in the filter field to retrieve the message.
Find the corresponding M3U8 message and look for the URL of the GET request in its header.
Run the script: Make sure FFmpeg is installed, then run the script in the terminal and wait for the download to complete.
summarize
This program effectively solves the problem of inefficient video learning and the problem of not being able to directly download M3U8 videos from WeChat web pages. We hope this program can help more learners to easily access the information they need and effectively improve their learning efficiency. If you have any questions, please refer to the detailed documentation in the GitHub project or contact us through comments.