How about

// Create your resource
BlobId blobId = BlobId.of(YOUR_BUCKET, *YOUR_FILENAME*);
BlobInfo blobInfo = BlobInfo.newBuilder(blobId).setContentType(*"video/mp4"*
).build();
Blob blob = getStorage().create(blobInfo);

WriteChannel writeChannel = blob.writer();
// Then use writeChannel to write your bytes, it extends 
WritableByteChannel which has

public int write(ByteBuffer src)

I.e you have to create an OutputStream that writes to a ByteBuffer first.

https://gist.github.com/hoijui/7fe8a6d31b20ae7af945

Sort of.

/ Linus



On Saturday, April 24, 2021 at 3:27:56 PM UTC+2 Richard Arnold wrote:

> I am attempting to use FFMPEG on Google App Engine (Java) to re-encode 
> some video files I have that are sitting in Google Cloud Storage. I found a 
> Java wrapper around ffmpeg that I would like to use here: 
> https://github.com/kokorin/Jaffree. 
>
> My issue is that this library requires an InputStream and OutputStream. I 
> am trying to specify the InputStream as a file in Google Cloud Storage and 
> the OutputStream as a new file. 
>
> I think I have done specifying the InputStream correctly, but I do not 
> know what to do about the OutputStream.
>
> How can I specify the OutputStream to be a new file?
>
> Or if possible, can I just overwrite the file in Google Cloud Storage?
>
> Here is my Java code in Google App Engine so far:
>
> Storage storage = StorageOptions.getDefaultInstance().getService();
>
> // This is the input file
> BlobId id = BlobId.of("storageBucket", "videos/video_1.mp4");
> byte[] content = storage.readAllBytes(id);
> InputStream inputStream = new ByteArrayInputStream(content);
>
> FFmpeg.atPath()
>     .addInput(PipeInput.pumpFrom(inputStream))
>     .setOverwriteOutput(true)
>     .addArguments("-movflags", "faststart")
>     .addOutput(PipeOutput.pumpTo(outputStream)) <---- I need to set this
>     .setProgressListener(new ProgressListener() {
>         @Override
>         public void onProgress(FFmpegProgress progress) {
>             double percents = 100. * progress.getTimeMillis() / 
> duration.get();
>             System.out.println("Progress: " + percents + "%");
>         }
>     })
>     .execute();
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/854de782-6647-43ad-b71b-7cf2cc17e72bn%40googlegroups.com.

Reply via email to