Recherche avancée

Médias (1)

Mot : - Tags -/pirate bay

Autres articles (108)

Sur d’autres sites (14342)

  • How to sync network audio with a different network video and play it with chewie

    26 mars 2023, par Rudra Sharma

    I am trying to stream a reddit videos on my app. For that reason I am using Reddit API but it is only giving the video url like 'redd.it/mpym0z9q8opa1/DASH_1080.mp4 ?source=fallback' with no audio but after some research I found out that we can get audio url by editing video url 'redd.it/mpym0z9q8opa1/DASH_audio.mp4 ?source=fallback'.

    


    Now I have both audio and video url with me how can I sync them on network and stream them on my app using chewie package (video player).

    


    This my code so far

    


    import &#x27;dart:async&#x27;;&#xA;import &#x27;dart:convert&#x27;;&#xA;import &#x27;package:http/http.dart&#x27; as http;&#xA;import &#x27;package:flutter/material.dart&#x27;;&#xA;import &#x27;package:video_player/video_player.dart&#x27;;&#xA;import &#x27;package:chewie/chewie.dart&#x27;;&#xA;&#xA;void main() => runApp(MyApp());&#xA;&#xA;class MyApp extends StatelessWidget {&#xA;  @override&#xA;  Widget build(BuildContext context) {&#xA;    return MaterialApp(&#xA;      title: &#x27;Reddit Videos&#x27;,&#xA;      theme: ThemeData(&#xA;        primarySwatch: Colors.blue,&#xA;        visualDensity: VisualDensity.adaptivePlatformDensity,&#xA;      ),&#xA;      home: VideoPlayerScreen(),&#xA;    );&#xA;  }&#xA;}&#xA;&#xA;class VideoPlayerScreen extends StatefulWidget {&#xA;  @override&#xA;  _VideoPlayerScreenState createState() => _VideoPlayerScreenState();&#xA;}&#xA;&#xA;class _VideoPlayerScreenState extends State<videoplayerscreen> {&#xA;  final List<string> _videoUrls = [];&#xA;&#xA;  @override&#xA;  void initState() {&#xA;    super.initState();&#xA;    _loadVideos();&#xA;  }&#xA;&#xA;  Future<void> _loadVideos() async {&#xA;    try {&#xA;      final videoUrls =&#xA;          await RedditApi.getVideoUrlsFromSubreddit(&#x27;aww&#x27;);&#xA;&#xA;      setState(() {&#xA;        _videoUrls.addAll(videoUrls);&#xA;      });&#xA;    } catch (e) {&#xA;      print(e);&#xA;    }&#xA;  }&#xA;&#xA;  @override&#xA;  Widget build(BuildContext context) {&#xA;    return Scaffold(&#xA;      appBar: AppBar(&#xA;        title: Text(&#x27;Reddit Videos&#x27;),&#xA;      ),&#xA;      body: SafeArea(&#xA;        child: _videoUrls.isNotEmpty&#xA;            ? _buildVideosList()&#xA;            : Center(child: CircularProgressIndicator()),&#xA;      ),&#xA;    );&#xA;  }&#xA;&#xA;  Widget _buildVideosList() {&#xA;    return ListView.builder(&#xA;      itemCount: _videoUrls.length,&#xA;      itemBuilder: (context, index) {&#xA;        return Padding(&#xA;          padding: const EdgeInsets.all(8.0),&#xA;          child: Chewie(&#xA;            controller: ChewieController(&#xA;              videoPlayerController: VideoPlayerController.network(&#xA;                _videoUrls[index],&#xA;              ),&#xA;              aspectRatio: 9 / 16,&#xA;              autoPlay: true,&#xA;              looping: true,&#xA;              autoInitialize: true,&#xA;            ),&#xA;          ),&#xA;        );&#xA;      },&#xA;    );&#xA;  }&#xA;}&#xA;&#xA;class RedditApi {&#xA;  static const String BASE_URL = &#x27;https://www.reddit.com&#x27;;&#xA;  static const String CLIENT_ID = &#x27;id&#x27;;&#xA;  static const String CLIENT_SECRET = &#x27;secret&#x27;;&#xA;&#xA;  static Future> getVideoUrlsFromSubreddit(&#xA;      String subredditName) async {&#xA;    final response = await http.get(&#xA;        Uri.parse(&#x27;$BASE_URL/r/$subredditName/top.json?limit=10&#x27;),&#xA;        headers: {&#x27;Authorization&#x27;: &#x27;Client-ID $CLIENT_ID&#x27;});&#xA;&#xA;    if (response.statusCode == 200) {&#xA;      final jsonData = jsonDecode(response.body);&#xA;      final postsData = jsonData[&#x27;data&#x27;][&#x27;children&#x27;];&#xA;&#xA;      final videoUrls = <string>[];&#xA;&#xA;      for (var postData in postsData) {&#xA;        if (postData[&#x27;data&#x27;][&#x27;is_video&#x27;]) {&#xA;          videoUrls.add(postData[&#x27;data&#x27;][&#x27;media&#x27;][&#x27;reddit_video&#x27;]&#xA;              [&#x27;fallback_url&#x27;]);&#xA;        }&#xA;      }&#xA;&#xA;      return videoUrls;&#xA;    } else {&#xA;      throw Exception("Failed to load videos from subreddit");&#xA;    }&#xA;  }&#xA;}&#xA;</string></void></string></videoplayerscreen>

    &#xA;

    I think the code is self explainatory about what I am trying to achieve (Trying to make a client for reddit).

    &#xA;

  • How to automate ffmpeg to split and merge parts of video, and keep the audio in sync ?

    9 décembre 2024, par Tree

    I have a Python script that automates trimming a large video (2 hours) into smaller segments and then concatenating them without re-encoding, to keep the process fast. The script runs these ffmpeg commands :

    &#xA;

    import subprocess&#xA;&#xA;# Extract chunks&#xA;segments = [(0, 300), (300, 600), (600, 900)]  # example segments in seconds&#xA;for i, (start, length) in enumerate(segments):&#xA;    subprocess.run([&#xA;        "ffmpeg", "-i", "input.mp4", "-ss", str(start), "-t", str(length),&#xA;        "-c", "copy", "-reset_timestamps", "1", "-y", f"chunk_{i}.mp4"&#xA;    ], check=True)&#xA;&#xA;# Create concat list&#xA;with open("list.txt", "w") as f:&#xA;    for i in range(len(segments)):&#xA;        f.write(f"file &#x27;chunk_{i}.mp4&#x27;\n")&#xA;&#xA;# Concatenate&#xA;subprocess.run([&#xA;    "ffmpeg", "-f", "concat", "-safe", "0",&#xA;    "-i", "list.txt", "-c", "copy", "-y", "merged_output.mp4"&#xA;], check=True)&#xA;

    &#xA;

    All chunks come from the same source video, with identical codecs, resolution, and bitrate. Despite this, the final merged_output.mp4 sometimes has audio out of sync—especially after the first chunk.

    &#xA;

    I’ve tried using -ss before -i to cut on keyframes, but the issue persists.

    &#xA;

    Question : How can I ensure correct A/V sync in the final concatenated video when programmatically segmenting and merging via ffmpeg without fully re-encoding ? Is there a way to adjust the ffmpeg commands or process to avoid audio desynchronization ?

    &#xA;

  • How to convert 7sec Video to Gif Android

    21 août 2014, par Donnie Ibiyemi

    Am making an app that convert shot video clips to Gif. i was wondering if there was a libary that directly converts videos to gifs on the Fly on Android.

    I’ve tried to extract all the frames of the video and encode them into a gif but am only getting the the first frame of the video. my code is below :

            public static final int GIF_DELAY_BETWEEN_FRAMES = 100;  
            public static final float SPEED_RATIO = 1.1f;

            Uri videoFileUri=Uri.parse(mOutputFile.toString());
           FFmpegMediaMetadataRetriever retriever = new FFmpegMediaMetadataRetriever();
           retriever.setDataSource(mOutputFile.getAbsolutePath());
            rev = new ArrayList<bitmap>();
           MediaPlayer mp = MediaPlayer.create(RecorderActivity.this, videoFileUri);
            int millis = mp.getDuration();
            for(int i=1000000;itest.gif");
               outStream.write(generateGIF());
               outStream.close();
            }catch(Exception e){
               e.printStackTrace();
            }


           public byte[] generateGIF() {
           ByteArrayOutputStream bos = new ByteArrayOutputStream();
           AnimatedGifEncoder encoder = new AnimatedGifEncoder();
           encoder.setDelay((int)(GIF_DELAY_BETWEEN_FRAMES * (1 / SPEED_RATIO)));
           encoder.start(bos);
           for (Bitmap bitmap : rev) {
               encoder.addFrame(bitmap);
           }
           encoder.finish();
           return bos.toByteArray();
        }
    </bitmap>

    Please help me guys...thanks