open-mmlab / mmaction2

OpenMMLab's Next Generation Video Understanding Toolbox and Benchmark
https://mmaction2.readthedocs.io
Apache License 2.0
4.24k stars 1.24k forks source link

k400 video input : [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56424560de40] moov atom not found #1415

Closed JXIONG008 closed 2 years ago

JXIONG008 commented 2 years ago

Thanks for your error report and we appreciate it a lot. If you feel we have help you, give us a STAR! :satisfied:

Checklist

  1. I have searched related issues but cannot get the expected help. ☑️
  2. The bug has not been fixed in the latest version. ☑️

Describe the bug

Reproduction

  1. What command or script did you run?
python tools/train.py configs/recognition/tsn/tsn_r50_video_mixup_1x1x8_100e_kinetics400_rgb.py
  1. Did you make any modifications on the code or config? Did you understand what you have modified? No.

  2. What dataset did you use? Kinetics400

Environment

  1. Please run PYTHONPATH=${PWD}:$PYTHONPATH python mmaction/utils/collect_env.py to collect necessary environment information and paste it here.

sys.platform: linux Python: 3.8.12 (default, Oct 12 2021, 13:49:34) [GCC 7.5.0] CUDA available: True GPU 0,1,2,3: GeForce GTX 1080 Ti CUDA_HOME: /usr/local/cuda NVCC: Cuda compilation tools, release 9.2, V9.2.148 GCC: gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 PyTorch: 1.10.1 PyTorch compiling details: PyTorch built with:

TorchVision: 0.11.2 OpenCV: 4.5.4 MMCV: 1.4.2 MMCV Compiler: GCC 7.3 MMCV CUDA Compiler: 10.2 MMAction2: 0.20.0+6fb9f47

  1. You may add addition that may be helpful for locating the problem, such as
    • UCF101 and HMDB51 works perfectly

Error traceback

If applicable, paste the error traceback here.

