Skip to content
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

RTVE.es videos [rtve.alacarta] aren't fluid #25382

Open
5 tasks done
gcapizzi opened this issue May 23, 2020 · 7 comments
Open
5 tasks done

RTVE.es videos [rtve.alacarta] aren't fluid #25382

gcapizzi opened this issue May 23, 2020 · 7 comments

Comments

@gcapizzi
Copy link

gcapizzi commented May 23, 2020

Checklist

  • I'm reporting a broken site support
  • I've verified that I'm running youtube-dl version 2020.05.08
  • I've checked that all provided URLs are alive and playable in a browser
  • I've checked that all URLs and arguments with special characters are properly quoted or escaped
  • I've searched the bugtracker for similar issues including closed ones

Verbose log

❯ youtube-dl -v --external-downloader aria2c --external-downloader-args '-c -j 3 -x 3 -s 3 -k 1M' --all-subs --embed-subs --postprocessor-args '-fflags +igndts' https://www.rtve.es/alacarta/videos/estoy-vivo/estoy-vivo-capitulo-1/4203918/
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-v', u'--external-downloader', u'aria2c', u'--external-downloader-args', u'-c -j 3 -x 3 -s 3 -k 1M', u'--all-subs', u'--embed-subs', u'--postprocessor-args', u'-fflags +igndts', u'https://www.rtve.es/alacarta/videos/estoy-vivo/estoy-vivo-capitulo-1/4203918/']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2020.05.08
[debug] Python version 2.7.16 (CPython) - Darwin-19.3.0-x86_64-i386-64bit
[debug] exe versions: avconv 12.3, avprobe 12.3, ffmpeg 4.2.2, ffprobe 4.2.2, rtmpdump 2.4
[debug] Proxy map: {}
[rtve.es:alacarta] Fetching manager info
[rtve.es:alacarta] 4203918: Downloading JSON metadata
[rtve.es:alacarta] 4203918: Downloading url information
[rtve.es:alacarta] 4203918: Downloading m3u8 information
[rtve.es:alacarta] 4203918: Downloading subtitles info
[debug] Default format spec: bestvideo+bestaudio/best
[info] Writing video subtitles to: Estoy vivo - Temporada 1 - Capítulo 1-4203918.es.vtt
[debug] Invoking downloader on u'https://rtve-hlsvod.secure.footprint.net/resources/TE_GL23/mp4/4/2/1504716904424.mp4/1504716904424-audio_eng=96000-video_eng=1493000.m3u8?hls_minimum_fragment_length=6&hls_client_manifest_version=3'
[download] Destination: Estoy vivo - Temporada 1 - Capítulo 1-4203918.mp4
[download] 100% of 797.72MiB
[debug] ffmpeg command line: ffprobe -show_streams 'file:Estoy vivo - Temporada 1 - Capítulo 1-4203918.mp4'
[ffmpeg] Fixing malformed AAC bitstream in "Estoy vivo - Temporada 1 - Capítulo 1-4203918.mp4"
[debug] ffmpeg command line: ffmpeg -y -loglevel 'repeat+info' -i 'file:Estoy vivo - Temporada 1 - Capítulo 1-4203918.mp4' -c copy -f mp4 '-bsf:a' aac_adtstoasc -fflags '+igndts' 'file:Estoy vivo - Temporada 1 - Capítulo 1-4203918.temp.mp4'
[ffmpeg] Embedding subtitles in 'Estoy vivo - Temporada 1 - Capítulo 1-4203918.mp4'
[debug] ffmpeg command line: ffmpeg -y -loglevel 'repeat+info' -i 'file:Estoy vivo - Temporada 1 - Capítulo 1-4203918.mp4' -i 'file:Estoy vivo - Temporada 1 - Capítulo 1-4203918.es.vtt' -map 0 -c copy -map '-0:s' -map '-0:d' '-c:s' mov_text -map '1:0' '-metadata:s:s:0' 'language=spa' -fflags '+igndts' 'file:Estoy vivo - Temporada 1 - Capítulo 1-4203918.temp.mp4'
Deleting original file Estoy vivo - Temporada 1 - Capítulo 1-4203918.es.vtt (pass -k to keep)

Description

After post-processing, videos downloaded from RTVE Alacarta don't look fluid. This is due to the TS stream containing invalid PTS and ffmpeg correcting them in a way that results in non-fluid playback. More details can be found at this SO answer.

As the answer suggests, this can be fixed by using ffmpeg's igndts format flag. I'm trying to pass --postprocessor-args '-fflags +igndts' to youtube-dl but it's not helping, as ffmpeg options need to be specified before the file they apply on:

As a general rule, options are applied to the next specified file. Therefore, order is important, and you can have the same option on the command line multiple times. Each occurrence is then applied to the next input or output file. Exceptions from this rule are the global options (e.g. verbosity level), which should be specified first.

This is unfortunate, as output options only work when applied before the output file (but after the input file) and viceversa. We have no way to tell what the user wants, unless we introduce separate options for input args and output args.

My questions:

  • Would it make sense to introduce a --postprocessor-input-args flag?
  • How can we fix this for everyone using the RTVE extractor? Do we have a way to customise post-processing for specific websites?

Happy to help with PRs once we find out a way forward. Thanks!

@felisucoibi
Copy link

I've never had problems with rtve videos, maybe is your ffmeg config? Tell me example

@gcapizzi
Copy link
Author

@felisucoibi nope, you can see the ffmpeg command in the debug output. Also, I have a local copy of youtube-dl patched to put the opts before the input files and it fixes the problem.

For a video example of the problem + an explanation of why it happens and a fix, see the Stack Overflow answer I linked to.

@felisucoibi
Copy link

felisucoibi commented May 24, 2020

If you can give me a example of video of rtve with this problem, i don't have any problems and i downloaded a lot fo them. (or maybe i don't see it, please give a example), wait you mean this "fixing malformed aac)

@gcapizzi
Copy link
Author

gcapizzi commented May 24, 2020 via email

@felisucoibi
Copy link

And you can see the problem when watching the video? i never noticed something strange in the video.

@gcapizzi
Copy link
Author

gcapizzi commented May 24, 2020

Have you tried my example? The playback it not fluid and almost trembling, like this example.

If you try to run the ffmpeg command manually, you'll see a lot of errors like these:

[mpegts @ 0x7fabfe802a00] Invalid timestamps stream=1, pts=21153600, dts=21160800, size=1936
[mpegts @ 0x7fabfe802a00] Invalid timestamps stream=1, pts=21160800, dts=21164400, size=2827
[mp4 @ 0x7fabff005000] Invalid DTS: 10800 PTS: 3600 in output stream 0:0, replacing by guess
[mp4 @ 0x7fabff005000] Invalid DTS: 14400 PTS: 10800 in output stream 0:0, replacing by guess

The reason is that the RTVE stream has invalid presentation timestamps. Here is an explanation from someone who helped me fix the issue:

Frames in video streams with B-frames are not encoded or stored in presentation order, so the presentation timestamps have to be correctly offset for fluid playback. In this TS sample, you have presentation timestamps earlier than decoding timestamps, which are invalid, and ffmpeg defaults to assigning the DTS as the new PTS.

This can be fixed by passing -fflags +igndts to ffmpeg before the input file, e.g.:

ffmpeg -fflags +igndts -i all.ts -c copy all.mp4

@felisucoibi
Copy link

There is PR to fix this? some of the movies downloaded from rtve does not andthere are errors in the mkv probably due to this sync problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants