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

find_streams fails due to ffprobe output variations #29

Closed
tve opened this issue Apr 10, 2022 · 1 comment
Closed

find_streams fails due to ffprobe output variations #29

tve opened this issue Apr 10, 2022 · 1 comment

Comments

@tve
Copy link

tve commented Apr 10, 2022

Trying to use gopro_join today I got an error:

$ ~/Projects/Navigation/gopro-overlay/bin/gopro-join.py ./GH100278.MP4
concat.mp4
Found: ['GH010278.MP4', 'GH020278.MP4', 'GH030278.MP4', 'GH040278.MP4', 'GH050278.MP4', 'GH060278.MP
4', 'GH070278.MP4', 'GH080278.MP4', 'GH090278.MP4', 'GH100278.MP4']
ffprobe --hide_banner ./GH010278.MP4
video: None audio: None meta: None video_dimension: None
Traceback (most recent call last):
  File "/home/tve/Projects/Navigation/gopro-overlay/bin/gopro-join.py", line 31, in <module>
    join_files(
  File "/home/Projects/Navigation/gopro-overlay/bin/../gopro_overlay/ffmpeg.py", line 52, in join_fi
les
    streams = find_streams(filepaths[0])
  File "/home/Projects/Navigation/gopro-overlay/bin/../gopro_overlay/ffmpeg.py", line 104, in find_s
treams
    raise IOError("Invalid File? The data stream doesn't seem to contain GoPro audio, video & metada
ta ")
OSError: Invalid File? The data stream doesn't seem to contain GoPro audio, video & metadata

The reason is that the regexp used in find_streams does not match the ffprobe output:

$ ffprobe -hide_banner -print_format json ./GH010278.MP4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './GH010278.MP4':
[...]
  Stream #0:0[0x1](eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt709, progressive), 2
704x1520 [SAR 1:1 DAR 169:95], 60003 kb/s, 59.94 fps, 59.94 tbr, 60k tbn (default)

Notice the [0x1]. While it's easy to fix the regexp, IMHO the proper fix would be to parse the json output of ffprobe:

ffprobe -hide_banner -print_format json -show_streams ./GH010278.MP4 2>/dev/null
{
    "streams": [
        {
            "index": 0,
            "codec_name": "h264",
            "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
            "profile": "High",
            "codec_type": "video",
            "codec_tag_string": "avc1",
            "codec_tag": "0x31637661",
            "width": 2704,
            "height": 1520,
            "coded_width": 2704,
            "coded_height": 1520,
            "closed_captions": 0,
...
@time4tea
Copy link
Owner

Interesting, didn't even know ffprobe had a json output. Yes, much easier to parse that, probably! Thanks!
👍

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