2022-02-02 19:41:46,594 - mmaction - INFO - workflow: [('train', 1)], max: 100 epochs
2022-02-02 19:41:46,595 - mmaction - INFO - Checkpoints will be saved to /home/students/s121md104_06/FYP/mmaction2/work_dirs/tsn_r50_video_mixup_1x1x8_100e_kinetics400_rgb by HardDiskBackend.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x56424560de40] moov atom not found
[19:42:56] /github/workspace/src/video/video_reader.cc:83: ERROR opening: , Invalid data found when processing input
Traceback (most recent call last):
  File "tools/train.py", line 201, in <module>
    main()
  File "tools/train.py", line 189, in main
    train_model(
  File "/home/students/s121md104_06/FYP/mmaction2/mmaction/apis/train.py", line 203, in train_model
    runner.run(data_loaders, cfg.workflow, cfg.total_epochs, **runner_kwargs)
  File "/home/students/s121md104_06/anaconda3/envs/open-mmlab-test/lib/python3.8/site-packages/mmcv/runner/epoch_based_runner.py", line 127, in run
    epoch_runner(data_loaders[i], **kwargs)
  File "/home/students/s121md104_06/anaconda3/envs/open-mmlab-test/lib/python3.8/site-packages/mmcv/runner/epoch_based_runner.py", line 50, in train
    self.run_iter(data_batch, train_mode=True, **kwargs)
  File "/home/students/s121md104_06/anaconda3/envs/open-mmlab-test/lib/python3.8/site-packages/mmcv/runner/epoch_based_runner.py", line 29, in run_iter
    outputs = self.model.train_step(data_batch, self.optimizer,
  File "/home/students/s121md104_06/anaconda3/envs/open-mmlab-test/lib/python3.8/site-packages/mmcv/parallel/data_parallel.py", line 75, in train_step
    return self.module.train_step(*inputs[0], **kwargs[0])
  File "/home/students/s121md104_06/FYP/mmaction2/mmaction/models/recognizers/base.py", line 300, in train_step
    losses = self(imgs, label, return_loss=True, **aux_info)
  File "/home/students/s121md104_06/anaconda3/envs/open-mmlab-test/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/students/s121md104_06/FYP/mmaction2/mmaction/models/recognizers/base.py", line 262, in forward
    return self.forward_train(imgs, label, **kwargs)
  File "/home/students/s121md104_06/FYP/mmaction2/mmaction/models/recognizers/recognizer2d.py", line 23, in forward_train
    x = self.extract_feat(imgs)
  File "/home/students/s121md104_06/anaconda3/envs/open-mmlab-test/lib/python3.8/site-packages/mmcv/runner/fp16_utils.py", line 98, in new_func
    return old_func(*args, **kwargs)
  File "/home/students/s121md104_06/FYP/mmaction2/mmaction/models/recognizers/base.py", line 163, in extract_feat
    x = self.backbone(imgs)
  File "/home/students/s121md104_06/anaconda3/envs/open-mmlab-test/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/students/s121md104_06/FYP/mmaction2/mmaction/models/backbones/resnet.py", line 546, in forward
    x = res_layer(x)
  File "/home/students/s121md104_06/anaconda3/envs/open-mmlab-test/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/students/s121md104_06/anaconda3/envs/open-mmlab-test/lib/python3.8/site-packages/torch/nn/modules/container.py", line 141, in forward
    input = module(input)
  File "/home/students/s121md104_06/anaconda3/envs/open-mmlab-test/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/students/s121md104_06/FYP/mmaction2/mmaction/models/backbones/resnet.py", line 215, in forward
    out = _inner_forward(x)
  File "/home/students/s121md104_06/FYP/mmaction2/mmaction/models/backbones/resnet.py", line 203, in _inner_forward
    out = self.conv3(out)
  File "/home/students/s121md104_06/anaconda3/envs/open-mmlab-test/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/students/s121md104_06/anaconda3/envs/open-mmlab-test/lib/python3.8/site-packages/mmcv/cnn/bricks/conv_module.py", line 203, in forward
    x = self.norm(x)
  File "/home/students/s121md104_06/anaconda3/envs/open-mmlab-test/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/students/s121md104_06/anaconda3/envs/open-mmlab-test/lib/python3.8/site-packages/torch/nn/modules/batchnorm.py", line 168, in forward
    return F.batch_norm(
  File "/home/students/s121md104_06/anaconda3/envs/open-mmlab-test/lib/python3.8/site-packages/torch/nn/functional.py", line 2282, in batch_norm
    return torch.batch_norm(
RuntimeError: CUDA out of memory. Tried to allocate 784.00 MiB (GPU 0; 10.92 GiB total capacity; 9.38 GiB already allocated; 761.06 MiB free; 9.40 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation.  See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

Bug fix

If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!

cliangyu commented 2 years ago

Seems running out GPU. Have you tried reducing BS (batch size)? Possibly Kinetics400 data is larger than UCF.

cliangyu commented 2 years ago

For moov atom not found error, I referred to #1093 Iterate all videos and see 1) how many videos are "broken"? 2) Can you open them manually in video player?

JXIONG008 commented 2 years ago

For moov atom not found error, I referred to #1093 Iterate all videos and see 1) how many videos are "broken"? 2) Can you open them manually in video player?

Hi Liangyu, thanks for your prompt reply.

  1. I did suspect this problem, but I had no clue how to iterate all the videos to see if they are corrupted.
  2. I manually checked some videos on a random basis, they worked fine.
cliangyu commented 2 years ago

Two suggested to-do

  1. resolve the CUDA out of memory first, so we can locate the related code more precisely.
  2. Check this out (https://repairit.wondershare.com/video-repair/moov-atom-not-found.html#:~:text=The%20reason%20for%20this%20error,there%20when%20the%20recording%20ends.), maybe method 2 is a good fix.
JXIONG008 commented 2 years ago

Two suggested to-do

  1. resolve the CUDA out of memory first, so we can locate the related code more precisely.
  2. Check this out (https://repairit.wondershare.com/video-repair/moov-atom-not-found.html#:~:text=The%20reason%20for%20this%20error,there%20when%20the%20recording%20ends.), maybe method 2 is a good fix.

in reply to point 2, I am trying to process all the corrupted files by a python loop, but the subprocess is not working as expected, or to be more specific, the function.

my code:

import os
from sys import stdout
import pandas as pd
import subprocess

def fix():

    df= pd.read_csv('/home/students/s121md104_06/FYP/mmaction2/data/kinetics400/annotations/kinetics_val.csv')
    des_root = '/home/students/s121md104_06/FYP/mmaction2/data/k400-fix/videos_val'

    for root, dirs, files in os.walk("/home/students/s121md104_06/FYP/mmaction2/data/kinetics400/videos_val", topdown=False):
        for name in files:
            print("root:"+root)
            root_first_part = root[0:70]
            root_last_part = "\'"+root[70:]+"\'"
            current_dir = os.path.join(root_first_part,root_last_part, name)
            print("current dir:"+current_dir)
            vid_id = name[0:11]
            #print(vid_id)
            label = df[df['youtube_id']==vid_id]['label'].item()
            #print(label)
            label_new = "\'"+label+"\'"
            final_folder = os.path.join(des_root, label_new)
            #print(final_folder)
            final_dir=os.path.join(final_folder,name)
            print("final dir:"+final_dir)
            #os.rename(current_dir, final_dir)
            cmd=["qt-faststart"]
            cmd.append(current_dir)
            cmd.append(final_dir)
            print(cmd)
            p=subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE, universal_newlines=True)
            print(p.stdout.read())
            #p=subprocess.Popen(,shell=True, stdout=subprocess.PIPE)

fix()

the imtermediate step:

root:/home/students/s121md104_06/FYP/mmaction2/data/kinetics400/videos_val/waxing chest
current dir:/home/students/s121md104_06/FYP/mmaction2/data/kinetics400/videos_val/'waxing chest'/-8h42AaoMnc_000020_000030.mp4
final dir:/home/students/s121md104_06/FYP/mmaction2/data/k400-fix/videos_val/'waxing chest'/-8h42AaoMnc_000020_000030.mp4
['qt-faststart', "/home/students/s121md104_06/FYP/mmaction2/data/kinetics400/videos_val/'waxing chest'/-8h42AaoMnc_000020_000030.mp4", "/home/students/s121md104_06/FYP/mmaction2/data/k400-fix/videos_val/'waxing chest'/-8h42AaoMnc_000020_000030.mp4"]
Usage: qt-faststart <infile.mov> <outfile.mov>
Note: alternatively you can use -movflags +faststart in ffmpeg

root:/home/students/s121md104_06/FYP/mmaction2/data/kinetics400/videos_val/waxing chest
current dir:/home/students/s121md104_06/FYP/mmaction2/data/kinetics400/videos_val/'waxing chest'/zX8mLojq_BY_000066_000076.mp4
final dir:/home/students/s121md104_06/FYP/mmaction2/data/k400-fix/videos_val/'waxing chest'/zX8mLojq_BY_000066_000076.mp4
['qt-faststart', "/home/students/s121md104_06/FYP/mmaction2/data/kinetics400/videos_val/'waxing chest'/zX8mLojq_BY_000066_000076.mp4", "/home/students/s121md104_06/FYP/mmaction2/data/k400-fix/videos_val/'waxing chest'/zX8mLojq_BY_000066_000076.mp4"]
Usage: qt-faststart <infile.mov> <outfile.mov>
Note: alternatively you can use -movflags +faststart in ffmpeg

root:/home/students/s121md104_06/FYP/mmaction2/data/kinetics400/videos_val/waxing chest
current dir:/home/students/s121md104_06/FYP/mmaction2/data/kinetics400/videos_val/'waxing chest'/vllcsHErd-o_000036_000046.mp4
final dir:/home/students/s121md104_06/FYP/mmaction2/data/k400-fix/videos_val/'waxing chest'/vllcsHErd-o_000036_000046.mp4
['qt-faststart', "/home/students/s121md104_06/FYP/mmaction2/data/kinetics400/videos_val/'waxing chest'/vllcsHErd-o_000036_000046.mp4", "/home/students/s121md104_06/FYP/mmaction2/data/k400-fix/videos_val/'waxing chest'/vllcsHErd-o_000036_000046.mp4"]
Usage: qt-faststart <infile.mov> <outfile.mov>
Note: alternatively you can use -movflags +faststart in ffmpeg
cliangyu commented 2 years ago

If you think the single quotation marks caused the error, you can try removing it.

Remove specific characters from a string in Python - Stack Overflow https://stackoverflow.com/questions/3939361/remove-specific-characters-from-a-string-in-python