tanersener / react-native-ffmpeg

FFmpeg for react-native. Not maintained anymore. Superseded by FFmpegKit.
GNU General Public License v3.0
401 stars 52 forks source link

Could not open file in cache directory #258

Closed rajeshde closed 3 years ago

rajeshde commented 3 years ago

Description Trying to create thumbnail from a video using this below syntax

import { FileSystem } from 'react-native-unimodules';
import { RNFFmpeg } from 'react-native-ffmpeg';
import { v4 as uuidv4 } from 'uuid';

const BASE_DIR = `${FileSystem.cacheDirectory}shreem-cache/`;

const sourceUri = `file:///var/mobile/Containers/Data/Application/5757F2E2-A974-4C2D-BECE-7936272D623D/Library/Caches/Camera/C13A5C9C-B5C8-438A-A80C-906A45106A9D.mov `
const newSource = `${BASE_DIR}${uuidv4()}.jpg`;

RNFFmpeg.execute(
    `-i ${sourceUri} -vcodec mjpeg -vframes 1 -ss 0 ${newSource}`
  ).then((result) => {
    console.log("result", result); // result is coming as 1
  });

Expected behavior It should create the .jpg file with a thumbnail from 0th frame. I have tested this syntax directly from ffmpeg and it worked.

Current behavior Could not open file : file:///var/mobile/Containers/Data/Application/5757F2E2-A974-4C2D-BECE-7936272D623D/Library/Caches/shreem-cache/e705360a-56c6-4e1b-9c53-a3ff188a39e8.jpg

Logs Directly pasted the log, as https://ghostbin.co giving 502 bad gateway error.

node_modules/react-native-ffmpeg/index.js:115
    Side data:

node_modules/react-native-ffmpeg/index.js:115

node_modules/react-native-ffmpeg/index.js:115
cpb: 
node_modules/react-native-ffmpeg/index.js:115
bitrate max/min/avg: 0/0/200000 buffer size: 0 
node_modules/react-native-ffmpeg/index.js:115
vbv_delay: N/A
node_modules/react-native-ffmpeg/index.js:115

node_modules/react-native-ffmpeg/index.js:115

node_modules/react-native-ffmpeg/index.js:115
displaymatrix: rotation of -0.00 degrees
node_modules/react-native-ffmpeg/index.js:115

node_modules/react-native-ffmpeg/index.js:115
Could not open file : file:///var/mobile/Containers/Data/Application/5757F2E2-A974-4C2D-BECE-7936272D623D/Library/Caches/shreem-cache/e705360a-56c6-4e1b-9c53-a3ff188a39e8.jpg

node_modules/react-native-ffmpeg/index.js:115
av_interleaved_write_frame(): Input/output error

node_modules/react-native-ffmpeg/index.js:115
frame=    1 fps=0.0 q=3.8 Lsize=N/A time=00:00:00.03 bitrate=N/A speed=0.0905x    

node_modules/react-native-ffmpeg/index.js:115
video:11kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 
node_modules/react-native-ffmpeg/index.js:115
unknown
node_modules/react-native-ffmpeg/index.js:115

node_modules/react-native-ffmpeg/index.js:115
Conversion failed!
result 1

Environment

System:
    OS: macOS 10.15.7
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
    Memory: 40.94 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 14.17.3 - ~/.nvm/versions/node/v14.17.3/bin/node
    Yarn: Not Found
    npm: 6.14.13 - ~/.nvm/versions/node/v14.17.3/bin/npm
    Watchman: 2021.06.07.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK:
      API Levels: 29, 30
      Build Tools: 27.0.3, 28.0.3, 29.0.2, 30.0.3, 31.0.0
      System Images: android-27 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.2 AI-202.7660.26.42.7351085
    Xcode: 12.4/12D4e - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_292 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.1 => 17.0.1 
    react-native: 0.64.2 => 0.64.2 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Other I have tried executeWithArguments function too and also other compression ways. But in all cases it could not read the file

mrksohag commented 3 years ago

Use this base dir const BASE_DIR =${FileSystem.cacheDirectory}/; or create your directory first using rnfs then try to create thumbnail ${FileSystem.cacheDirectory}/shreem-cache/ You may try this code '-i '+videoUri+' -an -ss 00:00:00.00 -vframes 1 '+imageUri

rajeshde commented 3 years ago

Thanks @mrksohag. I wasn't creating the directory under cacheDirectory. I am closing this, as it was a mistake from my end.