-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
After downloading and transferring to the phone, the video doesn't have any audio #37
Comments
So be aware that twitter's gif system encodes all gifs as MP4s, so the video you're looking at may never had audio. Can you post the link? |
|
It's I googled
Looks like they use some shitty muxer software ("Twitter-vork muxer") that produces bad-supported mp4 files.
These mp4 files work fine in Media Player Classic (MPC-HC) on Windows, but VLC plays them without sound. For example, a remux (repacking from mp4 to mp4 without re-encoding*) created with ffmpeg works fine in VLC player: ffmpeg.exe -i video.mp4 -c copy -map 0 -map_metadata 0 video.remux.mp4 Note *With ffmpeg's Tip BTW, additionally you can use:
So, Twitter's encoding (video and audio streams) is fine, but Twitter's mp4 container has issues. BTW, ffmpeg prints the follow warnings while remuxing: [mp4 @ 000001b886d78340] Non-monotonous DTS in output stream 0:0; previous: 107200, current: 107000; changing to 107201. This may result in incorrect timestamps in the output file.
[mp4 @ 000001b886d78340] Non-monotonous DTS in output stream 0:0; previous: 1655320, current: 1655120; changing to 1655321. This may result in incorrect timestamps in the output file.
[mp4 @ 000001b886d78340] Non-monotonous DTS in output stream 0:0; previous: 1691320, current: 1691120; changing to 1691321. This may result in incorrect timestamps in the output file.
... |
link:https://twitter.com/fluffiefifi/status/1734723306400752025 |
Thanks AlttiRi for getting back to me. Since I haven't learned programming, do I tackle this issue myself or are you going to help fix it later? |
Well, technically the script works as intended — it downloads the original (after Twitter's enconing) mp4 files in the best available quality, with sound, as gallery-dl does. There is the audio stream in this mp4 file, but your device just can't play the file correctly. On Windows and on Android it plays fine everywhere except VLC player. BTW, as far I know, Apple devices also can't play The possible fix is to remux (repack) the downloaded video and audio streams (without re-encoding/transcoding, so the quality will be absolutely the same) from "bad" Twitter's mp4 container to a "more correct" mp4 container. Possibly (I need to test it), remuxing can be optionally done inside a user script with https://github.com/Kagami/ffmpeg.js, although it seems for me it's a bit out of scope for this script. |
Twitter have already updated the setting of its encoder, so the new mp4 files should be played correctly on Apple devices and in VLC player. However, the files uploaded to Twitter from 2023.11.30 until 2023.12.15* will have the problematic mp4 container anyway. Here is a Bash command to create remux files with ls -1 *.mp4 | \
grep -Ev '\.remux\.mp4$' | \
grep -E '^\[twitter\].+2023\.(12\.(0[0-9]|1[0-4])|11\.30)' | \
while read file; do
output="${file%.mp4}.remux.mp4";
ffmpeg.exe \
-i "$file" `# input file` \
-c copy `# do not re-encode` \
-map 0 `# copy all streams` \
-map_metadata 0 `# save all metadata` \
-fflags bitexact `# do not add the encoder name metadata` \
-movflags faststart `# web optimisation` \
-loglevel error `# do not print logs` \
-n `# do not overwrite already created .remux.mp4` \
"$output" `# output file` \
< /dev/null; `# to close the stdin of the ffmpeg`
echo "$output";
done; It selects all * from ~"UTC 2023-11-30 15:00:00" to ~"UTC 2023-12-14 22:00:00" Compact version: ls -1 *.mp4 | grep -Ev '\.remux\.mp4$' | \
grep -E '^\[twitter\].+2023\.(12\.(0[0-9]|1[0-4])|11\.30)' | \
while read file; do
output="${file%.mp4}.remux.mp4";
ffmpeg.exe -i "$file" -c copy -map 0 -map_metadata 0 -fflags bitexact -movflags faststart -loglevel error -n "$output" < /dev/null;
echo "$output";
done; Without the second row it will work for every .mp4 file in a folder. |
Hi AlttiRi, thanks a bunch for the update! After downloading it from the computer and transferring it to my iPhone using LANDrop, the video's audio is working fine now. Appreciate it! |
Hey there, today I downloaded a video from Twitter and used LANDrop to transfer it to my phone, but it turns out the video had no audio. At first, I thought it was a LANDrop issue, but the same happened with other transfer methods. Then, I tried downloading Twitter videos using other methods and used LANDrop again to transfer them to my phone, and those videos had audio. Not sure if it's a bug, but hoping you can help resolve this. Thanks.
The text was updated successfully, but these errors were encountered: